-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Exception at value deserializer (custom deserializer) #853
Comments
Before figuring out what the proper fix is, it'd be necessary to see the code for POJOs, as well as code you use for deserialization. While exception is thrown from a specific place does not necessarily mean the problem occurred there, since deserializers called earlier may have read too little or too much, leading to insonsistent state. |
Hi, Sorry for the delayed response. Here is the my service method:
I have a custom deserializer for "connParams", because the fields in "connParams" are not fixed. They will be changing for each response. Here is my custom deserializer
|
Looking at your deserializer, I highly suspect it gets confused with the input and this is the reason for your problems. The reason is that you are not used Both methods will return It is oftentimes more reliably to use |
Thanks for the info! |
Hi,
I have created a custom JsonDeserializer for one of the type (say, ConnParams), which I'm using in my project. This ConnParams type is an inner class of another type (say, Connection).
In one of the Json response / data, I get an array of connections which will optionally contain connParams data. For the deserialization of connection object, I'm able to deseriailze with the objectMapper. But for deserialization of connParams object, I'm using a custom deserializer which extends JsonDeserializer<Connection.ConnParams>.
It is working fine, when I have a response with array of connections, which DOES NOT contain connParams data for LAST OBJECT.
The problem occurs only when I have connection object with connParams data for the LAST OBJECT.
Works fine for below sample response:
Fails for below sample response:
Exception/StackTrace:
Then, I've downloaded the source code for jackson-databind-version2.5.0 for debugging purpose. While debugging, I found a note/comment like "Note: must handle null explicitly here; value deserializers won't" in class "com.fasterxml.jackson.databind.deser.std.ObjectArrayDeserializer.java" at line 150.
In this class method deserialize(jp, ctxt), at line number 158, I've added a null check on t (a JsonTocken) which would break the while loop.
Can we have something like a flag, which would decide whether to have this null check for deserializers or not ?
Thanks,
Shashi
The text was updated successfully, but these errors were encountered: