-
-
Notifications
You must be signed in to change notification settings - Fork 221
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
After upgrade to 2.12.0, NPE when deserializing an empty element to ArrayList
#435
Comments
Thank you for reporting this & contributing possible fix! I think I'll first try to reproduce this, and then can use your patch to verify fix. |
ArrayList
Ok, this was interesting... coercion from empty XML element to Thank you for reporting the issue and suggesting a patch -- this made it easy to resolve the problem! |
@cowtowncoder Thanks to you for checking and adding all needed for a proper fix 👍 |
@cowtowncoder is 2.12.1-SNAPSHOT artifacts available somewhere? |
Thank you for reporting this -- it is too bad we didn't yet have unit test coverage for this particular case, but better late than never! :) Snapshots should be built by Travis, and available from Sonatype OSS repo. But I'll make sure to force manual deploy of snapshot version too. It looks like free Travis builds do not work very well any more for whatever reason. :-/ |
Oh, I am well aware of this... Thanks again. |
@cowtowncoder with 2.12.1-SNAPSHOT the following code: XML_MAPPER = new XmlMapper();
XML_MAPPER.configOverride(List.class).setSetterInfo(JsonSetter.Value.forValueNulls(Nulls.AS_EMPTY));
XML_MAPPER.configOverride(Set.class).setSetterInfo(JsonSetter.Value.forValueNulls(Nulls.AS_EMPTY));
XML_MAPPER.configOverride(Map.class).setSetterInfo(JsonSetter.Value.forValueNulls(Nulls.AS_EMPTY));
XML_MAPPER.enable(FromXmlParser.Feature.EMPTY_ELEMENT_AS_NULL);
List<LoggerTO> original = new ArrayList<>();
StringWriter writer = new StringWriter();
XML_MAPPER.writeValue(writer, original);
List<LoggerTO> actual = XML_MAPPER.readValue(writer.toString(), new TypeReference<List<LoggerTO>>() {
});
assertEquals(original, actual); fails with message
I have verified that serialization produces <ArrayList/> |
@ilgrosso Ok, I know this is related but could you create a separate issue for this part of the problem (null-handling ignored) -- I'll have to check it separately. I'll have to see if null coercion was to be applied for root values or not (in regular JSON handling). |
@cowtowncoder sure - see #437 |
This code:
generates the following XML:
<ArrayList/>
With same
XML_MAPPER
initialization, however, the following code:raises the following NPE:
Without the init line
this works as expected but I have failures elsewhere, when the Java list is part of a POJO:
With none of the lines:
all is working with Jackson 2.11.3.
Anything obvious I am missing? Thanks for your support.
The text was updated successfully, but these errors were encountered: