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/08/12 20:22:12 UTC

svn commit: r803651 - /qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/ManagementActor.java

Author: ritchiem
Date: Wed Aug 12 18:22:11 2009
New Revision: 803651

URL: http://svn.apache.org/viewvc?rev=803651&view=rev
Log:
QPID-2002 : Defensive update incase the thread name is not as expected. In all production environments it has shown to be but as the other tests highlight it will fail if the name is not as expected. Better to be defensive that just broken.

Modified:
    qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/ManagementActor.java

Modified: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/ManagementActor.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/ManagementActor.java?rev=803651&r1=803650&r2=803651&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/ManagementActor.java (original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/ManagementActor.java Wed Aug 12 18:22:11 2009
@@ -64,21 +64,40 @@
     {
         String currentName = Thread.currentThread().getName();
 
+        String actor;
         // Record the last thread name so we don't have to recreate the log string
         if (!currentName.equals(_lastThreadName))
         {
             _lastThreadName = currentName;
 
-            System.err.println(currentName);
-            // Management Threads have this format.
+            // Management Thread names have this format.
             //RMI TCP Connection(2)-169.24.29.116
-            String connectionID = currentName.split("\\(")[1].split("\\)")[0];
-            String ip = currentName.split("-")[1];
+            // This is true for both LocalAPI and JMX Connections
+            // However to be defensive lets test.
+
+            String[] split = currentName.split("\\(");
+            if (split.length == 2)
+            {
+                String connectionID = split[1].split("\\)")[0];
+                String ip = currentName.split("-")[1];
+
+                actor = MessageFormat.format(MANAGEMENT_FORMAT,
+                                             connectionID,
+                                             ip);
+            }
+            else
+            {
+                // This is a precautionary path as it is not expected to occur
+                // however rather than adjusting the thread name of the two
+                // tests that will use this it is safer all round to do this.
+                // it is also currently used by tests :
+                // AMQBrokerManagerMBeanTest
+                // ExchangeMBeanTest
+                actor = currentName;
+            }
+
+            _logString = "[" + actor + "] ";
 
-            _logString = "[" + MessageFormat.format(MANAGEMENT_FORMAT,
-                                                    connectionID,
-                                                    ip)
-                         + "] ";
         }
     }
 



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