You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ri...@apache.org on 2009/09/01 13:47:14 UTC

svn commit: r809981 - /qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/ManagementActorLoggingTest.java

Author: ritchiem
Date: Tue Sep  1 11:47:14 2009
New Revision: 809981

URL: http://svn.apache.org/viewvc?rev=809981&view=rev
Log:
QPID-2077 : The problem with the tearDown is that we still have a race condition when a control thread trys to close the connection at the same time as the exception handling thread is also closing the connection.

Solution here is to wait for the exception handling thread to have done enough to mark the connnection closed so the race condition will not occur.

Modified:
    qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/ManagementActorLoggingTest.java

Modified: qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/ManagementActorLoggingTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/ManagementActorLoggingTest.java?rev=809981&r1=809980&r2=809981&view=diff
==============================================================================
--- qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/ManagementActorLoggingTest.java (original)
+++ qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/ManagementActorLoggingTest.java Tue Sep  1 11:47:14 2009
@@ -29,6 +29,8 @@
 import org.apache.qpid.server.logging.subjects.AbstractTestLogSubject;
 
 import javax.jms.Connection;
+import javax.jms.ExceptionListener;
+import javax.jms.JMSException;
 import javax.management.JMException;
 import javax.management.MBeanException;
 import javax.management.MBeanServerConnection;
@@ -38,6 +40,8 @@
 import java.io.IOException;
 import java.util.List;
 import java.util.Set;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
 
 /**
  * Test class to test if any change in the broker JMX code is affesting the management console
@@ -161,6 +165,23 @@
             //Create a connection to the broker
             Connection connection = getConnection();
 
+            // Monitor the connection for an exception being thrown
+            // this should be a DisconnectionException but it is not this tests
+            // job to valiate that. Only use the exception as a synchronisation
+            // to check the log file for the Close message
+            final CountDownLatch exceptionReceived = new CountDownLatch(1);
+            connection.setExceptionListener(new ExceptionListener()
+            {
+                public void onException(JMSException e)
+                {
+                    //Failover being attempted.
+                    exceptionReceived.countDown();
+                }
+            });
+
+            //Remove the connection close from any 0-10 connections
+            _monitor.reset();
+
             // Get all active AMQP connections
             AllObjects allObject = new AllObjects(_mbsc);
             allObject.querystring = "org.apache.qpid:type=VirtualHost.Connection,*";
@@ -175,16 +196,17 @@
                     newProxyInstance(_mbsc, connectionName,
                                      ManagedConnection.class, false);
 
-            //Remove the connection close from any 0-10 connections 
-           _monitor.reset();
 
             //Close the connection
             mangedConnection.closeConnection();
 
+            //Wait for the connection to close
+            assertTrue("Timed out waiting for conneciton to report close",
+                       exceptionReceived.await(2, TimeUnit.SECONDS));
+
             //Validate results
             List<String> results = _monitor.findMatches("CON-1002");
 
-
             assertEquals("Unexpected Connection Close count", 1, results.size());
         }
     }



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org