Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-14267

Conversion fails with NullPointerException when the body is null at the end of a route and an outputType is set

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.24.2
    • 2.24.3, 3.0.1, 2.25.0, 3.1.0
    • camel-core
    • None
    • Novice

    Description

      NullPointerException thrown if the body is null at the end of a route and an outputType is set.

      Sample code:

      from("timer:foo?repeatCount=1")
         .setBody().constant("42")
         .to("direct:sub");
      from("direct:sub")
         .inputType(String.class)
         .outputType(Integer.class)
         .setBody().constant(null);
      

      Thrown exception:

      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]

       

      Attachments

        1. test-npe.zip
          4 kB
          Fabien Taysse

        Activity

          People

            Unassigned Unassigned
            ftaysse Fabien Taysse
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 40m
                40m