-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Description
Is your feature request related to a problem? Please describe.
See #5451
Describe the solution you'd like
I'd like to be able to configure a JsonMapper with a DeserializationProblemHandler that would allow me to log when a null has been met where a primitive is required.
The new method of the DeserializationProblemHandler would allow me to log (either through separate arguments of the method, or with a ready to log message)
- which type is expected (example:
double) - at which location (example:
com.foo.bar.Coordinates#latitude)
Usage example
var mapper = JsonMapper.builder().addHandler(new DeserializationProblemHandler() {
@Override
public void handleNullForPrimitive(String message) {
logger.warn("This problem should be handled before turning FAIL_ON_NULL_FOR_PRIMITIVES: " + message);
}
}).build();
And if a null is found for a primitive, that would thus log something like
This problem should be handled before turning FAIL_ON_NULL_FOR_PRIMITIVES: Met null for primitive of type `int` in com.foo.bar.Coordinates#latitude
The logger could create a log an exception to have the stack trace allowing to have more context (i.e. where the deserialization happened).
Additional context
No response