-
Notifications
You must be signed in to change notification settings - Fork 40.1k
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
Mutate existing default HttpMessageConverter instead of adding duplication #27319
Comments
Duplicate of #21374 and the various other issues to which it links. |
@wilkinsona I know it's intentional, but you are not considering other |
Because it is intentional that there are multiple converters with different configurations. They may, for example, support different media types. I'm just repeating here what's already been said in #21374 and the issues to which it links. Please take the time to read those other issues in full. |
I didn't find anything related to other |
In what way do you believe that the Smile, CBOR, and XML converters need to be considered? |
Spring MVC add 4 default @Bean
@ConditionalOnMissingBean(value = MappingJackson2CborHttpMessageConverter.class)
// other conditions
MappingJackson2CborHttpMessageConverter mappingJackson2CborHttpMessageConverter(ObjectMapper objectMapper) {
return new MappingJackson2CborHttpMessageConverter(objectMapper);
} |
That's not the case. Spring Boot's auto-configured |
I took some time to check boot flavored according to Lines 129 to 136 in 47516b5
I suggest add some logic like this: private boolean isDuplication(HttpMessageConverter<?> defaultConverter, HttpMessageConverter<?> candidate) {
if (defaultConverter.getClass() != candidate.getClass()) {
return false;
}
// SAFE_REPLACING_CONVERTERS: [StringHttpMessageConverter, MappingJackson2HttpMessageConverter]
return SAFE_REPLACING_CONVERTERS.contains(candidate.getClass());
} |
As described in the javadoc of
Your proposal above suggests that it's safe for one If you have a specific real-world problem that this behaviour is causing then please let us know. Otherwise, your concern appears to be purely theoretical and isn't sufficient reason to increase the complexity of |
I found Spring Boot add two flavored HttpMessageConverters to default messageConverters
spring-boot/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/http/JacksonHttpMessageConvertersConfiguration.java
Lines 47 to 54 in 47516b5
spring-boot/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/http/HttpMessageConvertersAutoConfiguration.java
Lines 77 to 84 in 47516b5
Here is combined converters by
HttpMessageConverters
there are two cons:
AbstractJackson2HttpMessageConverter
s such asMappingJackson2CborHttpMessageConverter
andMappingJackson2SmileHttpMessageConverter
are not consideredThe text was updated successfully, but these errors were encountered: