Repository navigation
Revisit converters and codecs default setup in HTTP stacks #33894
Description
Activity
- addedin: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancementA general enhancement
on Nov 15, 2024 - changed the title
[-]Consider reordering converters and codecs in HTTP stacks [/-][+]Consider revisiting converters and codecs default setup in HTTP stacks [/+]on Apr 2, 2025 - added a commit that references this issue
on Jun 26, 2025 - added a commit that references this issue
on Jun 26, 2025 1 remaining item
- added a commit that references this issue
on Jun 27, 2025 - added a commit that references this issue
on Jun 27, 2025 - added 2 commits that reference this issue
on Jul 11, 2025 - changed the title
[-]Consider revisiting converters and codecs default setup in HTTP stacks [/-][+]Revisit converters and codecs default setup in HTTP stacks [/+]on Jul 17, 2025 How can I fix this behavior? Right now, RestTemplate uses XML by default, and the same happens with @ControllerAdvice.
@Ixiodor I don't understand. Can you elaborate? Did you upgrade an application to a 7.0 milestone and see a behavior change? Maybe you can share a minimal sample application that demonstrates one behavior with 6.x and another with 7.0?
Hi,
I'm on:<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>3.5.3</version> <relativePath/> </parent>When I check the registered message converters, I see:
org.springframework.http.converter.ByteArrayHttpMessageConverter
org.springframework.http.converter.StringHttpMessageConverter
org.springframework.http.converter.ResourceHttpMessageConverter
org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter
org.springframework.http.converter.xml.MappingJackson2XmlHttpMessageConverter
org.springframework.http.converter.json.MappingJackson2HttpMessageConverterBecause the XML converter is listed before JSON, the default behavior ends up preferring XML over JSON when the request does not explicitly specify an Accept header.
This causes some unexpected behavior, for example:
- Default error pages are returned in XML
- @ControllerAdvice responses are serialized as XML
- RestTemplate post uses XML instead of JSON by default
(Coming from 3.2.2)
@Ixiodor In this case it's completely unrelated to this issue. You can ask this question on StackOverflow and share here the link, I will have a look.
@Ixiodor In this case it's completely unrelated to this issue. You can ask this question on StackOverflow and share here the link, I will have a look.
https://stackoverflow.com/questions/79762083/spring-changed-converters-order-prefering-xml Thanks
The order of codecs has been the same for a very long time and applications might rely on it.
On the other hand, Spring Boot has been consistently reordering converters and codecs to align with industry trends. For example, reordering XML last in favor of JSON and other converters.
Unfortunately, this creates a disconnect between the order as declared in the application context and what Spring Boot applies in practice. This also causes inconsistencies like spring-projects/spring-boot#43143.
We should consider a change here, as long as there is minimal disruption for Framework and Boot developers.