Skip to content

DirectoryProcessor catches InterruptedException without restoring interrupt flag — silent thread-pool shutdown breakage #5877

Description

@tsushanth

Bug description

sentry/src/main/java/io/sentry/DirectoryProcessor.java lines 94–96 catch Throwable in the outer try-catch, which swallows InterruptedException without restoring the interrupt flag:

} catch (Throwable e) {
  options.getLogger().log(SentryLevel.ERROR, "Failed to process directory.", e);
  // InterruptedException reaches here — interrupt flag is cleared and never restored
}

When the enclosing thread pool calls shutdownNow(), the worker thread's interrupt is set, but processDirectory() catches and discards it. The thread continues running, the pool's awaitTermination() never unblocks, and shutdown silently hangs.

Fix

Restore the interrupt flag when the caught exception is an InterruptedException:

} catch (Throwable e) {
  options.getLogger().log(SentryLevel.ERROR, "Failed to process directory.", e);
  if (e instanceof InterruptedException) {
    Thread.currentThread().interrupt();
  }
}

Environment

  • Verified against current main branch

Metadata

Metadata

Assignees

No one assigned

    Projects

    Status
    Waiting for: Product Owner

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions