activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbert...@apache.org
Subject [1/2] activemq-artemis git commit: ARTEMIS-1804 deprecated Netty SslHandler.close() causing NPE
Date Fri, 04 May 2018 19:27:55 GMT
Repository: activemq-artemis
Updated Branches:
  refs/heads/master acc34d908 -> 950698960


ARTEMIS-1804 deprecated Netty SslHandler.close() causing NPE

The NPE can appear when an OpenWire client which is using SSL disconnects.


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

Branch: refs/heads/master
Commit: dac332fe1fca33343a8fe3f7ea6c29ee772d32bc
Parents: acc34d9
Author: Jiri Danek <jdanek@redhat.com>
Authored: Fri May 4 14:15:43 2018 +0200
Committer: Justin Bertram <jbertram@apache.org>
Committed: Fri May 4 14:26:48 2018 -0500

----------------------------------------------------------------------
 .../remoting/impl/netty/NettyConnection.java    | 31 +++++---------------
 1 file changed, 7 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/dac332fe/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnection.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnection.java
b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnection.java
index 3f400dc..f8195fb 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnection.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnection.java
@@ -30,7 +30,6 @@ import io.netty.channel.ChannelFuture;
 import io.netty.channel.ChannelFutureListener;
 import io.netty.channel.ChannelPromise;
 import io.netty.channel.EventLoop;
-import io.netty.handler.ssl.SslHandler;
 import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
 import org.apache.activemq.artemis.api.core.ActiveMQInterruptedException;
 import org.apache.activemq.artemis.api.core.TransportConfiguration;
@@ -238,12 +237,10 @@ public class NettyConnection implements Connection {
       boolean inEventLoop = eventLoop.inEventLoop();
       //if we are in an event loop we need to close the channel after the writes have finished
       if (!inEventLoop) {
-         final SslHandler sslHandler = (SslHandler) channel.pipeline().get("ssl");
-         closeSSLAndChannel(sslHandler, channel, false);
+         closeChannel(channel, false);
       } else {
          eventLoop.execute(() -> {
-            final SslHandler sslHandler = (SslHandler) channel.pipeline().get("ssl");
-            closeSSLAndChannel(sslHandler, channel, true);
+            closeChannel(channel, true);
          });
       }
 
@@ -555,26 +552,12 @@ public class NettyConnection implements Connection {
       return super.toString() + "[ID=" + getID() + ", local= " + channel.localAddress() +
", remote=" + channel.remoteAddress() + "]";
    }
 
-   private void closeSSLAndChannel(SslHandler sslHandler, final Channel channel, boolean
inEventLoop) {
+   private void closeChannel(final Channel channel, boolean inEventLoop) {
       checkFlushBatchBuffer();
-      if (sslHandler != null) {
-         try {
-            ChannelFuture sslCloseFuture = sslHandler.close();
-            sslCloseFuture.addListener(future -> channel.close());
-            if (!inEventLoop && !sslCloseFuture.awaitUninterruptibly(DEFAULT_WAIT_MILLIS))
{
-               ActiveMQClientLogger.LOGGER.timeoutClosingSSL();
-            }
-         } catch (Throwable t) {
-            // ignore
-            if (ActiveMQClientLogger.LOGGER.isTraceEnabled()) {
-               ActiveMQClientLogger.LOGGER.trace(t.getMessage(), t);
-            }
-         }
-      } else {
-         ChannelFuture closeFuture = channel.close();
-         if (!inEventLoop && !closeFuture.awaitUninterruptibly(DEFAULT_WAIT_MILLIS))
{
-            ActiveMQClientLogger.LOGGER.timeoutClosingNettyChannel();
-         }
+      // closing the channel results in closing any sslHandler first; SslHandler#close()
was deprecated by netty
+      ChannelFuture closeFuture = channel.close();
+      if (!inEventLoop && !closeFuture.awaitUninterruptibly(DEFAULT_WAIT_MILLIS))
{
+         ActiveMQClientLogger.LOGGER.timeoutClosingNettyChannel();
       }
    }
 


Mime
View raw message