The read methods on JsonParserSequence previously correctly used all parsers in the sequence, however after upgrading to Jackson 3.x they only use the first one. This caused corrupt parsing in our application, dropping parts of the input json. We had a custom deserializer using the same mechanism as AsPropertyTypeDeserializer (which scans ahead for an @type property, then deserializing with a JsonParserSequence of a TokenBuffer and the actual parser).
Cause
Jackson 2.x - inherited from JsonParser superclass:
public <T extends TreeNode> T readValueAsTree() throws IOException {
return (T) _codec().readTree(this); // passing this causes all Parsers in the sequence to be used
}
Jackson 3.x - overridden by JsonParserDelegate superclass in 8ee7d0f, becoming incorrect for JsonParserSequence:
public <T extends TreeNode> T readValueAsTree() throws IOException {
return delegate.readValueAsTree(); // delegate is set to parsers[0] for JsonParserSequence
}
Workaround
Instead of parser.readValueAsTree() (or other read methods), use context.readTree(parser)
The read methods on
JsonParserSequencepreviously correctly used all parsers in the sequence, however after upgrading to Jackson 3.x they only use the first one. This caused corrupt parsing in our application, dropping parts of the input json. We had a custom deserializer using the same mechanism asAsPropertyTypeDeserializer(which scans ahead for an@typeproperty, then deserializing with aJsonParserSequenceof aTokenBufferand the actual parser).Cause
Jackson 2.x - inherited from JsonParser superclass:
Jackson 3.x - overridden by JsonParserDelegate superclass in 8ee7d0f, becoming incorrect for JsonParserSequence:
Workaround
Instead of
parser.readValueAsTree()(or other read methods), usecontext.readTree(parser)