docs/bugpattern/InterruptedInCatchBlock.md
When attempting to fail-fast when interrupted, you should preserve the
interrupted status of the thread by calling
Thread.currentThread().interrupt():
try {
mightTimeOutOrBeCancelled(); // for example myFuture.get()
} catch (InterruptedException e) {
Thread.currentThread().interrupt(); // Restore the interrupted status
throw new MyCheckedException("[describe what task was interrupted]", e);
}
The current code is likely accidentally calling Thread.interrupted(), which
clears the interrupt bit. (That is typically a no-op in this situation because
the interrupt bit is generally already unset when InterruptedException has
been thrown.) thread.interrupt() correctly restores the interrupt bit.
More information: