[jboss-cvs] JBoss Messaging SVN: r6693 - in trunk: src/main/org/jboss/messaging/core/remoting/server/impl and 3 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed May 6 13:22:40 EDT 2009


Author: timfox
Date: 2009-05-06 13:22:40 -0400 (Wed, 06 May 2009)
New Revision: 6693

Modified:
   trunk/src/main/org/jboss/messaging/core/remoting/impl/invm/InVMAcceptor.java
   trunk/src/main/org/jboss/messaging/core/remoting/impl/invm/InVMConnection.java
   trunk/src/main/org/jboss/messaging/core/remoting/impl/invm/InVMConnector.java
   trunk/src/main/org/jboss/messaging/core/remoting/server/impl/RemotingServiceImpl.java
   trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/ConnectionTest.java
   trunk/tests/src/org/jboss/messaging/tests/integration/jms/server/management/JMSServerControlTest.java
   trunk/tests/src/org/jboss/messaging/tests/integration/remoting/SynchronousCloseTest.java
Log:
more fixes

Modified: trunk/src/main/org/jboss/messaging/core/remoting/impl/invm/InVMAcceptor.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/impl/invm/InVMAcceptor.java	2009-05-06 17:14:30 UTC (rev 6692)
+++ trunk/src/main/org/jboss/messaging/core/remoting/impl/invm/InVMAcceptor.java	2009-05-06 17:22:40 UTC (rev 6693)
@@ -208,20 +208,16 @@
       }
 
       public void connectionDestroyed(final Object connectionID)
-      { 
-         //Note! MUST call connection destroyed on the same thread, since server side clearup of connection
-         //resources must be synchronous or client could cause a DoS by opening and closing many connections quickly
-         listener.connectionDestroyed(connectionID);
-         
+      {
          if (connections.remove(connectionID) != null)
-         {            
+         {             
+            listener.connectionDestroyed(connectionID);
+            
             //Execute on different thread to avoid deadlocks
             new Thread()
             {
                public void run()
-               {
-                 // listener.connectionDestroyed(connectionID);
-                  
+               {                                    
                   // Remove on the other side too
                   connector.disconnect((String)connectionID);
                }

Modified: trunk/src/main/org/jboss/messaging/core/remoting/impl/invm/InVMConnection.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/impl/invm/InVMConnection.java	2009-05-06 17:14:30 UTC (rev 6692)
+++ trunk/src/main/org/jboss/messaging/core/remoting/impl/invm/InVMConnection.java	2009-05-06 17:22:40 UTC (rev 6693)
@@ -31,7 +31,6 @@
 import org.jboss.messaging.core.remoting.spi.Connection;
 import org.jboss.messaging.core.remoting.spi.ConnectionLifeCycleListener;
 import org.jboss.messaging.core.remoting.spi.MessagingBuffer;
-import org.jboss.messaging.utils.Future;
 import org.jboss.messaging.utils.UUIDGenerator;
 
 /**
@@ -84,51 +83,24 @@
    }
 
    private volatile boolean closing;
-   
+
    public void close()
-   {      
+   {
       if (closing)
       {
          return;
       }
-      
+
       closing = true;
 
       synchronized (this)
-      {         
-         // Must execute this on the executor, to ensure connection destroyed doesn't get fired before the last DISCONNECT
-         // packet is processed   
-         try
+      {
+         if (!closed)
          {
-            executor.execute(new Runnable()
-            {
-               public void run()
-               {
-                  if (!closed)
-                  {
-//                     log.info("calling listener connection destroyed: " + listener);
-                     listener.connectionDestroyed(id);
-   
-                     closed = true;
-                  }
-               }
-            });
-            
-            Future future = new Future();
-            
-            executor.execute(future);
-            
-            boolean ok = future.await(10000);
-            
-            if (!ok)
-            {
-               log.warn("Timed out waiting to close");
-            }
+            listener.connectionDestroyed(id);
+
+            closed = true;
          }
-         catch (RejectedExecutionException e)
-         {
-            // Ignore - this can happen if server/client is shutdown
-         }
       }
    }
 

Modified: trunk/src/main/org/jboss/messaging/core/remoting/impl/invm/InVMConnector.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/impl/invm/InVMConnector.java	2009-05-06 17:14:30 UTC (rev 6692)
+++ trunk/src/main/org/jboss/messaging/core/remoting/impl/invm/InVMConnector.java	2009-05-06 17:22:40 UTC (rev 6693)
@@ -189,12 +189,11 @@
 
       public void connectionDestroyed(final Object connectionID)
       {
-         // Close the corresponding connection on the other side - this MUST be done on the same thread otherwise
-         // closing won't be synchronous!
-         acceptor.disconnect((String)connectionID);
-         
          if (connections.remove(connectionID) != null)
          {
+            // Close the corresponding connection on the other side
+            acceptor.disconnect((String)connectionID);
+            
             // Execute on different thread to avoid deadlocks
             new Thread()
             {

Modified: trunk/src/main/org/jboss/messaging/core/remoting/server/impl/RemotingServiceImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/server/impl/RemotingServiceImpl.java	2009-05-06 17:14:30 UTC (rev 6692)
+++ trunk/src/main/org/jboss/messaging/core/remoting/server/impl/RemotingServiceImpl.java	2009-05-06 17:22:40 UTC (rev 6693)
@@ -290,7 +290,7 @@
    }
 
    public void connectionDestroyed(final Object connectionID)
-   {       
+   {         
       RemotingConnection conn = connections.get(connectionID);
       
       if (conn != null)

Modified: trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/ConnectionTest.java
===================================================================
--- trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/ConnectionTest.java	2009-05-06 17:14:30 UTC (rev 6692)
+++ trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/ConnectionTest.java	2009-05-06 17:22:40 UTC (rev 6693)
@@ -64,13 +64,6 @@
 
    // Public --------------------------------------------------------
 
-   // Disabled  - http://www.jboss.org/index.html?module=bb&op=viewtopic&t=154603
-//   public void testFoo()
-//   {
-//      
-//   }
-//  
-   
    public void testManyConnections() throws Exception
    {
       for (int i = 0; i < 100; i++)
@@ -280,26 +273,28 @@
     * 
     * This needs to be run remotely to see the exception
     */
-   public void testConnectionListenerBug() throws Exception
-   {
-      for (int i = 0; i < 1000; i++)
-      {
-         log.info("********************************************");
-         
-         Connection conn = cf.createConnection();
-         
-         MyExceptionListener listener = new MyExceptionListener();
-         
-         conn.setExceptionListener(listener);
-         
-         conn.close();        
-         
-         //The problem with this test is I would need to capture the output and search
-         //for NullPointerException!!!    
-         
-         //Thread.sleep(100);
-      } 
-   }
+   
+// This test is currently commented out until we fix netty issue https://jira.jboss.org/jira/browse/JBMESSAGING-1618   
+//   public void testConnectionListenerBug() throws Exception
+//   {
+//      for (int i = 0; i < 1000; i++)
+//      {
+//         log.info("********************************************");
+//         
+//         Connection conn = cf.createConnection();
+//         
+//         MyExceptionListener listener = new MyExceptionListener();
+//         
+//         conn.setExceptionListener(listener);
+//         
+//         conn.close();        
+//         
+//         //The problem with this test is I would need to capture the output and search
+//         //for NullPointerException!!!    
+//         
+//         //Thread.sleep(100);
+//      } 
+//   }
 
    /**
     * This test is similar to a JORAM Test...

Modified: trunk/tests/src/org/jboss/messaging/tests/integration/jms/server/management/JMSServerControlTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/jms/server/management/JMSServerControlTest.java	2009-05-06 17:14:30 UTC (rev 6692)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/jms/server/management/JMSServerControlTest.java	2009-05-06 17:22:40 UTC (rev 6693)
@@ -22,10 +22,6 @@
 
 package org.jboss.messaging.tests.integration.jms.server.management;
 
-import static org.jboss.messaging.tests.util.RandomUtil.randomBoolean;
-import static org.jboss.messaging.tests.util.RandomUtil.randomDouble;
-import static org.jboss.messaging.tests.util.RandomUtil.randomInt;
-import static org.jboss.messaging.tests.util.RandomUtil.randomLong;
 import static org.jboss.messaging.tests.util.RandomUtil.randomString;
 
 import java.util.Map;
@@ -52,7 +48,6 @@
 import org.jboss.messaging.tests.integration.management.ManagementControlHelper;
 import org.jboss.messaging.tests.integration.management.ManagementTestBase;
 import org.jboss.messaging.tests.unit.util.InVMContext;
-import org.jboss.messaging.tests.util.RandomUtil;
 
 /**
  * A JMSServerControlTest

Modified: trunk/tests/src/org/jboss/messaging/tests/integration/remoting/SynchronousCloseTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/remoting/SynchronousCloseTest.java	2009-05-06 17:14:30 UTC (rev 6692)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/remoting/SynchronousCloseTest.java	2009-05-06 17:22:40 UTC (rev 6693)
@@ -45,10 +45,9 @@
 {
 
    // Constants -----------------------------------------------------
-   
+
    private static final Logger log = Logger.getLogger(SynchronousCloseTest.class);
 
-
    // Attributes ----------------------------------------------------
 
    private MessagingServer server;
@@ -81,12 +80,12 @@
 
       super.tearDown();
    }
-   
+
    protected boolean isNetty()
    {
       return false;
    }
-   
+
    protected ClientSessionFactory createSessionFactory()
    {
       ClientSessionFactory sf;
@@ -98,10 +97,10 @@
       {
          sf = new ClientSessionFactoryImpl(new TransportConfiguration(InVMConnectorFactory.class.getName()));
       }
-      
+
       return sf;
    }
-   
+
    /*
     * Server side resources should be cleaned up befor call to close has returned or client could launch
     * DoS attack
@@ -109,24 +108,27 @@
    public void testSynchronousClose() throws Exception
    {
       assertEquals(0, server.getMessagingServerControl().listRemoteAddresses().length);
-      
+
       ClientSessionFactory sf = createSessionFactory();
-      
+
       for (int i = 0; i < 100; i++)
-      {      
+      {
          ClientSession session = sf.createSession(false, true, true);
 
          assertEquals(1, server.getMessagingServerControl().listRemoteAddresses().length);
-             
+
+         log.info("closing session");
          session.close();
+         log.info("closed session");
 
+         // Thread.sleep(10000);
+
          assertEquals(0, server.getMessagingServerControl().listRemoteAddresses().length);
       }
-      
+
       sf.close();
    }
 
-   
    // Private -------------------------------------------------------
 
    // Inner classes -------------------------------------------------




More information about the jboss-cvs-commits mailing list