activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dej...@apache.org
Subject svn commit: r888367 - /activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/ManagementContext.java
Date Tue, 08 Dec 2009 12:22:25 GMT
Author: dejanb
Date: Tue Dec  8 12:22:24 2009
New Revision: 888367

URL: http://svn.apache.org/viewvc?rev=888367&view=rev
Log:
https://issues.apache.org/activemq/browse/AMQ-2525 - Prevent broker deadlock if jmxconnector
start hangs

Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/ManagementContext.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/ManagementContext.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/ManagementContext.java?rev=888367&r1=888366&r2=888367&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/ManagementContext.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/ManagementContext.java
Tue Dec  8 12:22:24 2009
@@ -70,6 +70,7 @@
     private int rmiServerPort;
     private String connectorPath = "/jmxrmi";
     private AtomicBoolean started = new AtomicBoolean(false);
+    private AtomicBoolean connectorStarting = new AtomicBoolean(false);
     private JMXConnectorServer connectorServer;
     private ObjectName namingServiceObjectName;
     private Registry registry;
@@ -98,7 +99,12 @@
                             JMXConnectorServer server = connectorServer;
                             if (started.get() && server != null) {
                                 LOG.debug("Starting JMXConnectorServer...");
-                                server.start();
+                                connectorStarting.set(true);
+                                try {
+                                	server.start();
+                                } finally {
+                                	connectorStarting.set(false);
+                                }
                                 LOG.info("JMX consoles can connect to " + server.getAddress());
                             }
                         } catch (IOException e) {
@@ -129,7 +135,9 @@
             connectorServer = null;
             if (server != null) {
                 try {
-                    server.stop();
+                	if (!connectorStarting.get()) {
+                		server.stop();
+                	}
                 } catch (IOException e) {
                     LOG.warn("Failed to stop jmx connector: " + e.getMessage());
                 }
@@ -217,7 +225,7 @@
     }
 
     public boolean isConnectorStarted() {
-		return connectorServer != null && connectorServer.isActive();
+		return connectorStarting.get() || (connectorServer != null && connectorServer.isActive());
 	}
 
 	/**



Mime
View raw message