-
-
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
Impossible to deserialize custom Throwable
sub-classes that do not have single-String constructors
#4071
Comments
It seems what the commit f27df63 tried to solve in #3497 did not intend change of behavior decribed here. Though it needs review by @cowtowncoder, #4072 might solve the problem. |
Thanks for this fix. I think it was not the intention but the removed lines have seemed unnecessary as it would have to be assumed by the ThrowableDeserializer. For some reasons, I have the same problem on some other custom exceptions with the property "suppressed" (the getter is "getSuppressed" but the fied is "suppressedExceptions" and it was also ignored by the removed code in f27df63) |
Np! Also, I only made a "possible" fix :)) I still probably need more time to figure out Jackson's behavior on
@Pass-Kal Could you also share the example case here? What is also possible is that #4072 will either
|
I merged #4072, which should handle |
Throwable
sub-classes that do not have single-String constructors
Search before asking
Describe the bug
An UnrecognizedPropertyException is thrown on fields "message" and/or "suppressed" while deserializing a custom exception.
(since correction #3497)
Workaround : adding ".configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)" (but with operationnal impact)
Version Information
2.14+
Reproduction
public class CustomException extends Exception{
public CustomException (){
super();
}
}
String json = JsonMapper.builder().build().writeValueAsString(new CustomException());
JsonMapper.builder().build().readValue(json, CustomException.class);
==> UnrecognizedPropertyException
Expected behavior
Deserialization is possible without disabling FAIL_ON_UNKNOWN_PROPERTIES
Additional context
Since f27df63
with the removal of "builder.addIgnorable("localizedMessage");" and "builder.addIgnorable("suppressed");" In class [BeanDeserializerFactory.java] (line 452 and line 454)
The text was updated successfully, but these errors were encountered: