Skip to content

XmlMapper behaviours defined in rest client builder message converters are not considered in serialisation -- spring-boot-starter-parent 3.4.4 and 3.4.5 #34853

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

Closed
MianoKariuki opened this issue May 4, 2025 · 2 comments
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) status: invalid An issue that we don't feel is valid

Comments

@MianoKariuki
Copy link

I have observed, that since the release of spring-boot-starter-parent version 3.4.4, that the XmlMapper behaviours defined for rest client builder message converter, are not being used in serialisation. PFA, report and sample project on the matter

Bug report.pdf

report-spring-rest-client-issue.zip

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label May 4, 2025
@bclozel
Copy link
Member

bclozel commented May 5, 2025

This is due to a Spring Framework bug fix in #34439.
Previously, the XML HTTP converter was not registered automatically for RestClient instances, and it the case as of 6.2.4.

Now this is causing an issue with your application because you were relying on the fact that there was no message converter present for processing XML HTTP messages and that your custom converter (added last) would be used for this. This is not the case anymore as the automatically registered. one takes precedence now.

You can fix your application by removing the default one and replacing it with your custom converter.

var restClient = RestClient.builder()
					.baseUrl("http://localhost:8080/")
					.messageConverters(converters -> {
						converters.removeIf(converter -> converter instanceof MappingJackson2XmlHttpMessageConverter);
						converters.add(new MappingJackson2XmlHttpMessageConverter(mapper));
					})

I'm closing this issue as the change was done in Framework and I don't think we should roll back this change.

Thanks for the report!

@bclozel bclozel closed this as not planned Won't fix, can't repro, duplicate, stale May 5, 2025
@bclozel bclozel added status: invalid An issue that we don't feel is valid for: external-project Needs a fix in external project and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels May 5, 2025
@bclozel bclozel transferred this issue from spring-projects/spring-boot May 5, 2025
@bclozel bclozel added in: web Issues in web modules (web, webmvc, webflux, websocket) and removed for: external-project Needs a fix in external project labels May 5, 2025
@MianoKariuki
Copy link
Author

This is due to a Spring Framework bug fix in #34439. Previously, the XML HTTP converter was not registered automatically for RestClient instances, and it the case as of 6.2.4.

Now this is causing an issue with your application because you were relying on the fact that there was no message converter present for processing XML HTTP messages and that your custom converter (added last) would be used for this. This is not the case anymore as the automatically registered. one takes precedence now.

You can fix your application by removing the default one and replacing it with your custom converter.

var restClient = RestClient.builder()
.baseUrl("http://localhost:8080/")
.messageConverters(converters -> {
converters.removeIf(converter -> converter instanceof MappingJackson2XmlHttpMessageConverter);
converters.add(new MappingJackson2XmlHttpMessageConverter(mapper));
})
I'm closing this issue as the change was done in Framework and I don't think we should roll back this change.

Thanks for the report!

Thank you. This has been both insightful and instructful in resolving the encountered issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) status: invalid An issue that we don't feel is valid
Projects
None yet
Development

No branches or pull requests

3 participants