Closed mof-dev-3 closed 12 months ago
Pls also consider following variant case AbstractCollectionSerializer.writeTypeNullabilityHeader method, which fail the NPE assert
`
public class CollectionsTest {
public static class TestCollectionHolder<T> {
private List<T> data;
public List getData() {
return data;
}
public void setData(List data) {
this.data = data;
}
public TestCollectionHolder(List data) {
this.data = data;
}
}
@org.testng.annotations.Test
public void testCollection() {
List data = new ArrayList<>();
data.add(null);
CollectionsTest.TestCollectionHolder h = new CollectionsTest.TestCollectionHolder(data);
Fury f = Fury.builder()
.withLanguage(Language.JAVA)
.build();
f.register(CollectionsTest.TestCollectionHolder.class);
byte[] serialize = f.serialize(h);
Object deserialize = f.deserialize(serialize);
Assert.assertEquals(deserialize.getClass(), h.getClass());
CollectionsTest.TestCollectionHolder h2 = (CollectionsTest.TestCollectionHolder) deserialize;
Assert.assertEquals(h2.getData(), h.getData());
}
}
`
Thanks for creating this issue @mof-dev-3 , I can reproduce it. I fixed it in https://github.com/alipay/fury/pull/1086 , please try it out and reopen this issue if the bug still persists.
This is a bug introduced in #923
How to reproduce ` public static class TestCollectionObj {
`
Expected behavior serialize with no exception
maybe we should check elemGenericType is null case and write a special flag like Fury.NULL_FLAG instead
Environment (please complete the following information): openjdk version "1.8.0_312" ubuntu 20