[ https://issues.apache.org/jira/browse/IGNITE-24736?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17937187#comment-17937187 ]
Andrey Mashenkov commented on IGNITE-24736: ------------------------------------------- The reason is `IgniteUtils.randomString` function skips different characters in Java 17. Actually, the function implementation is invalid because we pass `char` to function that accepts `int` code point. > IgniteUnsafeData writeUTF / readUTF depends on Java version > ----------------------------------------------------------- > > 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 > > 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)