CherishCai opened a new issue, #2618: URL: https://github.com/apache/fory/issues/2618
### Search before asking - [x] I had searched in the [issues](https://github.com/apache/fory/issues) and found no similar issues. ### Version Java fury 0.12.2 ### Component(s) Java ### Minimal reproduce step It should be tested multiple times to reproduce ..... ```java @Test public void testSerializeConcurrentHashMap() throws Exception { ThreadSafeFory fory = new ThreadLocalFory(classLoader -> { Fory f = Fory.builder().withLanguage(Language.JAVA) .withRefTracking(false) .withCodegen(true) .withNumberCompressed(true) .withCompatibleMode(CompatibleMode.COMPATIBLE) .withClassLoader(classLoader) .withAsyncCompilation(false) .withBufferSizeLimitBytes(4 * 1024 * 1024) .requireClassRegistration(false) .build(); f.register(TestClass.class); return f; }); TestClass testClass = new TestClass(); testClass.addSpan("spanKey", System.currentTimeMillis()); byte[] encoded0 = fory.serialize(testClass); for (int j = 0; j < 4; j++) { new Thread(() -> { for (int i = 0; i < 1000_000; i++) { testClass.addSpan("spanKey" + i, System.currentTimeMillis()); } }).start(); } TimeUnit.MILLISECONDS.sleep(1); byte[] encoded = fory.serialize(testClass); TestClass decodeObj = (TestClass) fory.deserialize(encoded); System.out.println("TestClass decodeObj.span.size: " + decodeObj.getSpan().size()); } public static class TestClass { private Map<String, Object> span; public Map<String, Object> getSpan() { return span; } public void setSpan(Map<String, Object> span) { this.span = span; } public void addSpan(String spanKey, Object spanVal) { if (span == null) { this.span = new ConcurrentHashMap<>(); } this.span.put(spanKey, spanVal); } } ``` ### What did you expect to see? Can accurately serialize JUC concurrent containers such as ConcurrentHashMap / CopyOnWriteArrayList / ConcurrentLinkedQueue ### What did you see instead? The bytes serialized by Fory are incorrect, when`ConcurrentHashMap` is set concurrently ### Anything Else? _No response_ ### Are you willing to submit a PR? - [ ] I'm willing to submit a PR! -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
