GitHub user Thopap opened a pull request:

    https://github.com/apache/camel/pull/2064

    CAMEL-11948  NPE on DefaultMessage setBody if deprecated constructor was 
used

    After upgrade camel 2.20.0, some operations fail with a 
NullPointerException:
    
    ```
    Caused by: java.lang.NullPointerException
            at 
org.apache.camel.impl.MessageSupport.setBody(MessageSupport.java:122)
    ```
    
    The issue seems to be introduced with the change CAMEL-11380.
    
    The issue could be easily reproduced by using the deprecated constructor, 
where no camelContext is set:
    
    ```
            Message message = new DefaultMessage();
            message.setBody("something");
    ```
    
    To remain better backward compatibility, i would suggest a nullcheck in the 
setBody for cases where the CamelContext is not set.


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/Thopap/camel master

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/camel/pull/2064.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #2064
    
----
commit 14baabbfaeb6edf53080b27c7984135d7af453d6
Author: Thomas Papke <thomas.pa...@icw.de>
Date:   2017-10-26T15:31:56Z

    CAMEL-11948 NPE on DefaultMessage setBody if deprecated constructor was
    used

commit 4701576cc2f140b829726a1ad529e82090f1e4ee
Author: Thomas Papke <thomas.pa...@icw.de>
Date:   2017-10-27T07:02:25Z

    CAMEL-11948 NPE on DefaultMessage setBody if deprecated constructor was
    used
    * Adding test

----


---

Reply via email to