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 18:25:25 UTC

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

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