/**
* Override the default Jackson 3.x JSON {@code HttpMessageConverter}
* with any converter supporting the JSON format.
* @param jsonMessageConverter the converter instance to use
* @see org.springframework.http.converter.json.JacksonJsonHttpMessageConverter
*/
T withJsonConverter(HttpMessageConverter<?> jsonMessageConverter);
I initially looked only at the Javadoc and assumed that overriding the JSON converter would register it unconditionally. After checking the implementation, I found that this is not the case: when registerDefaults() is not enabled, withJsonConverter(...) and similar methods are ignored and no converter is registered.
@Bean
fun groupConfigurer(objectMapper: JsonMapper): RestClientHttpServiceGroupConfigurer =
RestClientHttpServiceGroupConfigurer { groups ->
groups.forEachClient { _, builder ->
builder
.configureMessageConverters {
it.withJsonConverter(JacksonJsonHttpMessageConverter(objectMapper))
}
}
}
In this example, the order looks valid at a glance, but the specific converter registration only takes effect if registerDefaults() has already been enabled.
This matches the concern raised in the discussion on issue #35704, where it was
noted that the Javadoc should explicitly state that these format-specific converter
methods are intended to customize default registrations, and are ignored when default
registrations are turned off. That clarification does not appear to be reflected in
the current Javadoc yet.
It would be helpful to update the Javadoc to explicitly document this behavior,
so that users are not misled into expecting unconditional registration.
I initially looked only at the Javadoc and assumed that overriding the JSON converter would register it unconditionally. After checking the implementation, I found that this is not the case: when registerDefaults() is not enabled, withJsonConverter(...) and similar methods are ignored and no converter is registered.
In this example, the order looks valid at a glance, but the specific converter registration only takes effect if registerDefaults() has already been enabled.
This matches the concern raised in the discussion on issue #35704, where it was
noted that the Javadoc should explicitly state that these format-specific converter
methods are intended to customize default registrations, and are ignored when default
registrations are turned off. That clarification does not appear to be reflected in
the current Javadoc yet.
It would be helpful to update the Javadoc to explicitly document this behavior,
so that users are not misled into expecting unconditional registration.