diff --git a/src/java/org/apache/cassandra/tools/RemoteJmxMBeanAccessor.java b/src/java/org/apache/cassandra/tools/RemoteJmxMBeanAccessor.java index 0ce92b2b86..6891b85fdb 100644 --- a/src/java/org/apache/cassandra/tools/RemoteJmxMBeanAccessor.java +++ b/src/java/org/apache/cassandra/tools/RemoteJmxMBeanAccessor.java @@ -22,6 +22,7 @@ import java.io.IOException; import java.lang.management.ManagementFactory; import java.lang.management.MemoryMXBean; import java.lang.management.RuntimeMXBean; +import java.rmi.ConnectException; import java.rmi.server.RMIClientSocketFactory; import java.rmi.server.RMISocketFactory; import java.util.AbstractMap; @@ -415,14 +416,23 @@ public class RemoteJmxMBeanAccessor implements MBeanAccessor try { jmxc.close(); - jmxc = null; - mbeanServerConn = null; - connected = false; + } + catch (ConnectException e) + { + // result of stopdaemon command, if close() call fails, the daemon is shutdown + logger.error("Cassandra has shutdown."); } catch (IOException e) { - // result of 'stopdaemon' command - i.e. if close() call fails, the daemon is shutdown - logger.error("Cassandra has shutdown."); + logger.error("Failed to close connection to '{}:{}'.", host, port, e); + } + finally + { + jmxc = null; + mbeanServerConn = null; + connected = false; + clazzMBanRegistry.clear(); + namedMBeanRegistry.clear(); } }