Skip to content

Apache Lucene open-source search software

LUCENE-2610: addIndexes(Directory...) should not trigger merge on flush()

Shai Ererad5266943147a
diff --git a/lucene/src/java/org/apache/lucene/index/IndexWriter.java b/lucene/src/java/org/apache/lucene/index/IndexWriter.java
index 5c771b5ec91..ca6923c3889 100644
--- a/lucene/src/java/org/apache/lucene/index/IndexWriter.java
+++ b/lucene/src/java/org/apache/lucene/index/IndexWriter.java
@@ -2870,7 +2870,7 @@ public class IndexWriter implements Closeable {
try {
if (infoStream != null)
message("flush at addIndexes(Directory...)");
- flush(true, false, true);
+ flush(false, false, true);
int docCount = 0;
List<SegmentInfo> infos = new ArrayList<SegmentInfo>();
diff --git a/lucene/src/test/org/apache/lucene/index/TestSnapshotDeletionPolicy.java b/lucene/src/test/org/apache/lucene/index/TestSnapshotDeletionPolicy.java
index c47756fb7e5..58948e5b023 100644
--- a/lucene/src/test/org/apache/lucene/index/TestSnapshotDeletionPolicy.java
+++ b/lucene/src/test/org/apache/lucene/index/TestSnapshotDeletionPolicy.java
@@ -327,6 +327,7 @@ public class TestSnapshotDeletionPolicy extends LuceneTestCaseJ4 {
writer.commit();
writer.deleteUnusedFiles();
assertSnapshotExists(dir, sdp, numSnapshots - 1);
+ writer.close();
// but 'snapshot1' files will still exist (need to release snapshot before they can be deleted).
String segFileName = sdp.getSnapshot("snapshot1").getSegmentsFileName();
@@ -358,6 +359,7 @@ public class TestSnapshotDeletionPolicy extends LuceneTestCaseJ4 {
}
assertNull(sdp.getSnapshots().get(snapId));
writer.deleteUnusedFiles();
+ writer.close();
assertFalse("segments file should not be found in dirctory: " + segFileName, dir.fileExists(segFileName));
dir.close();
}