Skip to content

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

Closed
@kelseyh

Description

@kelseyh

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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions