-
-
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
NPE when deserializing JsonAnySetter
in Throwable
#4316
Comments
Thank you for reporting this: looks like a bug in |
JsonAnySetter
in Throwable
Fix is in |
For my concrete use case, there is still a problem. I have jackson-databind/src/main/java/com/fasterxml/jackson/databind/deser/std/ThrowableDeserializer.java Lines 144 to 145 in 91ea6fe
|
Could u elaborate further what the problem is? |
Still the same NPE when calling the any setter because the thowable is not initialized. reproducer: public class Main {
@JsonIgnoreProperties({ "cause", "stackTrace", "response", "message", "localizedMessage", "suppressed" })
static class Problem extends Exception {
@JsonAnySetter
@JsonAnyGetter
Map<String, Object> additionalProperties = new HashMap<>();
}
public static void main(String[] args) throws JsonProcessingException {
Problem problem = new Problem();
problem.additionalProperties.put("additional", "additional");
String json = new ObjectMapper().writeValueAsString(problem);
System.out.println(json);
Problem result = new ObjectMapper().readValue(json, Problem.class); // throws NPE
System.out.println(result.additionalProperties);
}
} |
Seems like case No.2 that should be covered... this maybe covered by #4326 🤔 |
Search before asking
Describe the bug
When using JsonAnyGetter+JsonAnySetter on an exception class, a NPE is thrown when deserializing.
Version Information
2.16.1
Reproduction
Expected behavior
No response
Additional context
Stacktrace:
jackson-databind/src/main/java/com/fasterxml/jackson/databind/deser/std/ThrowableDeserializer.java
Line 153 in 28efa9b
Note: It's specifically related to it being a Throwable. When I remove "extends Exception" it works.
The text was updated successfully, but these errors were encountered: