Port LUCENE-5654 from Lucene 4.8.1, #1381#1424
Draft
paulirwin wants to merge 16 commits into
Draft
Conversation
Some work already done; others deferred for issue apache#1381 batch 5.
…oming in batch 5)
Only including the PulseAll in this change; the rest will be in batch 5)
19 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Port LUCENE-5654 from Lucene 4.8.1
Partial #1381 (Batch 5)
Description
DO NOT MERGE: This PR is a stacked PR on #1413. Do not merge until that is merged.
This ports LUCENE-5654 which cleans up the suppressed exceptions on various close/dispose calls. The original changelog message in Java was: "Fix various close() methods that could suppress throwables such as OutOfMemoryError, instead returning scary messages that look like index corruption."
This also ports the rest of the Cranky codec suite, and adds some tests.
DRAFT NOTE: I am still working on TestIndexWriterOutOfMemory (commit 15b41abcc) and TestIndexWriterThreadsToSegments (commit 02163a83f).
For the close changes, we can't use
usingwhich is the .NET equivalent of Java's try-with-resources, because we made the decision to make TokenStreamICloseableinstead ofIDisposableso that it semantically can be "reopened." So this retains atry/finallybut removes thecatch/suppression.Note that this has a slight potential difference in behavior from Java in the event that
Close()throws when the body also throws. However, even switching tousing/IDisposablewould not solve this:usingNote that this PR is the most faithful to upstream, so I think it's worth considering the merit of not changing this. However, we could change this in a few different ways:
IOUtils.CloseWhileHandlingException(...)instead of.Close(). This would result in "A propagates, B lost" which is very close to the original behavior, just with losing B. I doubt much other than logging code actually inspects those suppressed exceptions in the real world (and nothing does in Lucene)..AsDisposable()method toTokenStreamso that we can wrap it in ausingblock/statement. This makes the code more closely match Java's try-with-resources, but as you can see above it doesn't help the exception behavior.successlogic. This would create a significant deviation from upstream at every callsite, with more to maintain. But it would let us match Java's logic.So my first choice would be option 4 (leave as-is), with option 1 (change to
CloseWhileHandlingException) as an acceptable alternative.Also note that I had to slightly change the TestIndexWriterOnJRECrash change from #1292 to not use the now-removed priorException overload.
Breaking change notice: this is a breaking change because the IOUtils method is being removed.