diff options
| author | Martin Ritchie <ritchiem@apache.org> | 2009-08-12 18:22:11 +0000 |
|---|---|---|
| committer | Martin Ritchie <ritchiem@apache.org> | 2009-08-12 18:22:11 +0000 |
| commit | 372d1139c830d8d74fa64287853048d41fe0a818 (patch) | |
| tree | 67cfd0127fbd1cb7aeb2ac9caebfb0ce2424824d /java | |
| parent | 4bf8623e418945618f9faadf9f5299028782c962 (diff) | |
| download | qpid-python-372d1139c830d8d74fa64287853048d41fe0a818.tar.gz | |
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.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@803651 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java')
| -rw-r--r-- | java/broker/src/main/java/org/apache/qpid/server/logging/actors/ManagementActor.java | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/java/broker/src/main/java/org/apache/qpid/server/logging/actors/ManagementActor.java b/java/broker/src/main/java/org/apache/qpid/server/logging/actors/ManagementActor.java index 2ad0f69fd6..85fbb8f1ac 100644 --- a/java/broker/src/main/java/org/apache/qpid/server/logging/actors/ManagementActor.java +++ b/java/broker/src/main/java/org/apache/qpid/server/logging/actors/ManagementActor.java @@ -64,21 +64,40 @@ public class ManagementActor extends AbstractActor { 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) - + "] "; } } |
