Skip to content

[FIX] Fix IllegalThreadStateException in ComponentStarter shutdown hook#4733

Merged
merlimat merged 1 commit intomasterfrom
fix-illegal-thread-state-shutdown
Mar 27, 2026
Merged

[FIX] Fix IllegalThreadStateException in ComponentStarter shutdown hook#4733
merlimat merged 1 commit intomasterfrom
fix-illegal-thread-state-shutdown

Conversation

@merlimat
Copy link
Copy Markdown
Contributor

Summary

  • The UncaughtExceptionHandler in ComponentStarter calls shutdownHookThread.start(), which throws IllegalThreadStateException if the thread was already started (by a prior exception or the JVM shutdown sequence)
  • This causes the JVM to print Exception: java.lang.IllegalThreadStateException thrown from the UncaughtExceptionHandler in thread "BookieDeathWatcher-<port>"
  • Fix: catch IllegalThreadStateException since it simply means shutdown is already in progress

Test plan

  • Verify the exception no longer appears when shutting down a bookie server
  • Existing unit tests pass

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.
@merlimat merlimat requested review from hangc0276 and lhotari March 24, 2026 20:54
@merlimat merlimat merged commit 6dc5925 into master Mar 27, 2026
77 of 85 checks passed
@merlimat merlimat deleted the fix-illegal-thread-state-shutdown branch March 27, 2026 00:45
merlimat added a commit that referenced this pull request Mar 27, 2026
…ok (#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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants