You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by kw...@apache.org on 2017/10/19 06:46:36 UTC

qpid-broker-j git commit: NO-JIRA: [Java Tests] Prevent socket leak from test class

Repository: qpid-broker-j
Updated Branches:
  refs/heads/master a213b5d43 -> 2318c2fe1


NO-JIRA: [Java Tests] Prevent socket leak from test class


Project: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/commit/2318c2fe
Tree: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/tree/2318c2fe
Diff: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/diff/2318c2fe

Branch: refs/heads/master
Commit: 2318c2fe1bd0cfe4c2563212650a873acf3e12bf
Parents: a213b5d
Author: Keith Wall <ke...@gmail.com>
Authored: Thu Oct 19 07:44:37 2017 +0100
Committer: Keith Wall <ke...@gmail.com>
Committed: Thu Oct 19 07:44:37 2017 +0100

----------------------------------------------------------------------
 .../transport/TCPandSSLTransportTest.java       | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/2318c2fe/broker-core/src/test/java/org/apache/qpid/server/transport/TCPandSSLTransportTest.java
----------------------------------------------------------------------
diff --git a/broker-core/src/test/java/org/apache/qpid/server/transport/TCPandSSLTransportTest.java b/broker-core/src/test/java/org/apache/qpid/server/transport/TCPandSSLTransportTest.java
index 8389fab..e83cdd1 100644
--- a/broker-core/src/test/java/org/apache/qpid/server/transport/TCPandSSLTransportTest.java
+++ b/broker-core/src/test/java/org/apache/qpid/server/transport/TCPandSSLTransportTest.java
@@ -148,7 +148,7 @@ public class TCPandSSLTransportTest extends QpidTestCase
         when(port.getThreadPoolSize()).thenReturn(2);
         when(port.getNumberOfSelectors()).thenReturn(1);
         when(port.getSSLContext()).thenReturn(sslContext);
-        when(port.getContextValue(Long.class, AmqpPort.PORT_AMQP_THREAD_POOL_KEEP_ALIVE_TIMEOUT)).thenReturn(1l);
+        when(port.getContextValue(Long.class, AmqpPort.PORT_AMQP_THREAD_POOL_KEEP_ALIVE_TIMEOUT)).thenReturn(1L);
         when(port.getContextValue(Integer.class, AmqpPort.PORT_AMQP_ACCEPT_BACKLOG)).thenReturn(AmqpPort.DEFAULT_PORT_AMQP_ACCEPT_BACKLOG);
         when(port.getProtocolHandshakeTimeout()).thenReturn(AmqpPort.DEFAULT_PROTOCOL_HANDSHAKE_TIMEOUT);
         ObjectMapper mapper = new ObjectMapper();
@@ -171,20 +171,18 @@ public class TCPandSSLTransportTest extends QpidTestCase
                                                               Protocol.AMQP_0_9_1);
 
         transport.start();
-        try
-        {
-            SSLContext clientContext = SSLContext.getInstance("TLS");
-            TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
-            tmf.init(keyStore);
+        SSLContext clientContext = SSLContext.getInstance("TLS");
+        TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
+        tmf.init(keyStore);
 
-            clientContext.init(null, tmf.getTrustManagers(), null);
+        clientContext.init(null, tmf.getTrustManagers(), null);
 
-            SSLSocket sslSocket =
-                    (SSLSocket) clientContext.getSocketFactory().createSocket(InetAddress.getLoopbackAddress(),
-                            transport.getAcceptingPort());
+        try (SSLSocket sslSocket = (SSLSocket) clientContext.getSocketFactory()
+                                                            .createSocket(InetAddress.getLoopbackAddress(),
+                                                                          transport.getAcceptingPort()))
+        {
 
             sslSocket.setEnabledProtocols(new String[]{clientProtocol});
-
             sslSocket.startHandshake();
         }
         finally


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