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

SmartCompositeMessageConverter incorrectly tries next converter when a conversion exception is thrown #1234

Open
kelseyh opened this issue Feb 4, 2025 · 0 comments

Comments

@kelseyh
Copy link

kelseyh commented Feb 4, 2025

As a result of #1168 the following fix 6dee668 was created. Unfortunately, this is not ideal, with the current "fix" all the remaining converters are tried before giving up.

Given the MessageConverter#fromMessage contract which states, "If the converter does not support the specified media type or cannot perform the conversion, it should return null". I believe the current "fix" leads to undesired/unexpected behaviour, given the contract one would expect conversion exceptions to be handled by implementations should they wish to be lenient and defer to the next converter.

I think it would be more useful if the MessageConverterHelper#this.failConversionIfNecessary was called in the exception handler block rather than after all the converters have been exhausted. The reason for this being that we do NOT want to try any additional converters as this may lead to unexpected behaviour. We have a custom application/json converter and do NOT wish to try the default jsonMapper based application/json converter when there's a json deserialisation problem as this then also throws a json processing exception, this is wasteful and unwanted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant