You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@activemq.apache.org by GitBox <gi...@apache.org> on 2021/10/24 10:50:44 UTC

[GitHub] [activemq-artemis] nbrendah opened a new pull request #3811: ARTEMIS-2582: EmbeddedActiveMQ.stop() should check for null

nbrendah opened a new pull request #3811:
URL: https://github.com/apache/activemq-artemis/pull/3811


   PR is created to as response for https://issues.apache.org/jira/browse/ARTEMIS-2582
   
   cc @clebertsuconic 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [activemq-artemis] nbrendah commented on pull request #3811: ARTEMIS-2582: EmbeddedActiveMQ.stop() should check for null

Posted by GitBox <gi...@apache.org>.
nbrendah commented on pull request #3811:
URL: https://github.com/apache/activemq-artemis/pull/3811#issuecomment-950315758


   Why is it that my tests are passing locally and failing here?
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [activemq-artemis] nbrendah commented on a change in pull request #3811: ARTEMIS-2582: EmbeddedActiveMQ.stop() should check for null

Posted by GitBox <gi...@apache.org>.
nbrendah commented on a change in pull request #3811:
URL: https://github.com/apache/activemq-artemis/pull/3811#discussion_r736052471



##########
File path: artemis-server/src/main/java/org/apache/activemq/artemis/core/server/embedded/EmbeddedActiveMQ.java
##########
@@ -139,7 +139,9 @@ protected void initStart() throws Exception {
    }
 
    public EmbeddedActiveMQ stop() throws Exception {
-      activeMQServer.stop();
+      if (activeMQServer != null) {
+         activeMQServer.stop();
+      }
       return this;

Review comment:
       Thanks @jbertram for the great explanation.   I think this is good as is.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [activemq-artemis] jbertram commented on pull request #3811: ARTEMIS-2582: EmbeddedActiveMQ.stop() should check for null

Posted by GitBox <gi...@apache.org>.
jbertram commented on pull request #3811:
URL: https://github.com/apache/activemq-artemis/pull/3811#issuecomment-1031557184


   I added a test during merge. Thanks, @nbrendah!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [activemq-artemis] asfgit closed pull request #3811: ARTEMIS-2582: EmbeddedActiveMQ.stop() should check for null

Posted by GitBox <gi...@apache.org>.
asfgit closed pull request #3811:
URL: https://github.com/apache/activemq-artemis/pull/3811


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [activemq-artemis] nbrendah commented on a change in pull request #3811: ARTEMIS-2582: EmbeddedActiveMQ.stop() should check for null

Posted by GitBox <gi...@apache.org>.
nbrendah commented on a change in pull request #3811:
URL: https://github.com/apache/activemq-artemis/pull/3811#discussion_r735153565



##########
File path: artemis-server/src/main/java/org/apache/activemq/artemis/core/server/embedded/EmbeddedActiveMQ.java
##########
@@ -139,7 +139,9 @@ protected void initStart() throws Exception {
    }
 
    public EmbeddedActiveMQ stop() throws Exception {
-      activeMQServer.stop();
+      if (activeMQServer != null) {
+         activeMQServer.stop();
+      }
       return this;

Review comment:
       Hello @clebertsuconic! 
   How about we do something like 
   ```
   public EmbeddedActiveMQ stop() throws Exception {
         activeMQServer.stop();
         if (activeMQServer != null) {
            activeMQServer.stop();
         } else {
                  throw new IllegalArgumentException("ActiveQMServer is null, hence not stopped");
         }
         return this;
   }
   ```
   or 
   ```
   public EmbeddedActiveMQ stop() throws Exception {
         activeMQServer.stop();
         if (activeMQServer == null) {
                  throw new IllegalArgumentException("ActiveQMServer is null, hence not stopped");
         } 
          activeMQServer.stop();
         return this;
   }
   ```
   such that creating test cases for this improved logic becomes simplified 
   ```
   server = null;
   Assert.assertThrows(IllegalAccessException.class, () -> {
            server.stop();
   });
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [activemq-artemis] nbrendah commented on a change in pull request #3811: ARTEMIS-2582: EmbeddedActiveMQ.stop() should check for null

Posted by GitBox <gi...@apache.org>.
nbrendah commented on a change in pull request #3811:
URL: https://github.com/apache/activemq-artemis/pull/3811#discussion_r735153565



##########
File path: artemis-server/src/main/java/org/apache/activemq/artemis/core/server/embedded/EmbeddedActiveMQ.java
##########
@@ -139,7 +139,9 @@ protected void initStart() throws Exception {
    }
 
    public EmbeddedActiveMQ stop() throws Exception {
-      activeMQServer.stop();
+      if (activeMQServer != null) {
+         activeMQServer.stop();
+      }
       return this;

Review comment:
       Hello @clebertsuconic! 
   How about we do something like 
   ```
   public EmbeddedActiveMQ stop() throws Exception {
     if (activeMQServer != null) {
        activeMQServer.stop();
     } else {
              throw new IllegalArgumentException("ActiveQMServer is null, hence not stopped");
     }
     return this;
   }
   ```
   or 
   ```
   public EmbeddedActiveMQ stop() throws Exception {
     if (activeMQServer == null) {
              throw new IllegalArgumentException("ActiveQMServer is null, hence not stopped");
     } 
      activeMQServer.stop();
     return this;
   }
   ```
   such that creating test cases for this improved logic becomes simplified 
   ```
   server = null;
   Assert.assertThrows(IllegalAccessException.class, () -> {
       server.stop();
   });
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [activemq-artemis] nbrendah commented on a change in pull request #3811: ARTEMIS-2582: EmbeddedActiveMQ.stop() should check for null

Posted by GitBox <gi...@apache.org>.
nbrendah commented on a change in pull request #3811:
URL: https://github.com/apache/activemq-artemis/pull/3811#discussion_r745074874



##########
File path: artemis-server/src/main/java/org/apache/activemq/artemis/core/server/embedded/EmbeddedActiveMQ.java
##########
@@ -139,7 +139,9 @@ protected void initStart() throws Exception {
    }
 
    public EmbeddedActiveMQ stop() throws Exception {
-      activeMQServer.stop();
+      if (activeMQServer != null) {
+         activeMQServer.stop();
+      }
       return this;

Review comment:
       hello @clebertsuconic 
   do you have any suggestions or comments on this?
   




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [activemq-artemis] gtully commented on pull request #3811: ARTEMIS-2582: EmbeddedActiveMQ.stop() should check for null

Posted by GitBox <gi...@apache.org>.
gtully commented on pull request #3811:
URL: https://github.com/apache/activemq-artemis/pull/3811#issuecomment-985701369


   it may as well have a little test, to ensure there is no regression in the future


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [activemq-artemis] nbrendah removed a comment on pull request #3811: ARTEMIS-2582: EmbeddedActiveMQ.stop() should check for null

Posted by GitBox <gi...@apache.org>.
nbrendah removed a comment on pull request #3811:
URL: https://github.com/apache/activemq-artemis/pull/3811#issuecomment-950315758


   Why is it that my tests are passing locally and failing here?
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [activemq-artemis] jbertram commented on a change in pull request #3811: ARTEMIS-2582: EmbeddedActiveMQ.stop() should check for null

Posted by GitBox <gi...@apache.org>.
jbertram commented on a change in pull request #3811:
URL: https://github.com/apache/activemq-artemis/pull/3811#discussion_r735869578



##########
File path: artemis-server/src/main/java/org/apache/activemq/artemis/core/server/embedded/EmbeddedActiveMQ.java
##########
@@ -139,7 +139,9 @@ protected void initStart() throws Exception {
    }
 
    public EmbeddedActiveMQ stop() throws Exception {
-      activeMQServer.stop();
+      if (activeMQServer != null) {
+         activeMQServer.stop();
+      }
       return this;

Review comment:
       The existing behavior which allows a `NullPointerException` is functionally no different from checking for `null` and throwing some other kind of `RuntimeException` (e.g. `java.lang.IllegalArgumentException`). The Jira was opened specifically to avoid such an exception.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [activemq-artemis] nbrendah commented on a change in pull request #3811: ARTEMIS-2582: EmbeddedActiveMQ.stop() should check for null

Posted by GitBox <gi...@apache.org>.
nbrendah commented on a change in pull request #3811:
URL: https://github.com/apache/activemq-artemis/pull/3811#discussion_r735843917



##########
File path: artemis-server/src/main/java/org/apache/activemq/artemis/core/server/embedded/EmbeddedActiveMQ.java
##########
@@ -139,7 +139,9 @@ protected void initStart() throws Exception {
    }
 
    public EmbeddedActiveMQ stop() throws Exception {
-      activeMQServer.stop();
+      if (activeMQServer != null) {
+         activeMQServer.stop();
+      }
       return this;

Review comment:
       yes @michaelpearce-gain I think it would be more technical that way.    




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [activemq-artemis] nbrendah removed a comment on pull request #3811: ARTEMIS-2582: EmbeddedActiveMQ.stop() should check for null

Posted by GitBox <gi...@apache.org>.
nbrendah removed a comment on pull request #3811:
URL: https://github.com/apache/activemq-artemis/pull/3811#issuecomment-950301910


   soon adding tests.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [activemq-artemis] michaelpearce-gain commented on a change in pull request #3811: ARTEMIS-2582: EmbeddedActiveMQ.stop() should check for null

Posted by GitBox <gi...@apache.org>.
michaelpearce-gain commented on a change in pull request #3811:
URL: https://github.com/apache/activemq-artemis/pull/3811#discussion_r735661878



##########
File path: artemis-server/src/main/java/org/apache/activemq/artemis/core/server/embedded/EmbeddedActiveMQ.java
##########
@@ -139,7 +139,9 @@ protected void initStart() throws Exception {
    }
 
    public EmbeddedActiveMQ stop() throws Exception {
-      activeMQServer.stop();
+      if (activeMQServer != null) {
+         activeMQServer.stop();
+      }
       return this;

Review comment:
       Would it not be illegal state? 




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [activemq-artemis] jbertram commented on a change in pull request #3811: ARTEMIS-2582: EmbeddedActiveMQ.stop() should check for null

Posted by GitBox <gi...@apache.org>.
jbertram commented on a change in pull request #3811:
URL: https://github.com/apache/activemq-artemis/pull/3811#discussion_r735869578



##########
File path: artemis-server/src/main/java/org/apache/activemq/artemis/core/server/embedded/EmbeddedActiveMQ.java
##########
@@ -139,7 +139,9 @@ protected void initStart() throws Exception {
    }
 
    public EmbeddedActiveMQ stop() throws Exception {
-      activeMQServer.stop();
+      if (activeMQServer != null) {
+         activeMQServer.stop();
+      }
       return this;

Review comment:
       The existing behavior which allows a `NullPointerException` is no different from checking for `null` and throwing some other kind of `RuntimeException` (e.g. `java.lang.IllegalArgumentException`). The Jira was opened specifically to avoid such an exception.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [activemq-artemis] nbrendah commented on pull request #3811: ARTEMIS-2582: EmbeddedActiveMQ.stop() should check for null

Posted by GitBox <gi...@apache.org>.
nbrendah commented on pull request #3811:
URL: https://github.com/apache/activemq-artemis/pull/3811#issuecomment-963553521


   hello @clebertsuconic
   do you have any suggestions or comments on this?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [activemq-artemis] nbrendah commented on pull request #3811: ARTEMIS-2582: EmbeddedActiveMQ.stop() should check for null

Posted by GitBox <gi...@apache.org>.
nbrendah commented on pull request #3811:
URL: https://github.com/apache/activemq-artemis/pull/3811#issuecomment-950301910


   soon adding tests.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [activemq-artemis] nbrendah commented on a change in pull request #3811: ARTEMIS-2582: EmbeddedActiveMQ.stop() should check for null

Posted by GitBox <gi...@apache.org>.
nbrendah commented on a change in pull request #3811:
URL: https://github.com/apache/activemq-artemis/pull/3811#discussion_r735153565



##########
File path: artemis-server/src/main/java/org/apache/activemq/artemis/core/server/embedded/EmbeddedActiveMQ.java
##########
@@ -139,7 +139,9 @@ protected void initStart() throws Exception {
    }
 
    public EmbeddedActiveMQ stop() throws Exception {
-      activeMQServer.stop();
+      if (activeMQServer != null) {
+         activeMQServer.stop();
+      }
       return this;

Review comment:
       Hello @clebertsuconic! 
   How about we do something like 
   ```
   public EmbeddedActiveMQ stop() throws Exception {
     if (activeMQServer != null) {
        activeMQServer.stop();
     } else {
              throw new IllegalArgumentException("ActiveQMServer is null, hence not stopped");
     }
     return this;
   }
   ```
   or 
   ```
   public EmbeddedActiveMQ stop() throws Exception {
     if (activeMQServer == null) {
        throw new IllegalArgumentException("ActiveQMServer is null, hence not stopped");
     } 
      activeMQServer.stop();
     return this;
   }
   ```
   such that creating test cases for this improved logic becomes simplified 
   ```
   server = null;
   Assert.assertThrows(IllegalAccessException.class, () -> {
       server.stop();
   });
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [activemq-artemis] nbrendah commented on a change in pull request #3811: ARTEMIS-2582: EmbeddedActiveMQ.stop() should check for null

Posted by GitBox <gi...@apache.org>.
nbrendah commented on a change in pull request #3811:
URL: https://github.com/apache/activemq-artemis/pull/3811#discussion_r735153565



##########
File path: artemis-server/src/main/java/org/apache/activemq/artemis/core/server/embedded/EmbeddedActiveMQ.java
##########
@@ -139,7 +139,9 @@ protected void initStart() throws Exception {
    }
 
    public EmbeddedActiveMQ stop() throws Exception {
-      activeMQServer.stop();
+      if (activeMQServer != null) {
+         activeMQServer.stop();
+      }
       return this;

Review comment:
       Hello @clebertsuconic! 
   How about we do something like 
   ```
   public EmbeddedActiveMQ stop() throws Exception {
     if (activeMQServer != null) {
        activeMQServer.stop();
     } else {
        throw new IllegalArgumentException("ActiveQMServer is null, hence not stopped");
     }
     return this;
   }
   ```
   or 
   ```
   public EmbeddedActiveMQ stop() throws Exception {
     if (activeMQServer == null) {
        throw new IllegalArgumentException("ActiveQMServer is null, hence not stopped");
     } 
     activeMQServer.stop();
     return this;
   }
   ```
   such that creating test cases for this improved logic becomes simplified 
   ```
   server = null;
   Assert.assertThrows(IllegalAccessException.class, () -> {
       server.stop();
   });
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org