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

   ### Question
   
   I just updated my serialization library code (to serialize types in some 
libraries I maintain) to Fory 0.11.0, and there's some very confusing new 
breaking changes. These range from a NullPointerException thrown sometimes by 
Fory when serializing (I have no idea why it happens and the exception info 
isn't clear; I will paste it below), to the (bizarre) requirement that Map and 
Collection types extend specific abstract Serializer types, which don't have 
nearly enough documentation for how to extend them or even why they are 
required. This didn't seem to be a requirement in 0.10.2 .
   
   My errors:
   
   Collection type doesn't extend a specific abstract serializer, even though a 
Serializer worked fine before:
   
   ```
   Serializer for type com.github.yellowstonegames.grid.CoordSet must extend 
AbstractCollectionSerializer, but got 
com.github.yellowstonegames.wrath.grid.CoordSetSerializer
   java.lang.IllegalArgumentException: Serializer for type 
com.github.yellowstonegames.grid.CoordSet must extend 
AbstractCollectionSerializer, but got 
com.github.yellowstonegames.wrath.grid.CoordSetSerializer
        at 
org.apache.fory.serializer.SerializationUtils.validateSerializer(SerializationUtils.java:57)
        at 
org.apache.fory.serializer.SerializationUtils.validate(SerializationUtils.java:62)
        at 
org.apache.fory.resolver.ClassResolver.registerSerializer(ClassResolver.java:745)
        at org.apache.fory.Fory.registerSerializer(Fory.java:235)
        at 
com.github.yellowstonegames.wrath.grid.GridTest.testCoordSet(GridTest.java:68)
        at 
java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
        at java.base/java.lang.reflect.Method.invoke(Method.java:580)
        at 
org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
   
   ```
   
   Map has the same issue:
   
   ```
   Serializer for type com.github.yellowstonegames.grid.CoordObjectMap must 
extend AbstractMapSerializer, but got 
com.github.yellowstonegames.wrath.grid.CoordObjectMapSerializer
   java.lang.IllegalArgumentException: Serializer for type 
com.github.yellowstonegames.grid.CoordObjectMap must extend 
AbstractMapSerializer, but got 
com.github.yellowstonegames.wrath.grid.CoordObjectMapSerializer
        at 
org.apache.fory.serializer.SerializationUtils.validateSerializer(SerializationUtils.java:57)
        at 
org.apache.fory.serializer.SerializationUtils.validate(SerializationUtils.java:63)
        at 
org.apache.fory.resolver.ClassResolver.registerSerializer(ClassResolver.java:745)
        at org.apache.fory.Fory.registerSerializer(Fory.java:235)
        at 
com.github.yellowstonegames.wrath.grid.GridTest.testCoordObjectMap(GridTest.java:98)
        at 
java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
        at java.base/java.lang.reflect.Method.invoke(Method.java:580)
        at 
org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
   ```
   
   And the mystery NPE:
   
   ```
   java.lang.NullPointerException
        at 
org.apache.fory.util.Preconditions.checkNotNull(Preconditions.java:26)
        at 
org.apache.fory.resolver.ClassResolver.addSerializer(ClassResolver.java:843)
        at 
org.apache.fory.resolver.ClassResolver.getClassInfo(ClassResolver.java:1257)
        at 
com.github.yellowstonegames.core.GapShufflerForyCodec_0.writeClassAndObject$(GapShufflerForyCodec_0.java:58)
        at 
com.github.yellowstonegames.core.GapShufflerForyCodec_0.write(GapShufflerForyCodec_0.java:229)
        at org.apache.fory.Fory.writeData(Fory.java:663)
        at org.apache.fory.Fory.serializeJavaObject(Fory.java:1178)
        at org.apache.fory.Fory.serializeJavaObject(Fory.java:1149)
        at 
com.github.yellowstonegames.wrath.core.CoreTest.testGapShuffler(CoreTest.java:65)
        at 
java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
        at java.base/java.lang.reflect.Method.invoke(Method.java:580)
        at 
org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
        at 
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
        at 
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
        at 
org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
        at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
        at 
org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
        at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
        at 
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
        at 
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
        at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
        at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
        at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
        at 
org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:112)
        at 
org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:58)
        at 
org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:40)
        at 
org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:54)
        at 
org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:53)
        at 
java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
        at java.base/java.lang.reflect.Method.invoke(Method.java:580)
        at 
org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
        at 
org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
        at 
org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33)
        at 
org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:92)
   ```
   
   My code that made the update to 0.11.0 is all in this commit, 
https://github.com/yellowstonegames/SquidSquad/commit/058354141cd8b9a680c2d573a9c5ae8c59127d62#diff-31ceb662f8e35cc286b96e63097b54dc67aa093d190a40028f02b141fbba2c78L55
 . The repo should be able to be checked out and built using Gradle, and the 
tests in the squidwrath submodule seem to fail often so far. squidwrathcore in 
particular has the mysterious NPEs.
   
   Let me know what I need to do to get more info if you need it! I, myself, 
need more info on how AbstractMapSerializer and AbstractCollectionSerializer 
work; is there any documentation for what the Map returned by one 
AbstractMapSerializer method is? The reading/copying methods appear totally 
missing JavaDocs.


-- 
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