-
Notifications
You must be signed in to change notification settings - Fork 41.5k
Description
This is a regression from spring boot 4.0.0-M3
Description
I add custom properties to my ProblemDetail errors.
With the sample code attached, on 4.0.0-M3 I get this :
{
"detail": "Simulated error",
"instance": "/hello",
"properties": {
"customProperty": "Custom Value"
},
"status": 400,
"title": "OH NOOOOO :(",
"type": null
}
expected result (from 4.0.0-M2)
{
"title": "OH NOOOOO :(",
"status": 400,
"detail": "Simulated error",
"instance": "/hello",
"customProperty": "Custom Value"
}
As you can see there is a "properties" node which should not be there
My analysis
HttpMessageConvertersAutoConfiguration creates an HttpMessageConverters instance based on :
- HttpMessageConverter from the context (additionalConverters)
- default HttpMessageConverter list
In both cases there is a JacksonJsonHttpMessageConverter, as shown here:
The first one (from additionalConverters) takes precedence, and is created by JacksonHttpMessageConvertersConfiguration. It uses the JsonMapper created in JacksonAutoConfiguration
using configuration properties (spring.jackson.* )
It doesn't add support for ProblemDetailJacksonMixin.
On the other hand, the 2nd JacksonJsonHttpMessageConverter created with default constructor adds ProblemDetailJacksonMixin
solution
Well, I'm not sure. Maybe JsonMixinModuleEntries
should add the ProblemDetailJacksonMixin if it's found in classpath ? (or handle something with @ConditionalOnClass(ProblemDetailJacksonMixin.class)
?)