[ 
https://issues.apache.org/jira/browse/CAMEL-7305?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13938881#comment-13938881
 ] 

Claus Ibsen commented on CAMEL-7305:
------------------------------------

This is resolved with CAMEL-7298 which enforces using predicate when the result 
type is boolean, and therefore the value is either true or false.

> Simple Language - ResultType Coercion is not consistent
> -------------------------------------------------------
>
>                 Key: CAMEL-7305
>                 URL: https://issues.apache.org/jira/browse/CAMEL-7305
>             Project: Camel
>          Issue Type: Bug
>    Affects Versions: 2.12.3
>            Reporter: Alan Foster
>
> Both of the following code snippets lead to unexpected results when setting a 
> resultType to be a boolean/integer
> {code:title=Scenario - Handling POJO}
>     <camelContext trace="false" 
> xmlns="http://camel.apache.org/schema/blueprint";>
>         <route>
>             <from uri="direct:entry"/>
>             <!-- Return any kind of POJO -->
>             <bean ref="complexModelFactory" method="createComplexModel" />
>             <setBody>
>                 <simple resultType="java.lang.Boolean">${body}</simple>
>             </setBody>
>             <log message="The body is currently :: '${body}'" />
>         </route>
>     </camelContext>
> {code}
> {code:title=Scenario - Handling missing header}
>     <camelContext trace="false" 
> xmlns="http://camel.apache.org/schema/blueprint";>
>         <route>
>             <from uri="direct:entry"/>
>             <setBody>
>                 <simple 
> resultType="java.lang.Boolean">${headers.missing}</simple>
>             </setBody>
>             <log message="The body is currently :: '${body}'" />
>         </route>
>     </camelContext>
> {code}
> The log for both of these scenarios is -
> {code}[                          main] route1                         INFO  
> The body is currently :: ''{code}
> It might be expected that the resulting body would either be true or false.
> I am not sure if the below behaviour is as expected either - as they are 
> similiar scenarios, but with different outcomes.
> {code}
>             <!-- No error - but header is not an integer -->
>             <setBody>
>                 <simple 
> resultType="java.lang.Integer">${headers.missing}</simple>
>             </setBody>
>            <!-- Causes java.lang.NumberFormatException: For input string: "" 
> -->
>             <setBody>
>                 <simple resultType="java.lang.Integer"></simple>
>             </setBody>
> {code}



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to