You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Nikhil Vibhav (Jira)" <ji...@apache.org> on 2019/12/07 20:27:01 UTC

[jira] [Commented] (CAMEL-14267) Conversion fails with NullPointerException when the body is null at the end of a route and an outputType is set

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

Nikhil Vibhav commented on CAMEL-14267:
---------------------------------------

[~ftaysse] I tried this out locally using Camel 2.24.2, but didn't face this issue. 
{code:java}
from("timer://foo?repeatCount=1")
    .setBody().constant("42")
    .to("direct:processFoo");

from("direct:processFoo")
    .inputType(String.class)
    .outputType(Integer.class)
    .process(exchange -> {
        System.out.println(exchange.getIn().getBody());
    })
    .setBody().constant(null)
    .process(exchange -> {
        System.out.println(exchange.getIn().getBody());
    }); {code}

Getting the output as expected and no exceptions are thrown.
{code}42
null

Process finished with exit code 130 (interrupted by signal 2: SIGINT)
{code}

> Conversion fails with NullPointerException when  the body is null at the end of a route and an outputType is set
> ----------------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-14267
>                 URL: https://issues.apache.org/jira/browse/CAMEL-14267
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-core
>    Affects Versions: 2.24.2
>            Reporter: Fabien Taysse
>            Priority: Major
>             Fix For: 2.24.3, 3.0.1, 2.25.0, 3.1.0
>
>
> NullPointerException thrown if the body is null at the end of a route and an outputType is set.
> Sample code:
> {code:java}
> from("timer:foo?repeatCount=1")
>    .setBody().constant("42")
>    .to("direct:sub");
> from("direct:sub")
>    .inputType(String.class)
>    .outputType(Integer.class)
>    .setBody().constant(null);
> {code}
> {{Thrown exception:}}
> {code:java}
> java.lang.NullPointerException: nulljava.lang.NullPointerException: null at org.apache.camel.processor.ContractAdvice.convertIfRequired(ContractAdvice.java:149) ~[camel-core-2.24.2.jar:2.24.2] at org.apache.camel.processor.ContractAdvice.doTransform(ContractAdvice.java:124) ~[camel-core-2.24.2.jar:2.24.2] at org.apache.camel.processor.ContractAdvice.after(ContractAdvice.java:103) ~[camel-core-2.24.2.jar:2.24.2] at org.apache.camel.processor.CamelInternalProcessor$InternalCallback.done(CamelInternalProcessor.java:251) ~[camel-core-2.24.2.jar:2.24.2] at org.apache.camel.processor.CamelInternalProcessor$InternalCallback.done(CamelInternalProcessor.java:262) ~[camel-core-2.24.2.jar:2.24.2] at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:579) ~[camel-core-2.24.2.jar:2.24.2] at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201) [camel-core-2.24.2.jar:2.24.2] at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201) [camel-core-2.24.2.jar:2.24.2] at org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:76) ~[camel-core-2.24.2.jar:2.24.2] at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:148) ~[camel-core-2.24.2.jar:2.24.2] at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:548) ~[camel-core-2.24.2.jar:2.24.2] at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201) [camel-core-2.24.2.jar:2.24.2] at org.apache.camel.processor.Pipeline.process(Pipeline.java:138) ~[camel-core-2.24.2.jar:2.24.2] at org.apache.camel.processor.Pipeline.process(Pipeline.java:101) ~[camel-core-2.24.2.jar:2.24.2] at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201) [camel-core-2.24.2.jar:2.24.2] at org.apache.camel.component.timer.TimerConsumer.sendTimerExchange(TimerConsumer.java:197) [camel-core-2.24.2.jar:2.24.2] at org.apache.camel.component.timer.TimerConsumer$1.run(TimerConsumer.java:79) [camel-core-2.24.2.jar:2.24.2] at java.util.TimerThread.mainLoop(Timer.java:555) [na:1.8.0_66] at java.util.TimerThread.run(Timer.java:505) [na:1.8.0_66]{code}
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)