apache/pulsar · warning · java.lang.RuntimeException
${e}
Error message
${e} What it means
shutdown() performs a forced, non-graceful teardown by delegating to the v4 client's shutdown(); if that throws org.apache.pulsar.client.api.PulsarClientException, it is wrapped in a plain java.lang.RuntimeException whose message is the exception's toString (the class name plus message). This signals the shutdown path itself failed and the JVM-level cleanup did not complete cleanly.
Source
Thrown at pulsar-client-v5/src/main/java/org/apache/pulsar/client/impl/v5/PulsarClientV5.java:122
v4Client.close();
} catch (org.apache.pulsar.client.api.PulsarClientException e) {
throw new PulsarClientException(e.getMessage(), e);
}
}
@Override
public CompletableFuture<Void> closeAsync() {
return v4Client.closeAsync().exceptionally(ex -> {
throw new CompletionException(new PulsarClientException(ex.getMessage(), ex));
});
}
@Override
public void shutdown() {
try {
v4Client.shutdown();
} catch (org.apache.pulsar.client.api.PulsarClientException e) {
throw new RuntimeException(e);
}
}
}
View on GitHub (pinned to 820761864e)
Solutions
- Read the wrapped RuntimeException's cause (the PulsarClientException) for the root failure
- Reorder lifecycle: call shutdown() only once and only after producers/consumers are stopped
- If the cause is benign (already closed), guard the call with a closed flag or catch-and-log
Example fix
// before
client.shutdown(); // raw RuntimeException on failure
// after
try {
client.shutdown();
} catch (RuntimeException e) {
log.warn("Shutdown failed", e.getCause());
} Defensive patterns
Strategy: try-catch
Validate before calling
if (clientShutdown) return; // guard with your own lifecycle flag
Try / catch
try {
client.shutdown();
} catch (RuntimeException e) {
log.warn("Shutdown failed: {}", e.getCause());
} Prevention
- Call shutdown() once, after all producers/consumers are stopped
- Never call shutdown() after close() on the same client
- In JVM shutdown hooks, catch-and-log RuntimeException from shutdown rather than crashing
When it happens
Trigger: Calling PulsarClientV5.shutdown() when the underlying v4 client's shutdown throws — e.g. I/O failures closing connections, or internal state indicating the client is already shut down.
Common situations: Shutdown hooks / JVM exit paths calling shutdown() during a network outage; calling shutdown() after close() (double teardown); container termination sequences where the broker is already gone.
Related errors
- Executor %s should have been shutdown before entering the te
- ProducerCache is already closed
- Timeout during managed ledger close
- ManagedLedgerFactory is already closed.
- ManagedLedger ${name} has already been closed
AI-assisted analysis of apache/pulsar@820761864e (2026-09-06).
Data as JSON: /api/errors/5e048d83cd9854d4.
Report an issue: GitHub.