You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@activemq.apache.org by jbertram <gi...@git.apache.org> on 2018/02/02 22:05:49 UTC

[GitHub] activemq-artemis pull request #1846: Avoid NPE when setting null address

GitHub user jbertram opened a pull request:

    https://github.com/apache/activemq-artemis/pull/1846

    Avoid NPE when setting null address

    

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

    $ git pull https://github.com/jbertram/activemq-artemis master_work

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

    https://github.com/apache/activemq-artemis/pull/1846.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 #1846
    
----
commit fc3ca2d0db90bda3d1a9d16d92eea9dbe8a2d852
Author: Justin Bertram <jb...@...>
Date:   2018-02-02T22:05:20Z

    Avoid NPE when setting null address

----


---

[GitHub] activemq-artemis pull request #1846: Avoid NPE when setting null address

Posted by michaelandrepearce <gi...@git.apache.org>.
Github user michaelandrepearce commented on a diff in the pull request:

    https://github.com/apache/activemq-artemis/pull/1846#discussion_r165901274
  
    --- Diff: artemis-core-client/src/main/java/org/apache/activemq/artemis/core/message/impl/CoreMessage.java ---
    @@ -437,7 +437,11 @@ public CoreMessage setMessageID(long messageID) {
     
        @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 && this.address != null) || !address.equals(this.address))) {
    --- End diff --
    
    Can be simplified as:  if (validBuffer && (address == null || !address.equals(this.address))) 


---

[GitHub] activemq-artemis pull request #1846: Avoid NPE when setting null address

Posted by jbertram <gi...@git.apache.org>.
Github user jbertram commented on a diff in the pull request:

    https://github.com/apache/activemq-artemis/pull/1846#discussion_r166100953
  
    --- Diff: artemis-core-client/src/main/java/org/apache/activemq/artemis/core/message/impl/CoreMessage.java ---
    @@ -437,7 +437,11 @@ public CoreMessage setMessageID(long messageID) {
     
        @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 && this.address != null) || !address.equals(this.address))) {
    --- End diff --
    
    Nice catch.  Should be fixed now.


---

[GitHub] activemq-artemis pull request #1846: Avoid NPE when setting null address

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/activemq-artemis/pull/1846


---

[GitHub] activemq-artemis pull request #1846: Avoid NPE when setting null address

Posted by michaelandrepearce <gi...@git.apache.org>.
Github user michaelandrepearce commented on a diff in the pull request:

    https://github.com/apache/activemq-artemis/pull/1846#discussion_r165900914
  
    --- Diff: artemis-core-client/src/main/java/org/apache/activemq/artemis/core/message/impl/CoreMessage.java ---
    @@ -437,7 +437,11 @@ public CoreMessage setMessageID(long messageID) {
     
        @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 && this.address != null) || !address.equals(this.address))) {
    --- End diff --
    
    When you're here, if address is null, you already know this.address is not null, due to the preceding check.


---