Avoid NPE when setting null address

Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/f09ee40b
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/f09ee40b
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/f09ee40b

Branch: refs/heads/master
Commit: f09ee40b538ec739b745cb9678131cf706fb1f08
Parents: 9c40a51
Author: Justin Bertram <jbert...@apache.org>
Authored: Fri Feb 2 16:05:20 2018 -0600
Committer: Michael Pearce <michael.andre.pea...@me.com>
Committed: Tue Feb 6 03:16:53 2018 +0000

----------------------------------------------------------------------
 .../apache/activemq/artemis/core/message/impl/CoreMessage.java | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/f09ee40b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/message/impl/CoreMessage.java
----------------------------------------------------------------------
diff --git 
a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/message/impl/CoreMessage.java
 
b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/message/impl/CoreMessage.java
index 888b785..0fb7c3e 100644
--- 
a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/message/impl/CoreMessage.java
+++ 
b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/message/impl/CoreMessage.java
@@ -437,7 +437,11 @@ public class CoreMessage extends RefCountMessage 
implements ICoreMessage {
 
    @Override
    public CoreMessage setAddress(SimpleString address) {
-      if (validBuffer && !address.equals(this.address)) {
+      if (address == null && this.address == null) {
+         // no-op so just return
+         return this;
+      }
+      if (validBuffer && (address == null || !address.equals(this.address))) {
          messageChanged();
       }
       this.address = address;

Reply via email to