Skip to content

MultipartHttpMessageWriter in WebClient doesn't use custom Jackson Encoder since 5.3.3 #27017

@flozano

Description

@flozano

Before v5.3.3, when configuring a custom jackson object mapper in WebClient with:

			ObjectMapper mapper = instantiateAndConfigureMyCustomObjectMapper();
			WebClient client = WebClient.builder().clientConnector(clientConnector)
					// ...
					.exchangeStrategies(ExchangeStrategies.builder().codecs(configurer -> {
						configurer.defaultCodecs().jackson2JsonDecoder(new Jackson2JsonDecoder(mapper,
								MediaType.APPLICATION_JSON, new MediaType("application", "*+json")));
						configurer.defaultCodecs().jackson2JsonEncoder(new Jackson2JsonEncoder(mapper,
								MediaType.APPLICATION_JSON, new MediaType("application", "*+json")));
					}).build())
					// ...
					 .build();

when multipart message is being encoded and contains a part with an object subject to be encoded by jackson, the custom mapper was used.

From v5.3.3 onwards, an empty default unconfigured ObjectMapper is used instead, causing several regressions to existing code that expects JSON configuration to be followed.

Most likely changes in spring-web/src/main/java/org/springframework/http/codec/support/BaseDefaultCodecs.java are related to this, as it seems now initialization of readers and writer is done eagerly just once instead of on-demand

#26263
e138509

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: regressionA bug that is also a regression

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions