[
https://issues.apache.org/jira/browse/IGNITE-24736?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Andrey Mashenkov updated IGNITE-24736:
--------------------------------------
Summary: Fix invalid IgniteTestUtils.randomString function (was: Fix
invalid )
> Fix invalid IgniteTestUtils.randomString function
> -------------------------------------------------
>
> Key: IGNITE-24736
> URL: https://issues.apache.org/jira/browse/IGNITE-24736
> Project: Ignite
> Issue Type: Improvement
> Reporter: Maksim Zhuravkov
> Assignee: Andrey Mashenkov
> Priority: Major
> Labels: ignite-3
> Fix For: 3.1
>
>
> Reproducer run `write` with JDK 11, run `read` against JDK 11 - strings match.
> run `read` against JDK 17, strings won't match.
> {code:java}
> public class RandomStringTest {
> private final Random random = new Random();
> @BeforeEach
> public void before() {
> random.setSeed(111);
> }
> @Test
> public void write() throws IOException {
> // Write JDK 11
> String s = IgniteTestUtils.randomString(random, 512);
> try (IgniteUnsafeDataOutput os = new IgniteUnsafeDataOutput(111)) {
> os.writeUTF(s);
> byte[] array = os.array();
> System.err.println(Arrays.toString(array));
> Path dir = Paths.get(".").toAbsolutePath();
> Files.write(dir.resolve("string.bin"), array);
> }
> }
> @Test
> public void read() throws IOException {
> // Read JDK 17
> String s = IgniteTestUtils.randomString(random, 512);
> Path dir = Paths.get(".").toAbsolutePath();
> byte[] bytes = Files.readAllBytes(dir.resolve("string.bin"));
> try (IgniteUnsafeDataInput os = new IgniteUnsafeDataInput(bytes)) {
> String s1 = os.readUTF();
> assertEquals(s, s1);
> }
> }
> }
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)