[
https://issues.apache.org/jira/browse/CAMEL-26509?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Claus Ibsen resolved CAMEL-26509.
---------------------------------
Resolution: Fixed
> camel-core - TypeConversionException always reports java.lang.String as the
> from type, and ArrayTypeConverter throws on an element that does not fit the
> array
> --------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: CAMEL-26509
> URL: https://issues.apache.org/jira/browse/CAMEL-26509
> Project: Camel
> Issue Type: Bug
> Components: camel-core
> Reporter: Claus Ibsen
> Assignee: Claus Ibsen
> Priority: Minor
> Fix For: 4.24.0
>
>
> Two bugs in the type converter of camel-core, found while fixing CAMEL-26189
> (camel-jgroups-raft).
> *1. TypeConversionException reports the wrong "from type"*
> {{CoreTypeConverterRegistry.createTypeConversionException}} builds the
> exception from {{MessageHelper.extractValueForLogging(value,
> exchange.getIn())}} when there is an exchange. That value is a String (the
> body prepared for logging), so:
> * the message always says {{Error during type conversion from type:
> java.lang.String to the required type: ...}}, whatever the real type of the
> value was;
> * {{TypeConversionException.getValue()}} and {{getFromType()}} return that
> logging String and {{String.class}}, not the value and its type.
> The logging-prepared value is still right for the message text (it keeps the
> length limit and the masking of sensitive data), but the type should be the
> type of the real value, and {{getValue()}}/{{getFromType()}} should give the
> real value and type.
> *2. ArrayTypeConverter throws instead of returning no conversion*
> {{ArrayTypeConverter.convertTo}} fills the target array with {{Array.set}}
> (from a Collection, and from another array). When an element does not fit the
> component type of the target array (for example a String element converted to
> {{int[]}}), {{Array.set}} throws {{IllegalArgumentException}} and the
> conversion fails, instead of returning {{null}} (no conversion) so that
> another converter can try, or the caller gets the normal "no type converter"
> outcome.
> Both need tests in camel-core.
> _Claude Code on behalf of Claus Ibsen (davsclaus)_
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)