GimoXie commented on issue #1085:
URL: https://github.com/apache/fury/issues/1085#issuecomment-2699696402
## Fury Version
0.7.1
## JDK Version
21
## Problem Description
When using Fury for serialization, a NullPointerException occurred. Here is
the error message:
`java.lang.NullPointerException
at
org.apache.fury.resolver.ClassResolver.createSerializer(ClassResolver.java:1177)
at
org.apache.fury.resolver.ClassResolver.getClassInfo(ClassResolver.java:1108)
at
org.apache.fury.serializer.collection.AbstractCollectionSerializer.writeTypeHeader(AbstractCollectionSerializer.java:203)
at
org.apache.fury.serializer.collection.AbstractCollectionSerializer.writeElementsHeader(AbstractCollectionSerializer.java:135)
at
org.apache.fury.serializer.collection.AbstractCollectionSerializer.writeElements(AbstractCollectionSerializer.java:310)
at
org.apache.fury.serializer.collection.AbstractCollectionSerializer.write(AbstractCollectionSerializer.java:305)
at org.apache.fury.Fury.writeNonRef(Fury.java:475)
at
org.apache.fury.serializer.ObjectSerializer.writeContainerFieldValue(ObjectSerializer.java:213)
at
org.apache.fury.serializer.ObjectSerializer.writeContainerFields(ObjectSerializer.java:195)
at
org.apache.fury.serializer.ObjectSerializer.write(ObjectSerializer.java:146)
at
org.apache.fury.serializer.collection.AbstractCollectionSerializer.writeSameTypeElements(AbstractCollectionSerializer.java:404)
at
org.apache.fury.serializer.collection.AbstractCollectionSerializer.generalJavaWrite(AbstractCollectionSerializer.java:391)
at
org.apache.fury.serializer.collection.AbstractCollectionSerializer.javaWriteWithGenerics(AbstractCollectionSerializer.java:369)
at
org.apache.fury.serializer.collection.AbstractCollectionSerializer.writeElements(AbstractCollectionSerializer.java:318)
at
org.apache.fury.serializer.collection.AbstractCollectionSerializer.write(AbstractCollectionSerializer.java:305)
at org.apache.fury.Fury.writeNonRef(Fury.java:475)
at
org.apache.fury.serializer.ObjectSerializer.writeContainerFieldValue(ObjectSerializer.java:213)
at
org.apache.fury.serializer.ObjectSerializer.writeContainerFields(ObjectSerializer.java:195)
at
org.apache.fury.serializer.ObjectSerializer.write(ObjectSerializer.java:146)
at org.apache.fury.Fury.writeData(Fury.java:584)
at org.apache.fury.Fury.write(Fury.java:347)
at org.apache.fury.Fury.serialize(Fury.java:269)
at org.apache.fury.Fury.lambda$serialize$0(Fury.java:285)
at org.apache.fury.Fury.serializeToStream(Fury.java:1427)
at org.apache.fury.Fury.serialize(Fury.java:285)
at com.ctrip.fury.FuryTest.testFurySerialize2(FuryTest.java:50)
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.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at
org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at
com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
at
com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
at
com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
at
com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
at
com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:232)
at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:55)`
## Sample Code
`/**
* {
* "holderList": [
* {
* "dataList": [
* null
* ]
* }
* ]
* }
*/
public class FuryTest {
@Test
public void testFurySerialize2() throws IOException {
Fury fury = Fury.builder()
.withLanguage(Language.JAVA)
.withRefTracking(true)
.withCompatibleMode(CompatibleMode.COMPATIBLE)
.withDeserializeNonexistentClass(true)
.requireClassRegistration(false)
.withAsyncCompilation(true)
.build();
List<Data> dataList = new ArrayList<>();
dataList.add(null);
DataHolder holder = new DataHolder();
holder.setDataList(dataList);
FuryTestResponse response = new FuryTestResponse();
response.setHolderList(Lists.newArrayList(holder));
fury.serialize(new
CountingOutputStream(newOutputStream(Paths.get("test"))), response);
}
@Getter
@Setter
class Data {
private String message;
}
@Getter
@Setter
class DataHolder {
private List<Data> dataList;
}
@Getter
@Setter
class FuryTestResponse {
private List<DataHolder> holderList;
}
}`
Thank you for your time and effort in looking into this issue. I appreciate
your help in resolving this problem.
--
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]