error handling when stopdaemon is called

This commit is contained in:
Maxim Muzafarov 2026-07-11 13:46:46 +02:00
parent a0e0598c10
commit 1947c9bb58
No known key found for this signature in database
GPG Key ID: 7FEC714D84388C16
1 changed files with 15 additions and 5 deletions

View File

@ -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();
}
}