apache / apache/lucene

Wherever we catch & suppress Throwable we should not suppress ThreadInterruptedException [LUCENE-3150]

Open
#4,223 5 comments 0 reactions 0 assignees View on GitHub
legacy-jira-fix-version:4.9 legacy-jira-fix-version:6.0 legacy-jira-priority:Minor type:bug
Dominant language
Java
Stars
3.6k
Forks
1.4k
Avg merge
2d 11h
Merged PRs (30d)
88

Description

In various places we catch Throwable and suppress it, usually in exception handlers where we want to just throw the first exc we had hit.

But this is dangerous for a thread interrupt since it means we can swallow & ignore the interrupt.

We should at least catch the interrupt & restore the interrupt bit, if we can't rethrow it.

One example is in SegmentInfos where we write the segments.gen file... there are many other examples in SegmentInfos too.

---
Migrated from [LUCENE-3150](https://issues.apache.org/jira/browse/LUCENE-3150) by Michael McCandless (@mikemccand), updated May 09 2016
Attachments: [LUCENE-3150.patch](https://apache.github.io/lucene-jira-archive/attachments/LUCENE-3150/LUCENE-3150.patch)

Contributor guide

Open the contributing guide

Research direction

Start by reviewing the Throwable handlers in SegmentInfos, especially the code that writes the segments.gen file, then search for the other handlers described in the issue. Check how ThreadInterruptedException is handled and preserve the thread's interrupt status when it cannot be rethrown. Done means suppressed interrupts are no longer swallowed across the identified cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend, search
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.