LUCENE-9408: roll back only called once enforcement

This commit is contained in:
Simon Willnauer 2020-06-17 23:27:39 +02:00
parent 59efe22ac2
commit 9524cc4233
2 changed files with 8 additions and 4 deletions

View File

@ -252,13 +252,16 @@ public abstract class MergePolicy {
public void mergeInit() throws IOException { public void mergeInit() throws IOException {
mergeProgress.setMergeThread(Thread.currentThread()); mergeProgress.setMergeThread(Thread.currentThread());
} }
private Exception originalClosed;
/** Called by {@link IndexWriter} after the merge is done and all readers have been closed. /** Called by {@link IndexWriter} after the merge is done and all readers have been closed.
* @param success true iff the merge finished successfully ie. was committed */ * @param success true iff the merge finished successfully ie. was committed */
public void mergeFinished(boolean success) throws IOException { public void mergeFinished(boolean success) throws IOException {
if (mergeCompleted.complete(success) == false) { mergeCompleted.complete(success);
throw new IllegalStateException("merge has already finished"); // https://issues.apache.org/jira/browse/LUCENE-9408
} // if (mergeCompleted.complete(success) == false) {
// throw new IllegalStateException("merge has already finished", originalClosed);
// }
} }
/** Wrap the reader in order to add/remove information to the merged segment. */ /** Wrap the reader in order to add/remove information to the merged segment. */

View File

@ -110,6 +110,7 @@ public class TestMergePolicy extends LuceneTestCase {
} }
} }
@AwaitsFix(bugUrl = "https://issues.apache.org/jira/browse/LUCENE-9408")
public void testFinishTwice() throws IOException { public void testFinishTwice() throws IOException {
try (Directory dir = newDirectory()) { try (Directory dir = newDirectory()) {
MergePolicy.MergeSpecification spec = createRandomMergeSpecification(dir, 1); MergePolicy.MergeSpecification spec = createRandomMergeSpecification(dir, 1);