I have a custom MappingJackson2HttpMessageConverter
that I add to the top of the converters list:
@Override
public void extendMessageConverters(final List<HttpMessageConverter<?>> converters) {
converters.add(0, customJacksonMessageConverter());
}
However, there are times when I need to skip over this and use the Spring default MappingJackson2HttpMessageConverter
, like when I want to update the logging level of my application through Spring Boot Admin. In my custom converter, I have overridden both canRead()
and canWrite()
with an added debug log line to see what the value returned is, and I can see they both return false
when I need to skip over. However, parsing using the default fails. If I remove my custom converter from the list, then the default does work.
My list of converters looks like this:
com.meanwhile.in.hell.converters.json.CustomJacksonMessageConverter
org.springframework.http.converter.ByteArrayHttpMessageConverter
org.springframework.http.converter.StringHttpMessageConverter
org.springframework.http.converter.StringHttpMessageConverter
org.springframework.http.converter.ResourceHttpMessageConverter
org.springframework.http.converter.ResourceRegionHttpMessageConverter
org.springframework.http.converter.xml.SourceHttpMessageConverter
org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter
org.springframework.http.converter.json.MappingJackson2HttpMessageConverter
org.springframework.http.converter.json.MappingJackson2HttpMessageConverter
org.springframework.http.converter.xml.MappingJackson2XmlHttpMessageConverter
org.springframework.http.converter.xml.MappingJackson2XmlHttpMessageConverter
I don't see why if my custom converter returns false
for canRead()
and canWrite()
, that it doesn't just skip over this and continue down the list of converters until it gets to the default Spring JSON converter.