[jira] [Commented] (CAMEL-11948) NPE on DefaultMessage setBody if deprecated constructor was used

2017-10-27 Thread ASF GitHub Bot (JIRA)

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

ASF GitHub Bot commented on CAMEL-11948:


Github user davsclaus closed the pull request at:

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


> 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
>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)


[jira] [Commented] (CAMEL-11948) NPE on DefaultMessage setBody if deprecated constructor was used

2017-10-27 Thread ASF GitHub Bot (JIRA)

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

ASF GitHub Bot commented on CAMEL-11948:


davsclaus closed pull request #2064: CAMEL-11948  NPE on DefaultMessage setBody 
if deprecated constructor was used
URL: https://github.com/apache/camel/pull/2064
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/camel-core/src/main/java/org/apache/camel/impl/MessageSupport.java 
b/camel-core/src/main/java/org/apache/camel/impl/MessageSupport.java
index 4c564b89aa3..a2ae7e73a2a 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/MessageSupport.java
+++ b/camel-core/src/main/java/org/apache/camel/impl/MessageSupport.java
@@ -33,7 +33,7 @@
  * Unless a specific provider wishes to do something particularly clever with
  * headers you probably want to just derive from {@link DefaultMessage}
  *
- * @version 
+ * @version
  */
 public abstract class MessageSupport implements Message, CamelContextAware, 
DataTypeAware {
 private CamelContext camelContext;
@@ -48,6 +48,7 @@ public String toString() {
 return String.format("Message[%s]", messageId == null ? "" : 
messageId);
 }
 
+@Override
 public Object getBody() {
 if (body == null) {
 body = createBody();
@@ -55,10 +56,12 @@ public Object getBody() {
 return body;
 }
 
+@Override
 public  T getBody(Class type) {
 return getBody(type, getBody());
 }
 
+@Override
 public Object getMandatoryBody() throws InvalidPayloadException {
 Object answer = getBody();
 if (answer == null) {
@@ -97,6 +100,7 @@ public Object getMandatoryBody() throws 
InvalidPayloadException {
 return null;
 }
 
+@Override
 public  T getMandatoryBody(Class type) throws 
InvalidPayloadException {
 // eager same instance type test to avoid the overhead of invoking the 
type converter
 // if already same type
@@ -116,14 +120,16 @@ public Object getMandatoryBody() throws 
InvalidPayloadException {
 throw new InvalidPayloadException(e, type, this);
 }
 
+@Override
 public void setBody(Object body) {
 this.body = body;
 // set data type if in use
-if (body != null && camelContext.isUseDataType()) {
+if (body != null && camelContext != null && 
camelContext.isUseDataType()) {
 this.dataType = new DataType(body.getClass());
 }
 }
 
+@Override
 public  void setBody(Object value, Class type) {
 Exchange e = getExchange();
 if (e != null) {
@@ -156,6 +162,7 @@ public boolean hasDataType() {
 return dataType != null;
 }
 
+@Override
 public Message copy() {
 Message answer = newInstance();
 // must copy over CamelContext
@@ -166,6 +173,7 @@ public Message copy() {
 return answer;
 }
 
+@Override
 public void copyFrom(Message that) {
 if (that == this) {
 // the same instance so do not need to copy
@@ -183,6 +191,7 @@ public void copyFrom(Message that) {
 copyFromWithNewBody(that, that.getBody());
 }
 
+@Override
 public void copyFromWithNewBody(Message that, Object newBody) {
 if (that == this) {
 // the same instance so do not need to copy
@@ -219,6 +228,7 @@ public void copyFromWithNewBody(Message that, Object 
newBody) {
 copyAttachments(that);
 }
 
+@Override
 public Exchange getExchange() {
 return exchange;
 }
@@ -227,14 +237,17 @@ public void setExchange(Exchange exchange) {
 this.exchange = exchange;
 }
 
+@Override
 public CamelContext getCamelContext() {
 return camelContext;
 }
 
+@Override
 public void setCamelContext(CamelContext camelContext) {
 this.camelContext = camelContext;
 }
 
+@Override
 public void copyAttachments(Message that) {
 // the attachments may be the same instance if the end user has made 
some mistake
 // and set the OUT message with the same attachment instance of the IN 
message etc
@@ -270,6 +283,7 @@ protected Object createBody() {
 return null;
 }
 
+@Override
 public String getMessageId() {
 if (messageId == null) {
 messageId = createMessageId();
@@ -277,6 +291,7 @@ public String getMessageId() {
 return this.messageId;
 }
 
+@Override
 public void setMessageId(String messageId) {
 this.messageId = messageId;
 }
diff --git 
a/camel-core/src/test/java/org/apache/camel/impl/DefaultMessageTest.java 

[jira] [Commented] (CAMEL-11948) NPE on DefaultMessage setBody if deprecated constructor was used

2017-10-27 Thread ASF GitHub Bot (JIRA)

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

ASF GitHub Bot commented on CAMEL-11948:


Thopap opened a new pull request #2064: CAMEL-11948  NPE on DefaultMessage 
setBody if deprecated constructor was used
URL: https://github.com/apache/camel/pull/2064
 
 
   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.
   


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> 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
>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)


[jira] [Commented] (CAMEL-11948) NPE on DefaultMessage setBody if deprecated constructor was used

2017-10-27 Thread ASF GitHub Bot (JIRA)

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

ASF GitHub Bot commented on CAMEL-11948:


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 
Date:   2017-10-26T15:31:56Z

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

commit 4701576cc2f140b829726a1ad529e82090f1e4ee
Author: Thomas Papke 
Date:   2017-10-27T07:02:25Z

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




> 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
>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)


[jira] [Commented] (CAMEL-11948) NPE on DefaultMessage setBody if deprecated constructor was used

2017-10-26 Thread Claus Ibsen (JIRA)

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

Claus Ibsen commented on CAMEL-11948:
-

You are welcome to work on a github PR

> 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
>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)