OmCheeLin commented on issue #2251: URL: https://github.com/apache/fury/issues/2251#issuecomment-2924317713
I have reproduced this issue on the main branch and found some differences. ```java public static final class EmptyList extends AbstractList<Object> { @Override public Object get(int index) { throw new IndexOutOfBoundsException(); } @Override public int size() { return 0; } public static final class EmptySerializer extends AbstractCollectionSerializer<EmptyList> { public EmptySerializer(Fory fory) { super(fory, EmptyList.class); } @Override public Collection onCollectionWrite(MemoryBuffer buffer, EmptyList value) { return Collections.emptyList(); } @Override public void write(MemoryBuffer buffer, EmptyList value) { // no-op } @Override public EmptyList read(MemoryBuffer buffer) { return new EmptyList(); } @Override public EmptyList onCollectionRead(Collection collection) { return new EmptyList(); } } } @Data public static class SomeRecord { private final EmptyList specialList; private final List<Object> normalList; public SomeRecord(EmptyList specialList, List<Object> normalList) { this.specialList = specialList; this.normalList = normalList; } } @Test public void testCollection() { Fory fury = Fory.builder() .withLanguage(Language.JAVA) .build(); fury.register(EmptyList.class); fury.registerSerializer(EmptyList.class, EmptyList.EmptySerializer.class); fury.register(SomeRecord.class); SomeRecord someRecord = new SomeRecord(new EmptyList(), new ArrayList<>()); byte[] bytes = fury.serialize(someRecord); // <--No Exception Object output = fury.deserialize(bytes); // <--No Exception } ``` ```txt java.lang.IndexOutOfBoundsException: readerIndex(8) + length(1) exceeds size(8): org.apache.fory.memory.MemoryBuffer$BoundChecker@7b4c50bc at org.apache.fory.memory.MemoryBuffer$BoundChecker.fillBuffer(MemoryBuffer.java:186) at org.apache.fory.memory.MemoryBuffer.readByte(MemoryBuffer.java:1353) at org.apache.fory.memory.MemoryBuffer.readVarUint36Slow(MemoryBuffer.java:1786) at org.apache.fory.memory.MemoryBuffer.readVarUint32Small14(MemoryBuffer.java:1886) at org.apache.fory.memory.MemoryBuffer.readVarUint32Small7(MemoryBuffer.java:1860) at org.apache.fory.serializer.collection.AbstractCollectionSerializer.newCollection(AbstractCollectionSerializer.java:487) at org.apache.fory.ForyTest_SomeRecordForyCodec_0.readFields1$(ForyTest_SomeRecordForyCodec_0.java:314) at org.apache.fory.ForyTest_SomeRecordForyCodec_0.read(ForyTest_SomeRecordForyCodec_0.java:366) at org.apache.fory.Fory.readDataInternal(Fory.java:1043) at org.apache.fory.Fory.readRef(Fory.java:917) at org.apache.fory.Fory.deserialize(Fory.java:871) at org.apache.fory.Fory.deserialize(Fory.java:781) at org.apache.fory.ForyTest.testCollection(ForyTest.java:602) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.testng.internal.invokers.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:136) at org.testng.internal.invokers.TestInvoker.invokeMethod(TestInvoker.java:658) at org.testng.internal.invokers.TestInvoker.invokeTestMethod(TestInvoker.java:219) at org.testng.internal.invokers.MethodRunner.runInSequence(MethodRunner.java:50) at org.testng.internal.invokers.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:923) at org.testng.internal.invokers.TestInvoker.invokeTestMethods(TestInvoker.java:192) at org.testng.internal.invokers.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:146) at org.testng.internal.invokers.TestMethodWorker.run(TestMethodWorker.java:128) at java.util.ArrayList.forEach(ArrayList.java:1259) at org.testng.TestRunner.privateRun(TestRunner.java:808) at org.testng.TestRunner.run(TestRunner.java:603) at org.testng.SuiteRunner.runTest(SuiteRunner.java:429) at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:423) at org.testng.SuiteRunner.privateRun(SuiteRunner.java:383) at org.testng.SuiteRunner.run(SuiteRunner.java:326) at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52) at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:95) at org.testng.TestNG.runSuitesSequentially(TestNG.java:1249) at org.testng.TestNG.runSuitesLocally(TestNG.java:1169) at org.testng.TestNG.runSuites(TestNG.java:1092) at org.testng.TestNG.run(TestNG.java:1060) at com.intellij.rt.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:65) at com.intellij.rt.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:105) ``` -- 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: commits-unsubscr...@fury.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@fury.apache.org For additional commands, e-mail: commits-h...@fury.apache.org