lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r636046 - in /lucene/java/branches/lucene_2_3: CHANGES.txt src/java/org/apache/lucene/index/IndexWriter.java src/test/org/apache/lucene/index/TestIndexWriter.java
Date Tue, 11 Mar 2008 18:17:33 GMT
Author: mikemccand
Date: Tue Mar 11 11:17:28 2008
New Revision: 636046

URL: http://svn.apache.org/viewvc?rev=636046&view=rev
Log:
LUCENE-1222: make sure IW.doAfterFlush is called regardless of whether adds or deletes are
flushed

Modified:
    lucene/java/branches/lucene_2_3/CHANGES.txt
    lucene/java/branches/lucene_2_3/src/java/org/apache/lucene/index/IndexWriter.java
    lucene/java/branches/lucene_2_3/src/test/org/apache/lucene/index/TestIndexWriter.java

Modified: lucene/java/branches/lucene_2_3/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_2_3/CHANGES.txt?rev=636046&r1=636045&r2=636046&view=diff
==============================================================================
--- lucene/java/branches/lucene_2_3/CHANGES.txt (original)
+++ lucene/java/branches/lucene_2_3/CHANGES.txt Tue Mar 11 11:17:28 2008
@@ -25,6 +25,9 @@
  7. LUCENE-1210: Fix deadlock case on hitting an exception while
     starting a merge when using ConcurrentMergeScheduler (Mike McCandless)
 
+ 8. LUCENE-1222: Fix IndexWriter.doAfterFlush to always be called on
+    flush (Mark Ferguson via Mike McCandless)
+
 ======================= Release 2.3.1 2008-02-22 =======================
 
 Bug fixes

Modified: lucene/java/branches/lucene_2_3/src/java/org/apache/lucene/index/IndexWriter.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_2_3/src/java/org/apache/lucene/index/IndexWriter.java?rev=636046&r1=636045&r2=636046&view=diff
==============================================================================
--- lucene/java/branches/lucene_2_3/src/java/org/apache/lucene/index/IndexWriter.java (original)
+++ lucene/java/branches/lucene_2_3/src/java/org/apache/lucene/index/IndexWriter.java Tue
Mar 11 11:17:28 2008
@@ -2610,14 +2610,14 @@
             segmentInfos.addElement(newSegment);
           }
 
-          if (flushDeletes) {
+          if (flushDeletes)
             // we should be able to change this so we can
             // buffer deletes longer and then flush them to
             // multiple flushed segments, when
             // autoCommit=false
             applyDeletes(flushDocs);
-            doAfterFlush();
-          }
+
+          doAfterFlush();
 
           checkpoint();
           success = true;

Modified: lucene/java/branches/lucene_2_3/src/test/org/apache/lucene/index/TestIndexWriter.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_2_3/src/test/org/apache/lucene/index/TestIndexWriter.java?rev=636046&r1=636045&r2=636046&view=diff
==============================================================================
--- lucene/java/branches/lucene_2_3/src/test/org/apache/lucene/index/TestIndexWriter.java
(original)
+++ lucene/java/branches/lucene_2_3/src/test/org/apache/lucene/index/TestIndexWriter.java
Tue Mar 11 11:17:28 2008
@@ -2954,4 +2954,40 @@
     w.close();
     dir.close();
   }
+
+  public class MockIndexWriter3 extends IndexWriter {
+
+    public MockIndexWriter3(Directory dir, boolean autoCommit, Analyzer a, boolean create)
throws IOException {
+      super(dir, autoCommit, a, create);
+    }
+
+    boolean wasCalled;
+
+    public void doAfterFlush() {
+      wasCalled = true;
+    }
+  }
+
+  // LUCENE-1222
+  public void testDoAfterFlush() throws IOException {
+    MockRAMDirectory dir = new MockRAMDirectory();
+    MockIndexWriter3 w = new MockIndexWriter3(dir, false, new WhitespaceAnalyzer(), true);
+    Document doc = new Document();
+    doc.add(new Field("field", "a field", Field.Store.YES,
+                      Field.Index.TOKENIZED));
+    w.addDocument(doc);
+    w.flush();
+    assertTrue(w.wasCalled);
+    w.wasCalled = true;
+    w.deleteDocuments(new Term("field", "field"));
+    w.flush();
+    assertTrue(w.wasCalled);
+    w.close();
+    dir.close();
+
+    IndexReader ir = IndexReader.open(dir);
+    assertEquals(1, ir.maxDoc());
+    assertEquals(0, ir.numDocs());
+    ir.close();
+  }
 }



Mime
View raw message