You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if (unknownTokens != null) {
// need to add END_OBJECT marker first
unknownTokens.writeEndObject();
JsonParser p2 = unknownTokens.asParser(p.streamReadConstraints()); <-- !!! HERE !!!
p2.nextToken(); // to get to first data field
bean = subDeser.deserialize(p2, ctxt, bean);
}
Exception in thread "main" java.lang.NullPointerException:
Cannot invoke "com.fasterxml.jackson.core.JsonParser.streamReadConstraints()" because "p" is null
at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.handlePolymorphic(BeanDeserializerBase.java:1749)
at com.fasterxml.jackson.databind.deser.BeanDeserializer._deserializeUsingPropertyBased(BeanDeserializer.java:541)
at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.deserializeFromObjectUsingNonDefault(BeanDeserializerBase.java:1409)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:352)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:185)
at com.fasterxml.jackson.databind.deser.DefaultDeserializationContext.readRootValue(DefaultDeserializationContext.java:323)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4825)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3772)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3740)
Version information
Which Jackson version(s) was this for? 2.15.0
To Reproduce
Here's a minimal code to reproduce. Note the intentional mismatch between the supplied and expected field names (one and two).
public class Main {
public static void main(String[] args) throws Exception {
new ObjectMapper().readValue("{\"one\":1}", Parent.class);
}
public abstract static class Parent {
@JsonCreator
public static Parent create(@JsonProperty("two") String two) {
return new Child();
}
}
public static class Child extends Parent {}
}
Additional context
A more real-world example would be an AutoValue class. It would trigger the exception similarly to the example above.
The bug seems to have been introduced by #3691 in 2.15.0
The text was updated successfully, but these errors were encountered:
mishako
changed the title
NullPointerException when deserializing a polymorphic with unknown properties
2.15.0 throws NPE when deserializing a polymorphic with unknown properties
May 3, 2023
Describe the bug
This line throws NullPointerException:
https://github.com/FasterXML/jackson-databind/blob/2.15/src/main/java/com/fasterxml/jackson/databind/deser/BeanDeserializerBase.java#L1749
Version information
Which Jackson version(s) was this for? 2.15.0
To Reproduce
Here's a minimal code to reproduce. Note the intentional mismatch between the supplied and expected field names (
one
andtwo
).Additional context
A more real-world example would be an AutoValue class. It would trigger the exception similarly to the example above.
The bug seems to have been introduced by #3691 in 2.15.0
The text was updated successfully, but these errors were encountered: