Skip to content
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

Duplicate HttpMessageConverter #21374

Closed
brucelwl opened this issue May 9, 2020 · 5 comments
Closed

Duplicate HttpMessageConverter #21374

brucelwl opened this issue May 9, 2020 · 5 comments
Labels
status: duplicate A duplicate of another issue

Comments

@brucelwl
Copy link

brucelwl commented May 9, 2020

Duplicate StringHttpMessageConverter
Duplicate MappingJackson2HttpMessageConverter

image

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label May 9, 2020
@bclozel bclozel added status: duplicate A duplicate of another issue and removed status: waiting-for-triage An issue we've not yet triaged labels May 9, 2020
@bclozel
Copy link
Member

bclozel commented May 9, 2020

Hi @brucelwl

This behavior is intentional and is documented. See #1293, #2444, #20235 and #15027 for more information on that (and duplicate issues in some cases).

The bottom line is: they're not really duplicate because they might not have the same configuration and one or the other might be used depending on the case.

Thanks!

@bclozel bclozel closed this as completed May 9, 2020
@brucelwl
Copy link
Author

But the configuration in org.springframework.http.converter.json.MappingJackson2HttpMessageConverter is exactly the same

image

@bclozel
Copy link
Member

bclozel commented May 24, 2020

@brucelwl the ObjectMapper instances aren't the same. See #1293 as mentioned in my previous comment.

@brucelwl
Copy link
Author

@bclozel I have roughly understood what you mean, but what should I do if I don't want to use the default converter? I think we should replace the converter instead of appending the converter before the default to avoid creating redundant objects. The media types to be supported can be customized by developers

In terms of StringHttpMessageConverter, it is difficult to use the second object because their judgment conditions are the same,

@hassanrehman01398
Copy link

hassanrehman01398 commented Feb 23, 2024

@bclozel @brucelwl
I have the same question. I have two MappingJackson Convertor of same data type. The modules registered in the first convertor are 5 and in the other one are 2. When I am calling my rest template, the second convertor is been called resulting in error.

Failed to evaluate Jackson deserialization for type
com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Invalid type definition for type
Argument #0 of constructor com.fasterxml.jackson.annotation.JsonCreator=@com.fasterxml.jackson.annotation.JsonCreator(mode=DEFAULT)}
has no property name (and is not Injectable): can not use as property-based Creator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: duplicate A duplicate of another issue
Projects
None yet
Development

No branches or pull requests

4 participants