apache/cassandra · warning · CloseException

Failed to close JMX connection

Error message

Failed to close JMX connection

What it means

JmxConnectionCommandInvoker.close() attempts to close the probe's AutoCloseable resource; any exception while closing is wrapped in CloseException('Failed to close JMX connection'). This typically indicates the underlying JMX connector was already dead or torn down.

Source

Thrown at src/java/org/apache/cassandra/tools/nodetool/JmxConnect.java:219

                AbstractCommand command = (AbstractCommand) lastParent.userObject();
                if (command.shouldConnect())
                    connect.run();
                command.probe(connect.probe());
            }
            return new RunLast().execute(parseResult);
        }

        @Override
        public void close() throws CloseException
        {
            try
            {
                if (connect.probe() != null)
                    ((AutoCloseable) connect.probe()).close();
            }
            catch (Exception e)
            {
                throw new CloseException("Failed to close JMX connection", e);
            }
        }

        private static CommandLine.Model.CommandSpec lastExecutableSubcommandWithSameParent(List<CommandLine> parsedCommands)
        {
            int start = parsedCommands.size() - 1;
            for (int i = parsedCommands.size() - 2; i >= 0; i--)
            {
                if (parsedCommands.get(i).getParent() != parsedCommands.get(i + 1).getParent())
                    break;
                start = i;
            }
            return parsedCommands.get(start).getCommandSpec();
        }

        private static class CloseException extends RuntimeException
        {
            public CloseException(String message, Throwable cause)

View on GitHub (pinned to 88fd0f6a0e)

Solutions

  1. Check node liveness/network stability during the command; retry the command
  2. Inspect the cause chain (CloseException's cause) for the underlying close error
  3. This usually follows an earlier connection failure — fix connectivity first

Example fix

// before
invoker.execute(parseResult); // CloseException propagates
// after
try { invoker.execute(parseResult); }
catch (JmxConnectionCommandInvoker.CloseException e) { e.getCause().printStackTrace(); }
Defensive patterns

Strategy: try-catch

Try / catch

try { invoker.execute(parseResult); } catch (JmxConnectionCommandInvoker.CloseException e) { log.warn("close failed", e.getCause()); /* non-fatal; connection already gone */ }

Prevention

When it happens

Trigger: JMX server dropped mid-session so closing the connector throws IOException; the MBean server connection is stale; remote JVM terminated before close.

Common situations: Long-running jmx command where the node restarted; network interruption during command execution; node shutdown racing with nodetool completion.

Related errors


AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10). Data as JSON: /api/errors/9cb55d3b01a3f565. Report an issue: GitHub.