[ https://issues.apache.org/jira/browse/CAMEL-11948?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16221852#comment-16221852 ]
Thomas Papke commented on CAMEL-11948: -------------------------------------- Ok i have added provided a PullRequest for this issue, please have a look at this fix. I would prefer to treat this issue as a bug and allow a backport to 2.20.1 if possible, because it prevent an upgrade from 2.19 to 2.20 for us (or would require several refactorings). Currently we are using some Services that prepare the Message like a Pojo (without the camelcontext) and some time later the message is put on the exchange ( {code:java} exchange.setIn(message) {code} ). In camel 2.19 this works, because "setIn" will perform: {code:java} org.apache.camel.impl.DefaultExchange.configureMessage(Message) {code} which add the camelcontext into the message. This "configureMessage" still exists in 2.20, so I assume it is still intended to create a "detached" message object. I am not sure if this pattern is specific to our implementation, I would assume there might be other camel users that also handle this in that way. > NPE on DefaultMessage setBody if deprecated constructor was used > ---------------------------------------------------------------- > > Key: CAMEL-11948 > URL: https://issues.apache.org/jira/browse/CAMEL-11948 > Project: Camel > Issue Type: Improvement > Components: camel-core > Affects Versions: 2.20.0 > Reporter: Thomas Papke > Assignee: Claus Ibsen > Priority: Minor > Fix For: 2.21.0 > > > After upgrade camel 2.20.0, some operations fail with a NullPointerException: > {code} > Caused by: java.lang.NullPointerException > at > org.apache.camel.impl.MessageSupport.setBody(MessageSupport.java:122) > {code} > 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: > {code} > Message message = new DefaultMessage(); > message.setBody("something"); > {code} > To remain better backward compatibility, i would suggest a nullcheck in the > setBody for cases where the CamelContext is not set. -- This message was sent by Atlassian JIRA (v6.4.14#64029)