Skip to content

fix: restore thread interrupt status after catching InterruptedException - #1018

Open
Zjianru wants to merge 1 commit into
qos-ch:masterfrom
Zjianru:fix/interrupt-status-restoration
Open

fix: restore thread interrupt status after catching InterruptedException#1018
Zjianru wants to merge 1 commit into
qos-ch:masterfrom
Zjianru:fix/interrupt-status-restoration

Conversation

@Zjianru

@Zjianru Zjianru commented Feb 11, 2026

Copy link
Copy Markdown

Fixes #998

Logback catches InterruptedException without re-interrupting the thread, which can cause caller threads to lose their interruption status and potentially deadlock.

This PR adds Thread.currentThread().interrupt() in all catch (InterruptedException) blocks found in production code (and example code for consistency).

Changes

  • AbstractSocketAppender.append() and .connectSocketAndispatchEvents()
  • ConcurrentServerRunner.run()
  • AsyncAppenderBase.Worker.run()
  • DefaultShutdownHook.run()
  • Example classes (ConsolePluginClient, NumberCruncherServer)

Testing

  • All existing tests pass (logback-core module).
  • The fix follows the standard Java concurrency practice described in Java Concurrency in Practice.

Impact

Low risk: only adds interrupt restoration without altering existing logic.

This addresses issue qos-ch#998 where Logback catches InterruptedException
without re-interrupting the thread, potentially causing caller threads
to lose their interruption status.

Changes:
- AbstractSocketAppender.append() and .connectSocketAndDispatchEvents()
- ConcurrentServerRunner.run()
- AsyncAppenderBase.Worker.run()
- DefaultShutdownHook.run()
- Example classes (ConsolePluginClient, NumberCruncherServer)

Also clears any prior interrupt in AsyncAppenderBaseTest to ensure
test stability.

All existing tests pass.

Signed-off-by: codez <codezhujr@gmail.com>
@Zjianru
Zjianru force-pushed the fix/interrupt-status-restoration branch from b2352b8 to 1f9e217 Compare February 11, 2026 11:37
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.

Logback catching InterruptedException without re-interrupting the thread

1 participant