mirror of https://github.com/apache/activemq.git
https://issues.apache.org/activemq/browse/AMQ-2525 - Prevent broker deadlock if jmxconnector start hangs
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@888367 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
df52a09063
commit
c9ca34a27a
|
@ -70,6 +70,7 @@ public class ManagementContext implements Service {
|
|||
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 @@ public class ManagementContext implements Service {
|
|||
JMXConnectorServer server = connectorServer;
|
||||
if (started.get() && server != null) {
|
||||
LOG.debug("Starting JMXConnectorServer...");
|
||||
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 @@ public class ManagementContext implements Service {
|
|||
connectorServer = null;
|
||||
if (server != null) {
|
||||
try {
|
||||
if (!connectorStarting.get()) {
|
||||
server.stop();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
LOG.warn("Failed to stop jmx connector: " + e.getMessage());
|
||||
}
|
||||
|
@ -217,7 +225,7 @@ public class ManagementContext implements Service {
|
|||
}
|
||||
|
||||
public boolean isConnectorStarted() {
|
||||
return connectorServer != null && connectorServer.isActive();
|
||||
return connectorStarting.get() || (connectorServer != null && connectorServer.isActive());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue