Skip to content
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

DeserializationProblemHandler is not invoked when trying to deserializing String #2973

Closed
zigzago opened this issue Dec 6, 2020 · 2 comments
Milestone

Comments

@zigzago
Copy link

zigzago commented Dec 6, 2020

Describe the bug
KMongo (https://github.com/Litote/kmongo) uses DeserializationProblemHandler in order to patch some unexpected deserialization issue (see https://github.com/Litote/kmongo/blob/master/kmongo-jackson-mapping/src/main/kotlin/org/litote/kmongo/jackson/StringDeserializationProblemHandler.kt#L38 )

in 2.12.0 I got this stacktrace (and DeserializationProblemHandler is not called)

com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize value of type `java.lang.String` from Object value (token `JsonToken.START_OBJECT`)
 at [Source: de.undercouch.bson4jackson.io.LittleEndianInputStream@2c7d121c; pos: 24] (through reference chain: org.litote.kmongo.issues.Issue85ObjectIdIsNotProperlyDeserializedInAStringPropertyWhenPropertyIsInherited$MainData["_id"])

	at com.fasterxml.jackson.databind.exc.MismatchedInputException.from(MismatchedInputException.java:63)
	at com.fasterxml.jackson.databind.DeserializationContext.reportInputMismatch(DeserializationContext.java:1590)
	at com.fasterxml.jackson.databind.DeserializationContext.extractScalarFromObject(DeserializationContext.java:872)
	at com.fasterxml.jackson.databind.deser.std.StringDeserializer.deserialize(StringDeserializer.java:62)
	at com.fasterxml.jackson.databind.deser.std.StringDeserializer.deserialize(StringDeserializer.java:11)
	at com.fasterxml.jackson.databind.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:542)
	at com.fasterxml.jackson.databind.deser.BeanDeserializer._deserializeWithErrorWrapping(BeanDeserializer.java:565)

Version information
Which Jackson version(s) was this for? 2.12.0
2.11.3 is ok

To Reproduce

This KMongo test fails: https://github.com/Litote/kmongo/blob/master/kmongo/src/test/kotlin/org/litote/kmongo/issues/Issue85ObjectIdIsNotProperlyDeserializedInAStringPropertyWhenPropertyIsInherited.kt#L70

Expected behavior
DeserializationProblemHandler invoked

Additional context
Digging in the code (StringDeserializer line 61):


// 29-Jun-2020, tatu: New! "Scalar from Object" (mostly for XML)
        if (t == JsonToken.START_OBJECT) {
            return ctxt.extractScalarFromObject(p, this, _valueClass);
        }
(...)
 return (String) ctxt.handleUnexpectedToken(_valueClass, p);

@zigzago zigzago added the to-evaluate Issue that has been received but not yet evaluated label Dec 6, 2020
@cowtowncoder cowtowncoder added 2.12 and removed to-evaluate Issue that has been received but not yet evaluated labels Dec 6, 2020
@cowtowncoder
Copy link
Member

Thank you for reporting this: sounds like a regression in that DeserializationProblemHandler.handleUnexpectedToken(..) used to be called earlier but now new default extractScalarFromObject does not call it.

@cowtowncoder cowtowncoder changed the title DeserializationProblemHandler is not invoked when trying to deserializing String (regression in 2.12.0) DeserializationProblemHandler is not invoked when trying to deserializing String Dec 9, 2020
@cowtowncoder cowtowncoder modified the milestones: 2.12.0, 2.12.1 Dec 9, 2020
@cowtowncoder
Copy link
Member

Fixed for 2.12.1 -- thank you for reporting this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants