Alan Foster created CAMEL-7305:
----------------------------------

             Summary: 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 - 

{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