You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ta...@apache.org on 2015/12/18 00:18:52 UTC

qpid-jms git commit: QPIDJMS-144 Add some more clenaup code in the failure cases.

Repository: qpid-jms
Updated Branches:
  refs/heads/master b14b3db97 -> f89097978


QPIDJMS-144 Add some more clenaup code in the failure cases.

Project: http://git-wip-us.apache.org/repos/asf/qpid-jms/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/f8909797
Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/f8909797
Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/f8909797

Branch: refs/heads/master
Commit: f89097978785ff03b1b45a53c0441c488b68eaf6
Parents: b14b3db
Author: Timothy Bish <ta...@gmail.com>
Authored: Thu Dec 17 18:18:41 2015 -0500
Committer: Timothy Bish <ta...@gmail.com>
Committed: Thu Dec 17 18:18:41 2015 -0500

----------------------------------------------------------------------
 .../qpid/jms/transports/netty/NettySslTransport.java   |  2 +-
 .../qpid/jms/transports/netty/NettyTcpTransport.java   | 11 +++++++----
 .../qpid/jms/integration/SessionIntegrationTest.java   |  1 -
 .../qpid/jms/transports/netty/NettyEchoServer.java     | 13 +++++++++++--
 .../jms/transports/netty/NettySslTransportTest.java    |  5 +++++
 5 files changed, 24 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/f8909797/qpid-jms-client/src/main/java/org/apache/qpid/jms/transports/netty/NettySslTransport.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/main/java/org/apache/qpid/jms/transports/netty/NettySslTransport.java b/qpid-jms-client/src/main/java/org/apache/qpid/jms/transports/netty/NettySslTransport.java
index 2ea2637..0d83826 100644
--- a/qpid-jms-client/src/main/java/org/apache/qpid/jms/transports/netty/NettySslTransport.java
+++ b/qpid-jms-client/src/main/java/org/apache/qpid/jms/transports/netty/NettySslTransport.java
@@ -85,7 +85,7 @@ public class NettySslTransport extends NettyTcpTransport implements SSLTransport
                     connectionEstablished(channel);
                 } else {
                     LOG.trace("SSL Handshake has failed: {}", channel);
-                    connectionFailed(IOExceptionSupport.create(future.cause()));
+                    connectionFailed(channel, IOExceptionSupport.create(future.cause()));
                 }
             }
         });

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/f8909797/qpid-jms-client/src/main/java/org/apache/qpid/jms/transports/netty/NettyTcpTransport.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/main/java/org/apache/qpid/jms/transports/netty/NettyTcpTransport.java b/qpid-jms-client/src/main/java/org/apache/qpid/jms/transports/netty/NettyTcpTransport.java
index cbb88f5..4b2664d 100644
--- a/qpid-jms-client/src/main/java/org/apache/qpid/jms/transports/netty/NettyTcpTransport.java
+++ b/qpid-jms-client/src/main/java/org/apache/qpid/jms/transports/netty/NettyTcpTransport.java
@@ -124,9 +124,9 @@ public class NettyTcpTransport implements Transport {
                 if (future.isSuccess()) {
                     handleConnected(future.channel());
                 } else if (future.isCancelled()) {
-                    connectionFailed(new IOException("Connection attempt was cancelled"));
+                    connectionFailed(future.channel(), new IOException("Connection attempt was cancelled"));
                 } else {
-                    connectionFailed(IOExceptionSupport.create(future.cause()));
+                    connectionFailed(future.channel(), IOExceptionSupport.create(future.cause()));
                 }
             }
         });
@@ -142,7 +142,7 @@ public class NettyTcpTransport implements Transport {
         if (failureCause != null) {
             // Close out any Netty resources now as they are no longer needed.
             if (channel != null) {
-                channel.close();
+                channel.close().syncUninterruptibly();
                 channel = null;
             }
             if (group != null) {
@@ -279,11 +279,14 @@ public class NettyTcpTransport implements Transport {
     /**
      * Called when the transport connection failed and an error should be returned.
      *
+     * @param failedChannel
+     *      The Channel instance that failed.
      * @param cause
      *      An IOException that describes the cause of the failed connection.
      */
-    protected void connectionFailed(IOException cause) {
+    protected void connectionFailed(Channel failedChannel, IOException cause) {
         failureCause = IOExceptionSupport.create(cause);
+        channel = failedChannel;
         connected.set(false);
         connectLatch.countDown();
     }

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/f8909797/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/SessionIntegrationTest.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/SessionIntegrationTest.java b/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/SessionIntegrationTest.java
index bf26f20..415ffb1 100644
--- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/SessionIntegrationTest.java
+++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/SessionIntegrationTest.java
@@ -1104,7 +1104,6 @@ public class SessionIntegrationTest extends QpidJmsTestCase {
         }
     }
 
-
     @Test(timeout=20000)
     public void testPrefetchPolicyInfluencesCreditFlow() throws Exception {
         try (TestAmqpPeer testPeer = new TestAmqpPeer();) {

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/f8909797/qpid-jms-client/src/test/java/org/apache/qpid/jms/transports/netty/NettyEchoServer.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/transports/netty/NettyEchoServer.java b/qpid-jms-client/src/test/java/org/apache/qpid/jms/transports/netty/NettyEchoServer.java
index 23f23fa..4f100a9 100644
--- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/transports/netty/NettyEchoServer.java
+++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/transports/netty/NettyEchoServer.java
@@ -59,7 +59,7 @@ public class NettyEchoServer implements AutoCloseable {
     private Channel serverChannel;
     private final TransportOptions options;
     private int serverPort;
-    private boolean needClientAuth;
+    private final boolean needClientAuth;
     private volatile SslHandler sslHandler;
 
     private final AtomicBoolean started = new AtomicBoolean();
@@ -158,13 +158,22 @@ public class NettyEchoServer implements AutoCloseable {
                 handler.handshakeFuture().addListener(new GenericFutureListener<Future<Channel>>() {
                     @Override
                     public void operationComplete(Future<Channel> future) throws Exception {
-                        LOG.info("SSL handshake completed. Succeeded: " + future.isSuccess());
+                        LOG.info("SSL handshake completed. Succeeded: {}", future.isSuccess());
+                        if (!future.isSuccess()) {
+                            sslHandler.close();
+                            ctx.close();
+                        }
                     }
                 });
             }
         }
 
         @Override
+        public void channelInactive(ChannelHandlerContext ctx) throws Exception {
+            ctx.close();
+        }
+
+        @Override
         public void channelRead(ChannelHandlerContext ctx, Object msg) {
             ctx.write(msg);
         }

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/f8909797/qpid-jms-client/src/test/java/org/apache/qpid/jms/transports/netty/NettySslTransportTest.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/transports/netty/NettySslTransportTest.java b/qpid-jms-client/src/test/java/org/apache/qpid/jms/transports/netty/NettySslTransportTest.java
index adadd38..bfc9f71 100644
--- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/transports/netty/NettySslTransportTest.java
+++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/transports/netty/NettySslTransportTest.java
@@ -32,13 +32,17 @@ import org.apache.qpid.jms.transports.Transport;
 import org.apache.qpid.jms.transports.TransportListener;
 import org.apache.qpid.jms.transports.TransportOptions;
 import org.apache.qpid.jms.transports.TransportSslOptions;
+import org.apache.qpid.jms.util.QpidJMSTestRunner;
+import org.apache.qpid.jms.util.Repeat;
 import org.junit.Test;
+import org.junit.runner.RunWith;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
  * Test basic functionality of the Netty based SSL Transport.
  */
+@RunWith(QpidJMSTestRunner.class)
 public class NettySslTransportTest extends NettyTcpTransportTest {
 
     private static final Logger LOG = LoggerFactory.getLogger(NettySslTransportTest.class);
@@ -95,6 +99,7 @@ public class NettySslTransportTest extends NettyTcpTransportTest {
     }
 
     @Test(timeout = 60 * 1000)
+    @Repeat(repetitions = 1)
     public void testConnectToServerUsingUntrustedKeyFails() throws Exception {
         try (NettyEchoServer server = new NettyEchoServer(createServerOptions())) {
             server.start();


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org