This is an automated email from the ASF dual-hosted git repository.
mmerli pushed a commit to branch branch-4.17
in repository https://gitbox.apache.org/repos/asf/bookkeeper.git
The following commit(s) were added to refs/heads/branch-4.17 by this push:
new 06726e1a52 [FIX] Fix IllegalThreadStateException in ComponentStarter
shutdown hook (#4733)
06726e1a52 is described below
commit 06726e1a52ffa7bba99e0d433eef2b570308a078
Author: Matteo Merli <[email protected]>
AuthorDate: Thu Mar 26 17:45:12 2026 -0700
[FIX] Fix IllegalThreadStateException in ComponentStarter shutdown hook
(#4733)
The UncaughtExceptionHandler in ComponentStarter calls
shutdownHookThread.start(), but this can throw IllegalThreadStateException
if the thread was already started by a prior exception or by the JVM
shutdown sequence. This exception propagates out of the handler, causing
the JVM to print "Exception thrown from the UncaughtExceptionHandler"
on the BookieDeathWatcher thread.
Catch IllegalThreadStateException since it simply means shutdown is
already in progress.
---
.../org/apache/bookkeeper/common/component/ComponentStarter.java | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git
a/bookkeeper-common/src/main/java/org/apache/bookkeeper/common/component/ComponentStarter.java
b/bookkeeper-common/src/main/java/org/apache/bookkeeper/common/component/ComponentStarter.java
index 3b44d67edb..44128b9cd3 100644
---
a/bookkeeper-common/src/main/java/org/apache/bookkeeper/common/component/ComponentStarter.java
+++
b/bookkeeper-common/src/main/java/org/apache/bookkeeper/common/component/ComponentStarter.java
@@ -75,7 +75,12 @@ public class ComponentStarter {
log.error("Triggered exceptionHandler of Component: {} because of
Exception in Thread: {}",
component.getName(), t, e);
// start the shutdown hook when an uncaught exception happen in
the lifecycle component.
- shutdownHookThread.start();
+ try {
+ shutdownHookThread.start();
+ } catch (IllegalThreadStateException ise) {
+ // the shutdown hook thread is already running (e.g. triggered
by a prior
+ // exception or by the JVM shutdown sequence), so there is
nothing else to do.
+ }
});
component.publishInfo(new ComponentInfoPublisher());