GEODE-3023: Moved the population of the socket.setSoTimeout before the SSL 
handshake.
This allows for the SO_TIMEOUT on the socket to be set before the any potential 
SSL failure.


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/4de5b2a4
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/4de5b2a4
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/4de5b2a4

Branch: refs/heads/feature/GEODE-3023
Commit: 4de5b2a4921c6703699f2963bb3a37b8a91be722
Parents: e5e48af
Author: Udo Kohlmeyer <[email protected]>
Authored: Tue Jun 6 10:49:05 2017 -0700
Committer: Udo Kohlmeyer <[email protected]>
Committed: Fri Jun 9 13:12:45 2017 -0700

----------------------------------------------------------------------
 .../internal/tcpserver/TcpServer.java           | 10 ++++----
 .../tcpserver/TCPServerSSLJUnitTest.java        | 17 ++++++++------
 .../internal/tcpserver/TcpServerJUnitTest.java  | 24 +++++++++++++-------
 .../geode/internal/net/DelaySocketCreator.java  |  4 +---
 4 files changed, 31 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/4de5b2a4/geode-core/src/main/java/org/apache/geode/distributed/internal/tcpserver/TcpServer.java
----------------------------------------------------------------------
diff --git 
a/geode-core/src/main/java/org/apache/geode/distributed/internal/tcpserver/TcpServer.java
 
b/geode-core/src/main/java/org/apache/geode/distributed/internal/tcpserver/TcpServer.java
index 976f504..06d3c66 100755
--- 
a/geode-core/src/main/java/org/apache/geode/distributed/internal/tcpserver/TcpServer.java
+++ 
b/geode-core/src/main/java/org/apache/geode/distributed/internal/tcpserver/TcpServer.java
@@ -68,7 +68,6 @@ import javax.net.ssl.SSLException;
  * <p>
  * This code was factored out of GossipServer.java to allow multiple handlers 
to share the same
  * gossip server port.
- * 
  * @since GemFire 5.7
  */
 public class TcpServer {
@@ -142,8 +141,8 @@ public class TcpServer {
   }
 
   public TcpServer(int port, InetAddress bind_address, Properties sslConfig,
-      DistributionConfigImpl cfg, TcpHandler handler, PoolStatHelper 
poolHelper,
-      ThreadGroup threadGroup, String threadName) {
+                   DistributionConfigImpl cfg, TcpHandler handler, 
PoolStatHelper poolHelper,
+                   ThreadGroup threadGroup, String threadName) {
     this.port = port;
     this.bind_address = bind_address;
     this.handler = handler;
@@ -174,7 +173,7 @@ public class TcpServer {
   }
 
   private static PooledExecutorWithDMStats createExecutor(PoolStatHelper 
poolHelper,
-      final ThreadGroup threadGroup) {
+                                                          final ThreadGroup 
threadGroup) {
     ThreadFactory factory = new ThreadFactory() {
       private final AtomicInteger threadNum = new AtomicInteger();
 
@@ -191,7 +190,7 @@ public class TcpServer {
   }
 
   public void restarting(InternalDistributedSystem ds, InternalCache cache,
-      ClusterConfigurationService sharedConfig) throws IOException {
+                         ClusterConfigurationService sharedConfig) throws 
IOException {
     this.shuttingDown = false;
     this.handler.restarting(ds, cache, sharedConfig);
     startServerThread();
@@ -263,7 +262,6 @@ public class TcpServer {
   /**
    * Returns the value of the bound port. If the server was initialized with a 
port of 0 indicating
    * that any ephemeral port should be used, this method will return the 
actual bound port.
-   * 
    * @return the locator's tcp/ip port. This will be zero if the locator 
hasn't been started.
    */
   public int getPort() {

http://git-wip-us.apache.org/repos/asf/geode/blob/4de5b2a4/geode-core/src/test/java/org/apache/geode/distributed/internal/tcpserver/TCPServerSSLJUnitTest.java
----------------------------------------------------------------------
diff --git 
a/geode-core/src/test/java/org/apache/geode/distributed/internal/tcpserver/TCPServerSSLJUnitTest.java
 
b/geode-core/src/test/java/org/apache/geode/distributed/internal/tcpserver/TCPServerSSLJUnitTest.java
index d35587f..138fc9d 100644
--- 
a/geode-core/src/test/java/org/apache/geode/distributed/internal/tcpserver/TCPServerSSLJUnitTest.java
+++ 
b/geode-core/src/test/java/org/apache/geode/distributed/internal/tcpserver/TCPServerSSLJUnitTest.java
@@ -30,6 +30,7 @@ import org.apache.geode.distributed.internal.PoolStatHelper;
 import org.apache.geode.internal.AvailablePort;
 import org.apache.geode.internal.admin.SSLConfig;
 import org.apache.geode.internal.net.DelaySocketCreator;
+import org.apache.geode.internal.net.DummySocketCreator;
 import org.apache.geode.internal.net.SSLConfigurationFactory;
 import org.apache.geode.internal.net.SocketCreator;
 import org.apache.geode.internal.net.SocketCreatorFactory;
@@ -93,7 +94,7 @@ public class TCPServerSSLJUnitTest {
 
       createTcpClientConnection();
 
-    } catch (LocatorCancelException e) {
+    } catch (LocatorCancelException e){
       // we catching the LocatorCancelException. Expected to have the 
exception thrown
       caughtLocatorException = true;
     }
@@ -109,8 +110,8 @@ public class TCPServerSSLJUnitTest {
 
   private Properties getSSLConfigurationProperties() {
     Properties sslProperties = new Properties();
-    sslProperties.setProperty(SSL_ENABLED_COMPONENTS,
-        SecurableCommunicationChannel.LOCATOR.getConstant());
+    sslProperties
+        .setProperty(SSL_ENABLED_COMPONENTS, 
SecurableCommunicationChannel.LOCATOR.getConstant());
     sslProperties.setProperty(SSL_KEYSTORE,
         TestUtil.getResourcePath(getClass(), 
"/org/apache/geode/internal/net/multiKey.jks"));
     sslProperties.setProperty(SSL_TRUSTSTORE,
@@ -138,8 +139,9 @@ public class TCPServerSSLJUnitTest {
     private List<Integer> recordedSocketsTimeouts = new ArrayList<>();
 
     public DummyTcpServer(int port, InetAddress bind_address, Properties 
sslConfig,
-        DistributionConfigImpl cfg, TcpHandler handler, PoolStatHelper 
poolHelper,
-        ThreadGroup threadGroup, String threadName) {
+                          DistributionConfigImpl cfg,
+                          TcpHandler handler,
+                          PoolStatHelper poolHelper, ThreadGroup threadGroup, 
String threadName) {
       super(port, bind_address, sslConfig, cfg, handler, poolHelper, 
threadGroup, threadName);
       if (cfg == null) {
         cfg = new DistributionConfigImpl(sslConfig);
@@ -151,9 +153,10 @@ public class TCPServerSSLJUnitTest {
     protected SocketCreator getSocketCreator() {
       if (this.socketCreator == null) {
         SSLConfigurationFactory.setDistributionConfig(distributionConfig);
-        SSLConfig sslConfig =
+        SSLConfig
+            sslConfig =
             
SSLConfigurationFactory.getSSLConfigForComponent(SecurableCommunicationChannel.LOCATOR);
-        this.socketCreator = new DelaySocketCreator(sslConfig, 
recordedSocketsTimeouts);
+        this.socketCreator = new DummySocketCreator(sslConfig, 
recordedSocketsTimeouts);
       }
       return socketCreator;
     }

http://git-wip-us.apache.org/repos/asf/geode/blob/4de5b2a4/geode-core/src/test/java/org/apache/geode/distributed/internal/tcpserver/TcpServerJUnitTest.java
----------------------------------------------------------------------
diff --git 
a/geode-core/src/test/java/org/apache/geode/distributed/internal/tcpserver/TcpServerJUnitTest.java
 
b/geode-core/src/test/java/org/apache/geode/distributed/internal/tcpserver/TcpServerJUnitTest.java
index eda0641..05fc302 100644
--- 
a/geode-core/src/test/java/org/apache/geode/distributed/internal/tcpserver/TcpServerJUnitTest.java
+++ 
b/geode-core/src/test/java/org/apache/geode/distributed/internal/tcpserver/TcpServerJUnitTest.java
@@ -181,11 +181,14 @@ public class TcpServerJUnitTest {
     }
 
     public void restarting(DistributedSystem ds, GemFireCache cache,
-        ClusterConfigurationService sharedConfig) {}
+                           ClusterConfigurationService sharedConfig) {
+    }
 
-    public void endRequest(Object request, long startTime) {}
+    public void endRequest(Object request, long startTime) {
+    }
 
-    public void endResponse(Object request, long startTime) {}
+    public void endResponse(Object request, long startTime) {
+    }
 
   }
 
@@ -197,7 +200,8 @@ public class TcpServerJUnitTest {
       this.latch = latch;
     }
 
-    public void init(TcpServer tcpServer) {}
+    public void init(TcpServer tcpServer) {
+    }
 
     public Object processRequest(Object request) throws IOException {
       Boolean delay = (Boolean) request;
@@ -211,14 +215,18 @@ public class TcpServerJUnitTest {
       return delay;
     }
 
-    public void shutDown() {}
+    public void shutDown() {
+    }
 
     public void restarting(DistributedSystem ds, GemFireCache cache,
-        ClusterConfigurationService sharedConfig) {}
+                           ClusterConfigurationService sharedConfig) {
+    }
 
-    public void endRequest(Object request, long startTime) {}
+    public void endRequest(Object request, long startTime) {
+    }
 
-    public void endResponse(Object request, long startTime) {}
+    public void endResponse(Object request, long startTime) {
+    }
   }
 
   private/* GemStoneAddition */ static class SimpleStats implements 
PoolStatHelper {

http://git-wip-us.apache.org/repos/asf/geode/blob/4de5b2a4/geode-core/src/test/java/org/apache/geode/internal/net/DelaySocketCreator.java
----------------------------------------------------------------------
diff --git 
a/geode-core/src/test/java/org/apache/geode/internal/net/DelaySocketCreator.java
 
b/geode-core/src/test/java/org/apache/geode/internal/net/DelaySocketCreator.java
index bfff90b..7daebbb 100644
--- 
a/geode-core/src/test/java/org/apache/geode/internal/net/DelaySocketCreator.java
+++ 
b/geode-core/src/test/java/org/apache/geode/internal/net/DelaySocketCreator.java
@@ -39,7 +39,5 @@ public class DelaySocketCreator extends SocketCreator {
     throw new SSLException("This is a test SSLException");
   }
 
-  public List<Integer> getSocketSoTimeouts() {
-    return socketSoTimeouts;
-  }
+  public List<Integer> getSocketSoTimeouts() { return socketSoTimeouts; }
 }

Reply via email to