urlyy opened a new issue, #2718:
URL: https://github.com/apache/fory/issues/2718

   ### Search before asking
   
   - [x] I had searched in the [issues](https://github.com/apache/fory/issues) 
and found no similar issues.
   
   
   ### Version
   
   Latest
   
   ### Component(s)
   
   Java
   
   ### Minimal reproduce step
   
   ```java
   enum Color {
     Green,
     Red,
     Blue,
     White,
   }
   
   static class MyStruct {
     int id;
   
     public MyStruct(int id) {
       this.id = id;
     }
   }
   
   @Data
   static class MyExt {
     int id;
   
     public MyExt(int id) {
       this.id = id;
     }
   
     public MyExt() {}
   }
   
   private static class MyExtSerializer extends Serializer<MyExt> {
   
     public MyExtSerializer(Fory fory, Class<MyExt> cls) {
       super(fory, cls);
     }
   
     @Override
     public void write(MemoryBuffer buffer, MyExt value) {
       xwrite(buffer, value);
     }
   
     @Override
     public MyExt read(MemoryBuffer buffer) {
       return xread(buffer);
     }
   
     @Override
     public void xwrite(MemoryBuffer buffer, MyExt value) {
       buffer.writeVarInt32(value.id);
     }
   
     @SuppressWarnings("unchecked")
     @Override
     public MyExt xread(MemoryBuffer buffer) {
       MyExt obj = new MyExt();
       obj.id = buffer.readVarInt32();
       return obj;
     }
   }
   
   @Data
   static class MyWrapper {
     Color color;
     MyExt my_ext;
     MyStruct my_struct;
   }
   
   @Data
   static class EmptyWrapper {}
   
   @Test
   public void testJava() {
     Fory fory1 =
         Fory.builder()
             .withLanguage(Language.XLANG)
             .withCompatibleMode(CompatibleMode.COMPATIBLE)
             .withCodegen(false)
             .build();
     fory1.register(Color.class, 101);
     fory1.register(MyStruct.class, 102);
     fory1.register(MyExt.class, 103);
     fory1.registerSerializer(MyExt.class, MyExtSerializer.class);
     fory1.register(MyWrapper.class, 104);
     Fory fory2 =
         Fory.builder()
             .withLanguage(Language.XLANG)
             .withCompatibleMode(CompatibleMode.COMPATIBLE)
             .withCodegen(false)
             .build();
     fory2.register(MyExt.class, 103);
     fory2.registerSerializer(MyExt.class, MyExtSerializer.class);
     fory2.register(EmptyWrapper.class, 104);
     MyWrapper wrapper = new MyWrapper();
     wrapper.color = Color.White;
     MyStruct myStruct = new MyStruct(42);
     MyExt myExt = new MyExt(43);
     wrapper.my_ext = myExt;
     wrapper.my_struct = myStruct;
     byte[] serialize = fory1.serialize(wrapper);
     MemoryBuffer buffer2 = MemoryUtils.wrap(serialize);
     EmptyWrapper newWrapper = (EmptyWrapper) fory2.deserialize(buffer2);
     Assert.assertEquals(newWrapper, new EmptyWrapper());
   }
   ```
   
   ### What did you expect to see?
   
   pass test
   
   ### What did you see instead?
   
   ```
   
   org.apache.fory.exception.DeserializationException: Failed to deserialize 
input
   
        at 
org.apache.fory.util.ExceptionUtils.handleReadFailed(ExceptionUtils.java:66)
        at org.apache.fory.Fory.deserialize(Fory.java:889)
        at org.apache.fory.Fory.deserialize(Fory.java:821)
        at org.apache.fory.RustXlangTest.testJava(RustXlangTest.java:766)
        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)
   Caused by: java.lang.IllegalStateException: Type id 3377663 not registered
        at 
org.apache.fory.resolver.XtypeResolver.throwUnexpectTypeIdException(XtypeResolver.java:786)
        at 
org.apache.fory.resolver.XtypeResolver.readClassInfo(XtypeResolver.java:763)
        at org.apache.fory.Fory.xreadNonRef(Fory.java:1086)
        at 
org.apache.fory.serializer.SerializationBinding$XlangSerializationBinding.readNonRef(SerializationBinding.java:390)
        at 
org.apache.fory.serializer.AbstractObjectSerializer.readOtherFieldValue(AbstractObjectSerializer.java:140)
        at 
org.apache.fory.serializer.MetaSharedSerializer.read(MetaSharedSerializer.java:216)
        at 
org.apache.fory.serializer.MetaSharedSerializer.xread(MetaSharedSerializer.java:261)
        at org.apache.fory.Fory.xreadNonRef(Fory.java:1121)
        at org.apache.fory.Fory.xreadRef(Fory.java:1056)
        at org.apache.fory.Fory.deserialize(Fory.java:883)
        ... 29 more
   ```
   
   ### 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]

Reply via email to