[jboss-remoting-commits] JBoss Remoting SVN: r6187 - remoting2/branches/2.x/src/tests/org/jboss/test/remoting/connection/identity.

jboss-remoting-commits at lists.jboss.org jboss-remoting-commits at lists.jboss.org
Sat Dec 18 17:03:56 EST 2010


Author: ron.sigal at jboss.com
Date: 2010-12-18 17:03:56 -0500 (Sat, 18 Dec 2010)
New Revision: 6187

Modified:
   remoting2/branches/2.x/src/tests/org/jboss/test/remoting/connection/identity/ServerIdentityTestCase.java
Log:
JBREM-1144: (1) Shut down ServerThreads in shutdownServer(); (2) sped up LeasePinger.

Modified: remoting2/branches/2.x/src/tests/org/jboss/test/remoting/connection/identity/ServerIdentityTestCase.java
===================================================================
--- remoting2/branches/2.x/src/tests/org/jboss/test/remoting/connection/identity/ServerIdentityTestCase.java	2010-12-18 22:02:27 UTC (rev 6186)
+++ remoting2/branches/2.x/src/tests/org/jboss/test/remoting/connection/identity/ServerIdentityTestCase.java	2010-12-18 22:03:56 UTC (rev 6187)
@@ -23,12 +23,16 @@
 
 import java.io.ByteArrayOutputStream;
 import java.io.PrintStream;
+import java.lang.reflect.Field;
 import java.net.InetAddress;
 import java.security.AccessController;
 import java.security.PrivilegedActionException;
 import java.security.PrivilegedExceptionAction;
+import java.util.ConcurrentModificationException;
 import java.util.HashMap;
+import java.util.Iterator;
 import java.util.Map;
+import java.util.Set;
 
 import javax.management.MBeanServer;
 
@@ -50,6 +54,10 @@
 import org.jboss.remoting.callback.InvokerCallbackHandler;
 import org.jboss.remoting.transport.Connector;
 import org.jboss.remoting.transport.PortUtil;
+import org.jboss.remoting.transport.socket.LRUPool;
+import org.jboss.remoting.transport.socket.ServerSocketWrapper;
+import org.jboss.remoting.transport.socket.ServerThread;
+import org.jboss.remoting.transport.socket.SocketServerInvoker;
 import org.jboss.remoting.util.SecurityUtility;
 
 
@@ -198,7 +206,7 @@
       log.info("SHUT DOWN SERVER");
       setupServer(true);
       log.info("SET UP NEW SERVER");
-      Thread.sleep(10000);
+      Thread.sleep(15000);
       log.info(this + " listener.connectionFailed: " + listener.connectionFailed);
       assertTrue(listener.connectionFailed);
       
@@ -285,7 +293,7 @@
       if (useLeasing)
       {
          locatorURI += "&" + InvokerLocator.CLIENT_LEASE + "=true";
-         locatorURI += "&" + InvokerLocator.CLIENT_LEASE_PERIOD + "=20000";
+         locatorURI += "&" + InvokerLocator.CLIENT_LEASE_PERIOD + "=2000";
       }
       String metadata = System.getProperty("remoting.metadata");
       if (metadata != null)
@@ -312,7 +320,33 @@
    protected void shutdownServer() throws Exception
    {
       if (connector != null)
+      {
+         // Remoting versions 1.x and 2.2.x don't necessarily shut down all of their
+         // ServerThreads, so an exiting connection could connect to a ServerThread
+         // associated with the old ServerInvoker.
+         SocketServerInvoker invoker = (SocketServerInvoker) connector.getServerInvoker();
+         Field clientpoolField = SocketServerInvoker.class.getDeclaredField("clientpool");
+         clientpoolField.setAccessible(true);
+         Field socketWrapperField = ServerThread.class.getDeclaredField("socketWrapper");
+         socketWrapperField.setAccessible(true);
+         LRUPool clientpool = (LRUPool) clientpoolField.get(invoker);
+         Set threads = clientpool.getContents();
+         Iterator it = threads.iterator();
+         while (it.hasNext())
+         {
+            try
+            {
+               ServerThread t = (ServerThread) it.next();
+               ServerSocketWrapper socketWrapper = (ServerSocketWrapper) socketWrapperField.get(t);
+               socketWrapper.close();
+            }
+            catch (ConcurrentModificationException e)
+            {
+               log.info(this + " caught " + e.getMessage());
+            }
+         }
          connector.stop();
+      }
    }
    
    



More information about the jboss-remoting-commits mailing list