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

@ -253,12 +253,15 @@ public abstract class MergePolicy {
mergeProgress.setMergeThread(Thread.currentThread());
}
private Exception originalClosed;
/** 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 */
public void mergeFinished(boolean success) throws IOException {
if (mergeCompleted.complete(success) == false) {
throw new IllegalStateException("merge has already finished");
}
mergeCompleted.complete(success);
// 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. */

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 {
try (Directory dir = newDirectory()) {
MergePolicy.MergeSpecification spec = createRandomMergeSpecification(dir, 1);