activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clebertsuco...@apache.org
Subject [2/3] activemq-artemis git commit: Avoid potential NPEs seen on tests
Date Thu, 30 Apr 2015 17:15:02 GMT
Avoid potential NPEs seen on tests


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

Branch: refs/heads/master
Commit: 028529b8a910af3d1d8c941c48184d1730ae4973
Parents: 791cc5c
Author: jbertram <jbertram@apache.org>
Authored: Wed Apr 29 13:35:18 2015 -0500
Committer: jbertram <jbertram@apache.org>
Committed: Thu Apr 30 09:26:03 2015 -0500

----------------------------------------------------------------------
 .../plug/test/minimalserver/MinimalServer.java  | 11 ++++-
 .../core/remoting/impl/netty/NettyAcceptor.java | 44 ++++++++++++--------
 2 files changed, 36 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/028529b8/artemis-protocols/artemis-proton-plug/src/test/java/org/proton/plug/test/minimalserver/MinimalServer.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-proton-plug/src/test/java/org/proton/plug/test/minimalserver/MinimalServer.java
b/artemis-protocols/artemis-proton-plug/src/test/java/org/proton/plug/test/minimalserver/MinimalServer.java
index 5c43d6f..8351396 100644
--- a/artemis-protocols/artemis-proton-plug/src/test/java/org/proton/plug/test/minimalserver/MinimalServer.java
+++ b/artemis-protocols/artemis-proton-plug/src/test/java/org/proton/plug/test/minimalserver/MinimalServer.java
@@ -155,8 +155,15 @@ public class MinimalServer
 
    public synchronized void stop()
    {
-      serverChannelGroup.close().awaitUninterruptibly();
-      ChannelGroupFuture future = channelGroup.close().awaitUninterruptibly();
+      if (serverChannelGroup != null)
+      {
+         serverChannelGroup.close().awaitUninterruptibly();
+      }
+
+      if (channelGroup != null)
+      {
+         ChannelGroupFuture future = channelGroup.close().awaitUninterruptibly();
+      }
    }
 
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/028529b8/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyAcceptor.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyAcceptor.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyAcceptor.java
index 02342f7..8ed06be 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyAcceptor.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyAcceptor.java
@@ -546,19 +546,26 @@ public class NettyAcceptor implements Acceptor
 
 
       // serverChannelGroup has been unbound in pause()
-      serverChannelGroup.close().awaitUninterruptibly();
-      ChannelGroupFuture future = channelGroup.close().awaitUninterruptibly();
+      if (serverChannelGroup != null)
+      {
+         serverChannelGroup.close().awaitUninterruptibly();
+      }
 
-      if (!future.isSuccess())
+      if (channelGroup != null)
       {
-         ActiveMQServerLogger.LOGGER.nettyChannelGroupError();
-         Iterator<Channel> iterator = future.group().iterator();
-         while (iterator.hasNext())
+         ChannelGroupFuture future = channelGroup.close().awaitUninterruptibly();
+
+         if (!future.isSuccess())
          {
-            Channel channel = iterator.next();
-            if (channel.isActive())
+            ActiveMQServerLogger.LOGGER.nettyChannelGroupError();
+            Iterator<Channel> iterator = future.group().iterator();
+            while (iterator.hasNext())
             {
-               ActiveMQServerLogger.LOGGER.nettyChannelStillOpen(channel, channel.remoteAddress());
+               Channel channel = iterator.next();
+               if (channel.isActive())
+               {
+                  ActiveMQServerLogger.LOGGER.nettyChannelStillOpen(channel, channel.remoteAddress());
+               }
             }
          }
       }
@@ -617,17 +624,20 @@ public class NettyAcceptor implements Acceptor
       }
 
       // We *pause* the acceptor so no new connections are made
-      ChannelGroupFuture future = serverChannelGroup.close().awaitUninterruptibly();
-      if (!future.isSuccess())
+      if (serverChannelGroup != null)
       {
-         ActiveMQServerLogger.LOGGER.nettyChannelGroupBindError();
-         Iterator<Channel> iterator = future.group().iterator();
-         while (iterator.hasNext())
+         ChannelGroupFuture future = serverChannelGroup.close().awaitUninterruptibly();
+         if (!future.isSuccess())
          {
-            Channel channel = iterator.next();
-            if (channel.isActive())
+            ActiveMQServerLogger.LOGGER.nettyChannelGroupBindError();
+            Iterator<Channel> iterator = future.group().iterator();
+            while (iterator.hasNext())
             {
-               ActiveMQServerLogger.LOGGER.nettyChannelStillBound(channel, channel.remoteAddress());
+               Channel channel = iterator.next();
+               if (channel.isActive())
+               {
+                  ActiveMQServerLogger.LOGGER.nettyChannelStillBound(channel, channel.remoteAddress());
+               }
             }
          }
       }


Mime
View raw message