[hornetq-commits] JBoss hornetq SVN: r8704 - in trunk: tests/src/org/hornetq/tests/integration/client and 1 other directory.

do-not-reply at jboss.org do-not-reply at jboss.org
Tue Dec 22 09:56:14 EST 2009


Author: jmesnil
Date: 2009-12-22 09:56:14 -0500 (Tue, 22 Dec 2009)
New Revision: 8704

Modified:
   trunk/src/main/org/hornetq/core/server/impl/HornetQPacketHandler.java
   trunk/tests/src/org/hornetq/tests/integration/client/IncompatibleVersionTest.java
Log:
HORNETQ-252: Connections not closed if client/server version mismatch

* on the server, do not destroy the connection immediately (or there is a chance the network
  socket will be closed before the exception packet is received by the client) and
  let it be destroyed later (when its TTL expires)
* rewrite IncompatibleVersionTest


Modified: trunk/src/main/org/hornetq/core/server/impl/HornetQPacketHandler.java
===================================================================
--- trunk/src/main/org/hornetq/core/server/impl/HornetQPacketHandler.java	2009-12-22 11:14:43 UTC (rev 8703)
+++ trunk/src/main/org/hornetq/core/server/impl/HornetQPacketHandler.java	2009-12-22 14:56:14 UTC (rev 8704)
@@ -153,7 +153,6 @@
       if (incompatibleVersion)
       {
          channel1.sendAndFlush(response);
-         connection.destroy();
       }
       else
       {

Modified: trunk/tests/src/org/hornetq/tests/integration/client/IncompatibleVersionTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/integration/client/IncompatibleVersionTest.java	2009-12-22 11:14:43 UTC (rev 8703)
+++ trunk/tests/src/org/hornetq/tests/integration/client/IncompatibleVersionTest.java	2009-12-22 14:56:14 UTC (rev 8704)
@@ -30,6 +30,7 @@
 import org.hornetq.core.remoting.impl.invm.InVMConnectorFactory;
 import org.hornetq.core.remoting.impl.wireformat.CreateSessionMessage;
 import org.hornetq.core.remoting.impl.wireformat.CreateSessionResponseMessage;
+import org.hornetq.core.remoting.server.impl.RemotingServiceImpl;
 import org.hornetq.core.server.HornetQServer;
 import org.hornetq.tests.util.ServiceTestBase;
 import org.hornetq.utils.VersionLoader;
@@ -37,7 +38,7 @@
 /**
  * A IncompatibleVersionTest
  *
- * @author jmesnil
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
  *
  *
  */
@@ -62,6 +63,7 @@
    protected void setUp() throws Exception
    {
       server = createServer(false, false);
+      server.getConfiguration().setConnectionTTLOverride(500);
       server.start();
 
       TransportConfiguration config = new TransportConfiguration(InVMConnectorFactory.class.getName());
@@ -74,7 +76,7 @@
                                                                     ClientSessionFactoryImpl.DEFAULT_FAILOVER_ON_SERVER_SHUTDOWN,
                                                                     ClientSessionFactoryImpl.DEFAULT_CALL_TIMEOUT,
                                                                     ClientSessionFactoryImpl.DEFAULT_CLIENT_FAILURE_CHECK_PERIOD,
-                                                                    ClientSessionFactoryImpl.DEFAULT_CONNECTION_TTL,
+                                                                    500,
                                                                     ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL,
                                                                     ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL_MULTIPLIER,
                                                                     ClientSessionFactoryImpl.DEFAULT_MAX_RETRY_INTERVAL,
@@ -88,6 +90,8 @@
    @Override
    protected void tearDown() throws Exception
    {
+      connection.destroy();
+      
       server.stop();
    }
 
@@ -141,6 +145,14 @@
          {
             assertEquals(HornetQException.INCOMPATIBLE_CLIENT_SERVER_VERSIONS, e.getCode());
          }
+         long start = System.currentTimeMillis();
+         while (System.currentTimeMillis() < start + 3 * RemotingServiceImpl.CONNECTION_TTL_CHECK_INTERVAL)
+         {
+            if (server.getConnectionCount() == 0)
+            {
+               break;
+            }
+         }
          // no connection on the server
          assertEquals(0, server.getConnectionCount());
       }



More information about the hornetq-commits mailing list