lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r1585759 [3/9] - in /lucene/dev/trunk: lucene/ lucene/analysis/common/src/test/org/apache/lucene/analysis/core/ lucene/analysis/common/src/test/org/apache/lucene/analysis/miscellaneous/ lucene/analysis/common/src/test/org/apache/lucene/anal...
Date Tue, 08 Apr 2014 15:34:58 GMT
Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestDirectoryReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestDirectoryReader.java?rev=1585759&r1=1585758&r2=1585759&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestDirectoryReader.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestDirectoryReader.java Tue Apr  8 15:34:50 2014
@@ -133,7 +133,7 @@ public class TestDirectoryReader extends
     Document doc = new Document();
     doc.add(newTextField("body", s, Field.Store.NO));
     iw.addDocument(doc);
-    iw.close();
+    iw.shutdown();
   }
   
   public void testIsCurrent() throws Exception {
@@ -141,7 +141,7 @@ public class TestDirectoryReader extends
     IndexWriter writer = new IndexWriter(d, newIndexWriterConfig( 
       TEST_VERSION_CURRENT, new MockAnalyzer(random())));
     addDocumentWithFields(writer);
-    writer.close();
+    writer.shutdown();
     // set up reader:
     DirectoryReader reader = DirectoryReader.open(d);
     assertTrue(reader.isCurrent());
@@ -149,13 +149,13 @@ public class TestDirectoryReader extends
     writer = new IndexWriter(d, newIndexWriterConfig(TEST_VERSION_CURRENT,
         new MockAnalyzer(random())).setOpenMode(OpenMode.APPEND));
     addDocumentWithFields(writer);
-    writer.close();
+    writer.shutdown();
     assertFalse(reader.isCurrent());
     // re-create index:
     writer = new IndexWriter(d, newIndexWriterConfig(TEST_VERSION_CURRENT,
         new MockAnalyzer(random())).setOpenMode(OpenMode.CREATE));
     addDocumentWithFields(writer);
-    writer.close();
+    writer.shutdown();
     assertFalse(reader.isCurrent());
     reader.close();
     d.close();
@@ -184,7 +184,7 @@ public class TestDirectoryReader extends
       doc.add(new TextField("unstored","test1", Field.Store.NO));
       writer.addDocument(doc);
 
-      writer.close();
+      writer.shutdown();
       // set up reader
       DirectoryReader reader = DirectoryReader.open(d);
       FieldInfos fieldInfos = MultiFields.getMergedFieldInfos(reader);
@@ -244,7 +244,7 @@ public class TestDirectoryReader extends
         writer.addDocument(doc);
       }
       
-      writer.close();
+      writer.shutdown();
 
       // verify fields again
       reader = DirectoryReader.open(d);
@@ -342,7 +342,7 @@ public void testTermVectors() throws Exc
       
       writer.addDocument(doc);
   }
-  writer.close();
+  writer.shutdown();
   d.close();
 }
 
@@ -379,13 +379,13 @@ void assertTermDocsCount(String msg,
       addDocumentWithDifferentFields(writer);
       addDocumentWithTermVectorFields(writer);
     }
-    writer.close();
+    writer.shutdown();
     writer = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())).setOpenMode(OpenMode.APPEND).setMergePolicy(newLogMergePolicy()));
     Document doc = new Document();
     doc.add(new StoredField("bin1", bin));
     doc.add(new TextField("junk", "junk text", Field.Store.NO));
     writer.addDocument(doc);
-    writer.close();
+    writer.shutdown();
     DirectoryReader reader = DirectoryReader.open(dir);
     StoredDocument doc2 = reader.document(reader.maxDoc() - 1);
     StorableField[] fields = doc2.getFields("bin1");
@@ -404,7 +404,7 @@ void assertTermDocsCount(String msg,
 
     writer = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())).setOpenMode(OpenMode.APPEND).setMergePolicy(newLogMergePolicy()));
     writer.forceMerge(1);
-    writer.close();
+    writer.shutdown();
     reader = DirectoryReader.open(dir);
     doc2 = reader.document(reader.maxDoc() - 1);
     fields = doc2.getFields("bin1");
@@ -442,7 +442,7 @@ public void testFilesOpenClose() throws 
       Directory dir = newFSDirectory(dirFile);
       IndexWriter writer  = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())));
       addDoc(writer, "test");
-      writer.close();
+      writer.shutdown();
       dir.close();
 
       // Try to erase the data - this ensures that the writer closed all files
@@ -452,7 +452,7 @@ public void testFilesOpenClose() throws 
       // Now create the data set again, just as before
       writer  = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())).setOpenMode(OpenMode.CREATE));
       addDoc(writer, "test");
-      writer.close();
+      writer.shutdown();
       dir.close();
 
       // Now open existing directory and test that reader closes all files
@@ -656,7 +656,7 @@ public void testFilesOpenClose() throws 
     );
     for(int i=0;i<27;i++)
       addDocumentWithFields(writer);
-    writer.close();
+    writer.shutdown();
 
     SegmentInfos sis = new SegmentInfos();
     sis.read(d);
@@ -677,7 +677,7 @@ public void testFilesOpenClose() throws 
     );
     for(int i=0;i<7;i++)
       addDocumentWithFields(writer);
-    writer.close();
+    writer.shutdown();
 
     DirectoryReader r2 = DirectoryReader.openIfChanged(r);
     assertNotNull(r2);
@@ -689,7 +689,7 @@ public void testFilesOpenClose() throws 
       new MockAnalyzer(random()))
       .setOpenMode(OpenMode.APPEND));
     writer.forceMerge(1);
-    writer.close();
+    writer.shutdown();
 
     r2 = DirectoryReader.openIfChanged(r);
     assertNotNull(r2);
@@ -738,7 +738,7 @@ public void testFilesOpenClose() throws 
     writer.addDocument(createDocument("a"));
     writer.addDocument(createDocument("a"));
     writer.addDocument(createDocument("a"));
-    writer.close();
+    writer.shutdown();
     
     Collection<IndexCommit> commits = DirectoryReader.listCommits(dir);
     for (final IndexCommit commit : commits) {
@@ -787,7 +787,7 @@ public void testFilesOpenClose() throws 
     r2.close();
     assertTrue(ints == ints2);
   
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
   
@@ -817,7 +817,7 @@ public void testFilesOpenClose() throws 
       assertEquals(10, s.reader().terms("number").size());
     }
     r2.close();
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
   
@@ -838,7 +838,7 @@ public void testFilesOpenClose() throws 
     assertNull(r2);
     writer.commit();
     assertFalse(r.isCurrent());
-    writer.close();
+    writer.shutdown();
     r.close();
     dir.close();
   }
@@ -858,7 +858,7 @@ public void testFilesOpenClose() throws 
     writer.addDocument(new Document());
     writer.commit();
     sdp.snapshot();
-    writer.close();
+    writer.shutdown();
     long currentGen = 0;
     for (IndexCommit ic : DirectoryReader.listCommits(dir)) {
       assertTrue("currentGen=" + currentGen + " commitGen=" + ic.getGeneration(), currentGen < ic.getGeneration());
@@ -876,7 +876,7 @@ public void testFilesOpenClose() throws 
     d.add(newTextField("f", "a a b", Field.Store.NO));
     writer.addDocument(d);
     DirectoryReader r = writer.getReader();
-    writer.close();
+    writer.shutdown();
     try {
       // Make sure codec impls totalTermFreq (eg PreFlex doesn't)
       Assume.assumeTrue(r.totalTermFreq(new Term("f", new BytesRef("b"))) != -1);
@@ -899,7 +899,7 @@ public void testFilesOpenClose() throws 
     d.add(newTextField("f", "b", Field.Store.NO));
     writer.addDocument(d);
     DirectoryReader r = writer.getReader();
-    writer.close();
+    writer.shutdown();
     try {
       // Make sure codec impls getSumDocFreq (eg PreFlex doesn't)
       Assume.assumeTrue(r.getSumDocFreq("f") != -1);
@@ -920,7 +920,7 @@ public void testFilesOpenClose() throws 
     d.add(newTextField("f", "a", Field.Store.NO));
     writer.addDocument(d);
     DirectoryReader r = writer.getReader();
-    writer.close();
+    writer.shutdown();
     try {
       // Make sure codec impls getSumDocFreq (eg PreFlex doesn't)
       Assume.assumeTrue(r.getDocCount("f") != -1);
@@ -941,7 +941,7 @@ public void testFilesOpenClose() throws 
     d.add(newTextField("f", "a a b", Field.Store.NO));
     writer.addDocument(d);
     DirectoryReader r = writer.getReader();
-    writer.close();
+    writer.shutdown();
     try {
       // Make sure codec impls getSumDocFreq (eg PreFlex doesn't)
       Assume.assumeTrue(r.getSumTotalTermFreq("f") != -1);
@@ -976,7 +976,7 @@ public void testFilesOpenClose() throws 
   
     // Close the top reader, its the only one that should be closed
     assertEquals(1, closeCount[0]);
-    writer.close();
+    writer.shutdown();
   
     DirectoryReader reader2 = DirectoryReader.open(dir);
     reader2.addReaderClosedListener(listener);
@@ -992,7 +992,7 @@ public void testFilesOpenClose() throws 
     IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())));
     writer.addDocument(new Document());
     DirectoryReader r = writer.getReader();
-    writer.close();
+    writer.shutdown();
     r.document(0);
     try {
       r.document(1);
@@ -1014,7 +1014,7 @@ public void testFilesOpenClose() throws 
     r.decRef();
     r.close();
     assertFalse(r.tryIncRef());
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
   
@@ -1042,7 +1042,7 @@ public void testFilesOpenClose() throws 
       assertNull(threads[i].failed);
     }
     assertFalse(r.tryIncRef());
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
   
@@ -1078,7 +1078,7 @@ public void testFilesOpenClose() throws 
     doc.add(newStringField("field2", "foobaz", Field.Store.YES));
     writer.addDocument(doc);
     DirectoryReader r = writer.getReader();
-    writer.close();
+    writer.shutdown();
     Set<String> fieldsToLoad = new HashSet<>();
     assertEquals(0, r.document(0, fieldsToLoad).getFields().size());
     fieldsToLoad.add("field1");

Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestDirectoryReaderReopen.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestDirectoryReaderReopen.java?rev=1585759&r1=1585758&r2=1585759&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestDirectoryReaderReopen.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestDirectoryReaderReopen.java Tue Apr  8 15:34:50 2014
@@ -142,7 +142,7 @@ public class TestDirectoryReaderReopen e
         }
       }
     } finally {
-      iwriter.close();
+      iwriter.shutdown();
       reader.close();
     }
   }
@@ -203,7 +203,7 @@ public class TestDirectoryReaderReopen e
       writer.addDocument(createDocument(i, 3));
     }
     writer.forceMerge(1);
-    writer.close();
+    writer.shutdown();
 
     final TestReopen test = new TestReopen() {      
       @Override
@@ -211,7 +211,7 @@ public class TestDirectoryReaderReopen e
        IndexWriter modifier = new IndexWriter(dir, new IndexWriterConfig(
          TEST_VERSION_CURRENT, new MockAnalyzer(random())));
        modifier.addDocument(createDocument(n + i, 6));
-       modifier.close();
+       modifier.shutdown();
       }
 
       @Override
@@ -444,7 +444,7 @@ public class TestDirectoryReaderReopen e
       w.forceMerge(1);
     }
     
-    w.close();
+    w.shutdown();
 
     DirectoryReader r = DirectoryReader.open(dir);
     if (multiSegment) {
@@ -485,13 +485,13 @@ public class TestDirectoryReaderReopen e
         IndexWriter w = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())));
         w.deleteDocuments(new Term("field2", "a11"));
         w.deleteDocuments(new Term("field2", "b30"));
-        w.close();
+        w.shutdown();
         break;
       }
       case 1: {
         IndexWriter w = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())));
         w.forceMerge(1);
-        w.close();
+        w.shutdown();
         break;
       }
       case 2: {
@@ -500,13 +500,13 @@ public class TestDirectoryReaderReopen e
         w.forceMerge(1);
         w.addDocument(createDocument(102, 4));
         w.addDocument(createDocument(103, 4));
-        w.close();
+        w.shutdown();
         break;
       }
       case 3: {
         IndexWriter w = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())));
         w.addDocument(createDocument(101, 4));
-        w.close();
+        w.shutdown();
         break;
       }
     }
@@ -564,7 +564,7 @@ public class TestDirectoryReaderReopen e
       writer.setCommitData(data);
       writer.commit();
     }
-    writer.close();
+    writer.shutdown();
 
     DirectoryReader r = DirectoryReader.open(dir);
     assertEquals(0, r.numDocs());
@@ -614,7 +614,7 @@ public class TestDirectoryReaderReopen e
     assertNotNull(r2);
     r.close();
     assertEquals(1, r2.numDocs());
-    w.close();
+    w.shutdown();
     r2.close();
     dir.close();
   }

Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestDoc.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestDoc.java?rev=1585759&r1=1585758&r2=1585759&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestDoc.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestDoc.java Tue Apr  8 15:34:50 2014
@@ -135,7 +135,7 @@ public class TestDoc extends LuceneTestC
 
       SegmentCommitInfo si2 = indexDoc(writer, "test2.txt");
       printSegment(out, si2);
-      writer.close();
+      writer.shutdown();
 
       SegmentCommitInfo siMerge = merge(directory, si1, si2, "_merge", false);
       printSegment(out, siMerge);
@@ -177,7 +177,7 @@ public class TestDoc extends LuceneTestC
 
       si2 = indexDoc(writer, "test2.txt");
       printSegment(out, si2);
-      writer.close();
+      writer.shutdown();
 
       siMerge = merge(directory, si1, si2, "_merge", true);
       printSegment(out, siMerge);

Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestDocCount.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestDocCount.java?rev=1585759&r1=1585758&r2=1585759&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestDocCount.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestDocCount.java Tue Apr  8 15:34:50 2014
@@ -43,7 +43,7 @@ public class TestDocCount extends Lucene
     ir = iw.getReader();
     verifyCount(ir);
     ir.close();
-    iw.close();
+    iw.shutdown();
     dir.close();
   }
   

Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestDocInverterPerFieldErrorInfo.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestDocInverterPerFieldErrorInfo.java?rev=1585759&r1=1585758&r2=1585759&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestDocInverterPerFieldErrorInfo.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestDocInverterPerFieldErrorInfo.java Tue Apr  8 15:34:50 2014
@@ -86,7 +86,7 @@ public class TestDocInverterPerFieldErro
       assertTrue(infoStream.contains("distinctiveFieldName"));
     }
 
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
 
@@ -111,7 +111,7 @@ public class TestDocInverterPerFieldErro
     String infoStream = new String(infoBytes.toByteArray(), IOUtils.UTF_8);
     assertFalse(infoStream.contains("boringFieldName"));
 
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
 

Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestDocTermOrds.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestDocTermOrds.java?rev=1585759&r1=1585758&r2=1585759&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestDocTermOrds.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestDocTermOrds.java Tue Apr  8 15:34:50 2014
@@ -64,7 +64,7 @@ public class TestDocTermOrds extends Luc
     w.addDocument(doc);
     
     final IndexReader r = w.getReader();
-    w.close();
+    w.shutdown();
 
     final AtomicReader ar = SlowCompositeReaderWrapper.wrap(r);
     final DocTermOrds dto = new DocTermOrds(ar, ar.getLiveDocs(), "field");
@@ -151,7 +151,7 @@ public class TestDocTermOrds extends Luc
     }
     
     final DirectoryReader r = w.getReader();
-    w.close();
+    w.shutdown();
 
     if (VERBOSE) {
       System.out.println("TEST: reader=" + r);
@@ -248,7 +248,7 @@ public class TestDocTermOrds extends Luc
     }
     
     final DirectoryReader r = w.getReader();
-    w.close();
+    w.shutdown();
 
     if (VERBOSE) {
       System.out.println("TEST: reader=" + r);
@@ -401,7 +401,7 @@ public class TestDocTermOrds extends Luc
     v.setDocument(1);
     assertEquals(1, v.nextOrd());
     
-    iw.close();
+    iw.shutdown();
     r1.close();
     r2.close();
     dir.close();
@@ -428,7 +428,7 @@ public class TestDocTermOrds extends Luc
     iwriter.forceMerge(1);
     
     DirectoryReader ireader = iwriter.getReader();
-    iwriter.close();
+    iwriter.shutdown();
 
     AtomicReader ar = getOnlySegmentReader(ireader);
     SortedSetDocValues dv = FieldCache.DEFAULT.getDocTermOrds(ar, "field");

Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestDocValuesIndexing.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestDocValuesIndexing.java?rev=1585759&r1=1585758&r2=1585759&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestDocValuesIndexing.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestDocValuesIndexing.java Tue Apr  8 15:34:50 2014
@@ -57,7 +57,7 @@ public class TestDocValuesIndexing exten
     doc.add(new NumericDocValuesField("dv", 1));
     w.addDocument(doc);
     IndexReader r1 = w.getReader();
-    w.close();
+    w.shutdown();
 
     Directory d2 = newDirectory();
     w = new RandomIndexWriter(random(), d2);
@@ -66,7 +66,7 @@ public class TestDocValuesIndexing exten
     doc.add(new NumericDocValuesField("dv", 2));
     w.addDocument(doc);
     IndexReader r2 = w.getReader();
-    w.close();
+    w.shutdown();
 
     Directory d3 = newDirectory();
     w = new RandomIndexWriter(random(), d3);
@@ -78,7 +78,7 @@ public class TestDocValuesIndexing exten
 
     w.forceMerge(1);
     DirectoryReader r3 = w.getReader();
-    w.close();
+    w.shutdown();
     AtomicReader sr = getOnlySegmentReader(r3);
     assertEquals(2, sr.numDocs());
     NumericDocValues docValues = sr.getNumericDocValues("dv");
@@ -108,7 +108,7 @@ public class TestDocValuesIndexing exten
     w.addDocument(doc);
     w.forceMerge(1);
     DirectoryReader r = w.getReader();
-    w.close();
+    w.shutdown();
     assertEquals(17, FieldCache.DEFAULT.getInts(getOnlySegmentReader(r), "field", false).get(0));
     r.close();
     d.close();
@@ -135,7 +135,7 @@ public class TestDocValuesIndexing exten
     w.addDocument(doc);
     w.forceMerge(1);
     DirectoryReader r = w.getReader();
-    w.close();
+    w.shutdown();
     assertEquals(17, FieldCache.DEFAULT.getInts(getOnlySegmentReader(r), "field", false).get(0));
     r.close();
     d.close();
@@ -163,7 +163,7 @@ public class TestDocValuesIndexing exten
     DirectoryReader r = w.getReader();
     assertEquals(17, getOnlySegmentReader(r).getNumericDocValues("field").get(0));
     r.close();
-    w.close();
+    w.shutdown();
     d.close();
   }
 
@@ -195,7 +195,7 @@ public class TestDocValuesIndexing exten
     bytes[0] = 1;
     assertEquals(b, bytes1);
     r.close();
-    w.close();
+    w.shutdown();
     d.close();
   }
 
@@ -224,7 +224,7 @@ public class TestDocValuesIndexing exten
       assertEquals(Integer.toString(i), d.get("docId"));
     }
     slow.close();
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
 
@@ -240,7 +240,7 @@ public class TestDocValuesIndexing exten
     } catch (IllegalArgumentException iae) {
       // expected
     }
-    w.close();
+    w.shutdown();
     dir.close();
   }
 
@@ -259,7 +259,7 @@ public class TestDocValuesIndexing exten
     } catch (IllegalArgumentException iae) {
       // expected
     }
-    w.close();
+    w.shutdown();
     dir.close();
   }
   
@@ -279,9 +279,11 @@ public class TestDocValuesIndexing exten
       fail("didn't hit expected exception");
     } catch (IllegalArgumentException expected) {
       // expected
+      System.out.println("hit exc:");
+      expected.printStackTrace(System.out);
     }
     
-    iwriter.close();
+    iwriter.shutdown();
     directory.close();
   }
   
@@ -303,7 +305,7 @@ public class TestDocValuesIndexing exten
       // expected
     }
     
-    iwriter.close();
+    iwriter.shutdown();
     directory.close();
   }
   
@@ -325,7 +327,7 @@ public class TestDocValuesIndexing exten
       // expected
     }
     
-    iwriter.close();
+    iwriter.shutdown();
     directory.close();
   }
 
@@ -348,7 +350,7 @@ public class TestDocValuesIndexing exten
     } catch (IllegalArgumentException expected) {
       // expected
     }
-    iwriter.close();
+    iwriter.shutdown();
     directory.close();
   }
   
@@ -372,7 +374,7 @@ public class TestDocValuesIndexing exten
     } catch (IllegalArgumentException expected) {
       // expected
     }
-    iwriter.close();
+    iwriter.shutdown();
     directory.close();
   }
 
@@ -392,7 +394,7 @@ public class TestDocValuesIndexing exten
     } catch (IllegalArgumentException iae) {
       // expected
     }
-    w.close();
+    w.shutdown();
     dir.close();
   }
 
@@ -408,7 +410,7 @@ public class TestDocValuesIndexing exten
     doc = new Document();
     doc.add(new SortedDocValuesField("foo", new BytesRef("hello")));
     w.addDocument(doc);
-    w.close();
+    w.shutdown();
     dir.close();
   }
 
@@ -419,7 +421,7 @@ public class TestDocValuesIndexing exten
     Document doc = new Document();
     doc.add(new NumericDocValuesField("foo", 0));
     w.addDocument(doc);
-    w.close();
+    w.shutdown();
 
     IndexWriterConfig iwc = newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()));
     iwc.setOpenMode(IndexWriterConfig.OpenMode.CREATE);
@@ -427,7 +429,7 @@ public class TestDocValuesIndexing exten
     doc = new Document();
     doc.add(new SortedDocValuesField("foo", new BytesRef("hello")));
     w.addDocument(doc);
-    w.close();
+    w.shutdown();
     dir.close();
   }
 
@@ -475,7 +477,7 @@ public class TestDocValuesIndexing exten
       t.join();
     }
     assertTrue(hitExc.get());
-    w.close();
+    w.shutdown();
     dir.close();
   }
 
@@ -493,7 +495,7 @@ public class TestDocValuesIndexing exten
     doc = new Document();
     doc.add(new SortedDocValuesField("foo", new BytesRef("hello")));
     w2.addDocument(doc);
-    w2.close();
+    w2.shutdown();
 
     try {
       w.addIndexes(new Directory[] {dir2});
@@ -510,7 +512,7 @@ public class TestDocValuesIndexing exten
 
     r.close();
     dir2.close();
-    w.close();
+    w.shutdown();
     dir.close();
   }
 
@@ -529,7 +531,7 @@ public class TestDocValuesIndexing exten
     } catch (IllegalArgumentException iae) {
       // expected
     }
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
 
@@ -540,7 +542,7 @@ public class TestDocValuesIndexing exten
     Document doc = new Document();
     doc.add(new NumericDocValuesField("dv", 0L));
     writer.addDocument(doc);
-    writer.close();
+    writer.shutdown();
 
     writer = new IndexWriter(dir, conf.clone());
     doc = new Document();
@@ -551,7 +553,7 @@ public class TestDocValuesIndexing exten
     } catch (IllegalArgumentException iae) {
       // expected
     }
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
 
@@ -562,14 +564,14 @@ public class TestDocValuesIndexing exten
     Document doc = new Document();
     doc.add(new NumericDocValuesField("dv", 0L));
     writer.addDocument(doc);
-    writer.close();
+    writer.shutdown();
 
     writer = new IndexWriter(dir, conf.clone());
     writer.deleteAll();
     doc = new Document();
     doc.add(new SortedDocValuesField("dv", new BytesRef("foo")));
     writer.addDocument(doc);
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
 
@@ -584,7 +586,7 @@ public class TestDocValuesIndexing exten
     doc = new Document();
     doc.add(new SortedDocValuesField("dv", new BytesRef("foo")));
     writer.addDocument(doc);
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
 
@@ -600,7 +602,7 @@ public class TestDocValuesIndexing exten
     doc = new Document();
     doc.add(new SortedDocValuesField("dv", new BytesRef("foo")));
     writer.addDocument(doc);
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
 
@@ -611,13 +613,13 @@ public class TestDocValuesIndexing exten
     Document doc = new Document();
     doc.add(new NumericDocValuesField("dv", 0L));
     writer.addDocument(doc);
-    writer.close();
+    writer.shutdown();
     conf.setOpenMode(IndexWriterConfig.OpenMode.CREATE);
     writer = new IndexWriter(dir, conf.clone());
     doc = new Document();
     doc.add(new SortedDocValuesField("dv", new BytesRef("foo")));
     writer.addDocument(doc);
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
 
@@ -628,7 +630,7 @@ public class TestDocValuesIndexing exten
     Document doc = new Document();
     doc.add(new NumericDocValuesField("dv", 0L));
     writer.addDocument(doc);
-    writer.close();
+    writer.shutdown();
 
     Directory dir2 = newDirectory();
     writer = new IndexWriter(dir2, conf.clone());
@@ -641,7 +643,7 @@ public class TestDocValuesIndexing exten
     } catch (IllegalArgumentException iae) {
       // expected
     }
-    writer.close();
+    writer.shutdown();
 
     dir.close();
     dir2.close();
@@ -654,7 +656,7 @@ public class TestDocValuesIndexing exten
     Document doc = new Document();
     doc.add(new NumericDocValuesField("dv", 0L));
     writer.addDocument(doc);
-    writer.close();
+    writer.shutdown();
 
     Directory dir2 = newDirectory();
     writer = new IndexWriter(dir2, conf.clone());
@@ -669,7 +671,7 @@ public class TestDocValuesIndexing exten
       // expected
     }
     readers[0].close();
-    writer.close();
+    writer.shutdown();
 
     dir.close();
     dir2.close();
@@ -682,7 +684,7 @@ public class TestDocValuesIndexing exten
     Document doc = new Document();
     doc.add(new NumericDocValuesField("dv", 0L));
     writer.addDocument(doc);
-    writer.close();
+    writer.shutdown();
 
     Directory dir2 = newDirectory();
     writer = new IndexWriter(dir2, conf.clone());
@@ -695,7 +697,7 @@ public class TestDocValuesIndexing exten
     } catch (IllegalArgumentException iae) {
       // expected
     }
-    writer.close();
+    writer.shutdown();
     dir2.close();
     dir.close();
   }
@@ -707,7 +709,7 @@ public class TestDocValuesIndexing exten
     Document doc = new Document();
     doc.add(new NumericDocValuesField("dv", 0L));
     writer.addDocument(doc);
-    writer.close();
+    writer.shutdown();
 
     Directory dir2 = newDirectory();
     writer = new IndexWriter(dir2, conf.clone());
@@ -722,7 +724,7 @@ public class TestDocValuesIndexing exten
     } catch (IllegalArgumentException iae) {
       // expected
     }
-    writer.close();
+    writer.shutdown();
     dir2.close();
     dir.close();
   }
@@ -741,7 +743,7 @@ public class TestDocValuesIndexing exten
     writer.addDocument(doc);
     
     DirectoryReader r = writer.getReader();
-    writer.close();
+    writer.shutdown();
 
     AtomicReader subR = r.leaves().get(0).reader();
     assertEquals(2, subR.numDocs());

Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestDocValuesWithThreads.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestDocValuesWithThreads.java?rev=1585759&r1=1585758&r2=1585759&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestDocValuesWithThreads.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestDocValuesWithThreads.java Tue Apr  8 15:34:50 2014
@@ -63,7 +63,7 @@ public class TestDocValuesWithThreads ex
 
     w.forceMerge(1);
     final IndexReader r = w.getReader();
-    w.close();
+    w.shutdown();
 
     assertEquals(1, r.leaves().size());
     final AtomicReader ar = r.leaves().get(0).reader();
@@ -176,7 +176,7 @@ public class TestDocValuesWithThreads ex
 
     writer.forceMerge(1);
     final DirectoryReader r = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     final AtomicReader sr = getOnlySegmentReader(r);
 

Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestDocsAndPositions.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestDocsAndPositions.java?rev=1585759&r1=1585758&r2=1585759&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestDocsAndPositions.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestDocsAndPositions.java Tue Apr  8 15:34:50 2014
@@ -58,7 +58,7 @@ public class TestDocsAndPositions extend
       writer.addDocument(doc);
     }
     IndexReader reader = writer.getReader();
-    writer.close();
+    writer.shutdown();
 
     int num = atLeast(13);
     for (int i = 0; i < num; i++) {
@@ -140,7 +140,7 @@ public class TestDocsAndPositions extend
     }
 
     IndexReader reader = writer.getReader();
-    writer.close();
+    writer.shutdown();
 
     int num = atLeast(13);
     for (int i = 0; i < num; i++) {
@@ -216,7 +216,7 @@ public class TestDocsAndPositions extend
     }
 
     IndexReader reader = writer.getReader();
-    writer.close();
+    writer.shutdown();
 
     int num = atLeast(13);
     for (int i = 0; i < num; i++) {
@@ -293,7 +293,7 @@ public class TestDocsAndPositions extend
 
     // now do searches
     IndexReader reader = writer.getReader();
-    writer.close();
+    writer.shutdown();
 
     int num = atLeast(13);
     for (int i = 0; i < num; i++) {
@@ -346,7 +346,7 @@ public class TestDocsAndPositions extend
     docid = disi.docID();
     assertEquals(-1, docid);
     assertTrue(disi.nextDoc() != DocIdSetIterator.NO_MORE_DOCS);
-    writer.close();
+    writer.shutdown();
     r.close();
     dir.close();
   }
@@ -371,7 +371,7 @@ public class TestDocsAndPositions extend
     docid = disi.docID();
     assertEquals(-1, docid);
     assertTrue(disi.nextDoc() != DocIdSetIterator.NO_MORE_DOCS);
-    writer.close();
+    writer.shutdown();
     r.close();
     dir.close();
   }

Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestDocumentWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestDocumentWriter.java?rev=1585759&r1=1585758&r2=1585759&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestDocumentWriter.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestDocumentWriter.java Tue Apr  8 15:34:50 2014
@@ -35,7 +35,6 @@ import org.apache.lucene.util.AttributeS
 import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.util.LuceneTestCase;
 import org.apache.lucene.util.TestUtil;
-import org.apache.lucene.util.TestUtil;
 
 public class TestDocumentWriter extends LuceneTestCase {
   private Directory dir;
@@ -63,7 +62,7 @@ public class TestDocumentWriter extends 
     writer.addDocument(testDoc);
     writer.commit();
     SegmentCommitInfo info = writer.newestSegment();
-    writer.close();
+    writer.shutdown();
     //After adding the document, we should be able to read it back in
     SegmentReader reader = new SegmentReader(info, newIOContext(random()));
     assertTrue(reader != null);
@@ -125,7 +124,7 @@ public class TestDocumentWriter extends 
     writer.addDocument(doc);
     writer.commit();
     SegmentCommitInfo info = writer.newestSegment();
-    writer.close();
+    writer.shutdown();
     SegmentReader reader = new SegmentReader(info, newIOContext(random()));
 
     DocsAndPositionsEnum termPositions = MultiFields.getTermPositionsEnum(reader, MultiFields.getLiveDocs(reader),
@@ -197,7 +196,7 @@ public class TestDocumentWriter extends 
     writer.addDocument(doc);
     writer.commit();
     SegmentCommitInfo info = writer.newestSegment();
-    writer.close();
+    writer.shutdown();
     SegmentReader reader = new SegmentReader(info, newIOContext(random()));
 
     DocsAndPositionsEnum termPositions = MultiFields.getTermPositionsEnum(reader, reader.getLiveDocs(), "f1", new BytesRef("a"));
@@ -240,7 +239,7 @@ public class TestDocumentWriter extends 
     writer.addDocument(doc);
     writer.commit();
     SegmentCommitInfo info = writer.newestSegment();
-    writer.close();
+    writer.shutdown();
     SegmentReader reader = new SegmentReader(info, newIOContext(random()));
 
     DocsAndPositionsEnum termPositions = reader.termPositionsEnum(new Term("preanalyzed", "term1"));
@@ -281,7 +280,7 @@ public class TestDocumentWriter extends 
     IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(
         TEST_VERSION_CURRENT, new MockAnalyzer(random())));
     writer.addDocument(doc);
-    writer.close();
+    writer.shutdown();
 
     TestUtil.checkIndex(dir);
 
@@ -322,7 +321,7 @@ public class TestDocumentWriter extends 
         TEST_VERSION_CURRENT, new MockAnalyzer(random())));
     writer.addDocument(doc);
     writer.forceMerge(1); // be sure to have a single segment
-    writer.close();
+    writer.shutdown();
 
     TestUtil.checkIndex(dir);
 

Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestDuelingCodecs.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestDuelingCodecs.java?rev=1585759&r1=1585758&r2=1585759&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestDuelingCodecs.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestDuelingCodecs.java Tue Apr  8 15:34:50 2014
@@ -89,9 +89,9 @@ public class TestDuelingCodecs extends L
     createRandomIndex(numdocs, rightWriter, seed);
 
     leftReader = maybeWrapReader(leftWriter.getReader());
-    leftWriter.close();
+    leftWriter.shutdown();
     rightReader = maybeWrapReader(rightWriter.getReader());
-    rightWriter.close();
+    rightWriter.shutdown();
     
     // check that our readers are valid
     TestUtil.checkReader(leftReader);

Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestExceedMaxTermLength.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestExceedMaxTermLength.java?rev=1585759&r1=1585758&r2=1585759&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestExceedMaxTermLength.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestExceedMaxTermLength.java Tue Apr  8 15:34:50 2014
@@ -99,7 +99,7 @@ public class TestExceedMaxTermLength ext
                    msg.contains(name));
       }
     } finally {
-      w.close();
+      w.shutdown();
     }
   }
 }

Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestFieldsReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestFieldsReader.java?rev=1585759&r1=1585758&r2=1585759&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestFieldsReader.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestFieldsReader.java Tue Apr  8 15:34:50 2014
@@ -56,7 +56,7 @@ public class TestFieldsReader extends Lu
     conf.getMergePolicy().setNoCFSRatio(0.0);
     IndexWriter writer = new IndexWriter(dir, conf);
     writer.addDocument(testDoc);
-    writer.close();
+    writer.shutdown();
     FaultyIndexInput.doFail = false;
   }
   
@@ -197,7 +197,7 @@ public class TestFieldsReader extends Lu
       for(int i=0;i<2;i++)
         writer.addDocument(testDoc);
       writer.forceMerge(1);
-      writer.close();
+      writer.shutdown();
 
       IndexReader reader = DirectoryReader.open(dir);
 

Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestFilterAtomicReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestFilterAtomicReader.java?rev=1585759&r1=1585758&r2=1585759&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestFilterAtomicReader.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestFilterAtomicReader.java Tue Apr  8 15:34:50 2014
@@ -130,7 +130,7 @@ public class TestFilterAtomicReader exte
     d3.add(newTextField("default", "two four", Field.Store.YES));
     writer.addDocument(d3);
 
-    writer.close();
+    writer.shutdown();
 
     Directory target = newDirectory();
 
@@ -140,7 +140,7 @@ public class TestFilterAtomicReader exte
     writer = new IndexWriter(target, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())));
     IndexReader reader = new TestReader(DirectoryReader.open(directory));
     writer.addIndexes(reader);
-    writer.close();
+    writer.shutdown();
     reader.close();
     reader = DirectoryReader.open(target);
     

Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestFlex.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestFlex.java?rev=1585759&r1=1585758&r2=1585759&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestFlex.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestFlex.java Tue Apr  8 15:34:50 2014
@@ -58,7 +58,7 @@ public class TestFlex extends LuceneTest
       r.close();
     }
 
-    w.close();
+    w.shutdown();
     d.close();
   }
 
@@ -79,7 +79,7 @@ public class TestFlex extends LuceneTest
       // ok -- codec is not required to support this op
     }
     r.close();
-    w.close();
+    w.shutdown();
     d.close();
   }
 }

Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestFlushByRamOrCountsPolicy.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestFlushByRamOrCountsPolicy.java?rev=1585759&r1=1585758&r2=1585759&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestFlushByRamOrCountsPolicy.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestFlushByRamOrCountsPolicy.java Tue Apr  8 15:34:50 2014
@@ -111,7 +111,7 @@ public class TestFlushByRamOrCountsPolic
     if (ensureNotStalled) {
       assertFalse(docsWriter.flushControl.stallControl.wasStalled());
     }
-    writer.close();
+    writer.shutdown();
     assertEquals(0, flushControl.activeBytes());
     dir.close();
   }
@@ -162,7 +162,7 @@ public class TestFlushByRamOrCountsPolic
       assertTrue("peak bytes without flush exceeded watermark",
           flushPolicy.peakDocCountWithoutFlush <= iwc.getMaxBufferedDocs());
       assertActiveBytesAfter(flushControl);
-      writer.close();
+      writer.shutdown();
       assertEquals(0, flushControl.activeBytes());
       dir.close();
     }
@@ -225,7 +225,7 @@ public class TestFlushByRamOrCountsPolic
       assertFalse("never block if we don't flush on RAM", docsWriter.flushControl.stallControl.hasBlocked());
     }
     r.close();
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
 
@@ -276,7 +276,7 @@ public class TestFlushByRamOrCountsPolic
         assertTrue(docsWriter.flushControl.stallControl.wasStalled());
       }
       assertActiveBytesAfter(flushControl);
-      writer.close(true);
+      writer.shutdown();
       dir.close();
     }
   }

Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestForTooMuchCloning.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestForTooMuchCloning.java?rev=1585759&r1=1585758&r2=1585759&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestForTooMuchCloning.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestForTooMuchCloning.java Tue Apr  8 15:34:50 2014
@@ -55,7 +55,7 @@ public class TestForTooMuchCloning exten
       w.addDocument(doc);
     }
     final IndexReader r = w.getReader();
-    w.close();
+    w.shutdown();
 
     final int cloneCount = dir.getInputCloneCount();
     //System.out.println("merge clone count=" + cloneCount);

Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestForceMergeForever.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestForceMergeForever.java?rev=1585759&r1=1585758&r2=1585759&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestForceMergeForever.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestForceMergeForever.java Tue Apr  8 15:34:50 2014
@@ -74,7 +74,7 @@ public class TestForceMergeForever exten
       ((LogMergePolicy) mp).setMergeFactor(mergeAtOnce);
     } else {
       // skip test
-      w.close();
+      w.shutdown();
       d.close();
       return;
     }
@@ -101,7 +101,7 @@ public class TestForceMergeForever exten
     doStop.set(true);
     t.join();
     assertTrue("merge count is " + w.mergeCount.get(), w.mergeCount.get() <= 1);
-    w.close();
+    w.shutdown();
     d.close();
     docs.close();
   }

Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestIndexFileDeleter.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestIndexFileDeleter.java?rev=1585759&r1=1585758&r2=1585759&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestIndexFileDeleter.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestIndexFileDeleter.java Tue Apr  8 15:34:50 2014
@@ -66,7 +66,7 @@ public class TestIndexFileDeleter extend
     for(;i<45;i++) {
       addDoc(writer, i);
     }
-    writer.close();
+    writer.shutdown();
 
     // Delete one doc so we get a .del file:
     writer = new IndexWriter(
@@ -76,7 +76,7 @@ public class TestIndexFileDeleter extend
     );
     Term searchTerm = new Term("id", "7");
     writer.deleteDocuments(searchTerm);
-    writer.close();
+    writer.shutdown();
 
     // Now, artificially create an extra .del file & extra
     // .s0 file:
@@ -125,7 +125,7 @@ public class TestIndexFileDeleter extend
     // Open & close a writer: it should delete the above 4
     // files and nothing more:
     writer = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())).setOpenMode(OpenMode.APPEND));
-    writer.close();
+    writer.shutdown();
 
     String[] files2 = dir.listAll();
     dir.close();

Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestIndexReaderClose.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestIndexReaderClose.java?rev=1585759&r1=1585758&r2=1585759&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestIndexReaderClose.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestIndexReaderClose.java Tue Apr  8 15:34:50 2014
@@ -37,7 +37,7 @@ public class TestIndexReaderClose extend
       Directory dir = newDirectory();
       IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random(), TEST_VERSION_CURRENT, new MockAnalyzer(random())));
       writer.commit();
-      writer.close();
+      writer.shutdown();
       DirectoryReader open = DirectoryReader.open(dir);
       final boolean throwOnClose = !rarely();
       AtomicReader wrap = SlowCompositeReaderWrapper.wrap(open);

Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java?rev=1585759&r1=1585758&r2=1585759&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java Tue Apr  8 15:34:50 2014
@@ -27,6 +27,7 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Random;
 import java.util.Set;
+import java.util.concurrent.CountDownLatch;
 
 import org.apache.lucene.analysis.*;
 import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
@@ -69,10 +70,12 @@ import org.apache.lucene.util.Bits;
 import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.util.Constants;
 import org.apache.lucene.util.IOUtils;
+import org.apache.lucene.util.InfoStream;
 import org.apache.lucene.util.LuceneTestCase;
 import org.apache.lucene.util.SetOnce;
 import org.apache.lucene.util.TestUtil;
 import org.apache.lucene.util.ThreadInterruptedException;
+import org.apache.lucene.util.Version;
 import org.apache.lucene.util.automaton.Automaton;
 import org.apache.lucene.util.automaton.BasicAutomata;
 import org.apache.lucene.util.automaton.CharacterRunAutomaton;
@@ -103,14 +106,14 @@ public class TestIndexWriter extends Luc
             addDocWithIndex(writer,i);
         }
         assertEquals(100, writer.maxDoc());
-        writer.close();
+        writer.shutdown();
 
         // delete 40 documents
         writer = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())).setMergePolicy(NoMergePolicy.NO_COMPOUND_FILES));
         for (i = 0; i < 40; i++) {
             writer.deleteDocuments(new Term("id", ""+i));
         }
-        writer.close();
+        writer.shutdown();
 
         reader = DirectoryReader.open(dir);
         assertEquals(60, reader.numDocs());
@@ -122,7 +125,7 @@ public class TestIndexWriter extends Luc
         writer.forceMerge(1);
         assertEquals(60, writer.maxDoc());
         assertEquals(60, writer.numDocs());
-        writer.close();
+        writer.shutdown();
 
         // check that the index reader gives the same numbers.
         reader = DirectoryReader.open(dir);
@@ -135,7 +138,7 @@ public class TestIndexWriter extends Luc
         writer = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random())).setOpenMode(OpenMode.CREATE));
         assertEquals(0, writer.maxDoc());
         assertEquals(0, writer.numDocs());
-        writer.close();
+        writer.shutdown();
         dir.close();
     }
 
@@ -189,7 +192,7 @@ public class TestIndexWriter extends Luc
       // add one document & close writer
       IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random())));
       addDoc(writer);
-      writer.close();
+      writer.shutdown();
 
       // now open reader:
       IndexReader reader = DirectoryReader.open(dir);
@@ -199,7 +202,7 @@ public class TestIndexWriter extends Luc
       writer = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random())).setOpenMode(OpenMode.CREATE));
       assertEquals("should be zero documents", writer.maxDoc(), 0);
       addDoc(writer);
-      writer.close();
+      writer.shutdown();
 
       assertEquals("should be one document", reader.numDocs(), 1);
       IndexReader reader2 = DirectoryReader.open(dir);
@@ -219,7 +222,7 @@ public class TestIndexWriter extends Luc
         addDoc(writer);
 
         // close
-        writer.close();
+        writer.shutdown();
         try {
           addDoc(writer);
           fail("did not hit AlreadyClosedException");
@@ -235,7 +238,7 @@ public class TestIndexWriter extends Luc
       Directory dir = newDirectory();
       IndexWriter writer  = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random())));
       writer.commit();
-      writer.close();
+      writer.shutdown();
 
       IndexReader reader = DirectoryReader.open(dir);
       assertEquals(0, reader.maxDoc());
@@ -244,7 +247,7 @@ public class TestIndexWriter extends Luc
 
       writer  = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random())).setOpenMode(OpenMode.APPEND));
       writer.commit();
-      writer.close();
+      writer.shutdown();
 
       reader = DirectoryReader.open(dir);
       assertEquals(0, reader.maxDoc());
@@ -266,7 +269,7 @@ public class TestIndexWriter extends Luc
         doc.add(newField("f"+j, "aaa", storedTextType));
         writer.addDocument(doc);
       }
-      writer.close();
+      writer.shutdown();
 
       IndexReader reader = DirectoryReader.open(dir);
       assertEquals(100, reader.maxDoc());
@@ -302,7 +305,7 @@ public class TestIndexWriter extends Luc
         assertTrue(numFile > lastNumFile);
         lastNumFile = numFile;
       }
-      writer.close();
+      writer.shutdown();
       dir.close();
     }
 
@@ -358,7 +361,7 @@ public class TestIndexWriter extends Luc
           assertTrue(flushCount > lastFlushCount);
         }
       }
-      writer.close();
+      writer.shutdown();
       dir.close();
     }
 
@@ -419,7 +422,7 @@ public class TestIndexWriter extends Luc
           assertTrue(flushCount > lastFlushCount);
         }
       }
-      writer.close();
+      writer.shutdown();
       dir.close();
     }
 
@@ -461,7 +464,7 @@ public class TestIndexWriter extends Luc
           writer.addDocument(doc);
         }
       }
-      writer.close();
+      writer.shutdown();
 
       IndexReader reader = DirectoryReader.open(dir);
       IndexSearcher searcher = newSearcher(reader);
@@ -490,7 +493,7 @@ public class TestIndexWriter extends Luc
         doc.add(f);
         writer.addDocument(doc);
       }
-      writer.close();
+      writer.shutdown();
 
       Term searchTerm = new Term("field", "aaa");
 
@@ -515,7 +518,7 @@ public class TestIndexWriter extends Luc
         doc.add(f);
         writer.addDocument(doc);
       }
-      writer.close();
+      writer.shutdown();
       reader = DirectoryReader.open(dir);
       searcher = newSearcher(reader);
       hits = searcher.search(new TermQuery(searchTerm), null, 1000).scoreDocs;
@@ -547,7 +550,7 @@ public class TestIndexWriter extends Luc
       customType.setStoreTermVectorOffsets(true);
       doc.add(newField("field", b.toString(), customType));
       writer.addDocument(doc);
-      writer.close();
+      writer.shutdown();
 
       IndexReader reader = DirectoryReader.open(dir);
       assertEquals(1, reader.maxDoc());
@@ -592,7 +595,7 @@ public class TestIndexWriter extends Luc
       for (int i = 0; i < 100; i++) {
         addDoc(writer);
       }
-      writer.close();
+      writer.shutdown();
       Term searchTerm = new Term("content", "aaa");
       IndexReader reader = DirectoryReader.open(dir);
       IndexSearcher searcher = newSearcher(reader);
@@ -602,7 +605,7 @@ public class TestIndexWriter extends Luc
 
       writer = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random()))
         .setOpenMode(OpenMode.CREATE));
-      writer.close();
+      writer.shutdown();
       dir.close();
     }
 
@@ -623,7 +626,7 @@ public class TestIndexWriter extends Luc
       for(int i=0;i<19;i++)
         writer.addDocument(doc);
       writer.flush(false, true);
-      writer.close();
+      writer.shutdown();
       SegmentInfos sis = new SegmentInfos();
       sis.read(dir);
       // Since we flushed w/o allowing merging we should now
@@ -649,7 +652,7 @@ public class TestIndexWriter extends Luc
         System.out.println("\nTEST: now add empty doc");
       }
       writer.addDocument(new Document());
-      writer.close();
+      writer.shutdown();
       IndexReader reader = DirectoryReader.open(dir);
       assertEquals(2, reader.numDocs());
       reader.close();
@@ -673,7 +676,7 @@ public class TestIndexWriter extends Luc
     customType.setStoreTermVectors(true);
     document.add(newField("tvtest", "", customType));
     iw.addDocument(document);
-    iw.close();
+    iw.shutdown();
     dir.close();
   }
 
@@ -694,7 +697,7 @@ public class TestIndexWriter extends Luc
       Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
       for(int i=0;i<4;i++)
         iw.addDocument(document);
-      iw.close();
+      iw.shutdown();
       dir.close();
     } finally {
       Thread.currentThread().setPriority(pri);
@@ -733,14 +736,14 @@ public class TestIndexWriter extends Luc
       for(int j=0;j<4;j++)
         writer.addDocument(doc);
 
-      writer.close();
+      writer.shutdown();
 
       if (0 == i % 4) {
         writer = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random())));
         //LogMergePolicy lmp2 = (LogMergePolicy) writer.getConfig().getMergePolicy();
         //lmp2.setNoCFSRatio(0.0);
         writer.forceMerge(1);
-        writer.close();
+        writer.shutdown();
       }
     }
     dir.close();
@@ -759,7 +762,7 @@ public class TestIndexWriter extends Luc
     b.append(" x");
     doc.add(newTextField("field", b.toString(), Field.Store.NO));
     writer.addDocument(doc);
-    writer.close();
+    writer.shutdown();
 
     IndexReader reader = DirectoryReader.open(dir);
     Term t = new Term("field", "x");
@@ -777,7 +780,7 @@ public class TestIndexWriter extends Luc
     Document doc = new Document();
     doc.add(newTextField("", "a b c", Field.Store.NO));
     writer.addDocument(doc);
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
   
@@ -787,7 +790,7 @@ public class TestIndexWriter extends Luc
     Document doc = new Document();
     doc.add(newTextField("", "a b c", Field.Store.NO));
     writer.addDocument(doc);  
-    writer.close();
+    writer.shutdown();
     DirectoryReader reader = DirectoryReader.open(dir);
     AtomicReader subreader = getOnlySegmentReader(reader);
     TermsEnum te = subreader.fields().terms("").iterator(null);
@@ -808,7 +811,7 @@ public class TestIndexWriter extends Luc
     doc.add(newStringField("", "b", Field.Store.NO));
     doc.add(newStringField("", "c", Field.Store.NO));
     writer.addDocument(doc);  
-    writer.close();
+    writer.shutdown();
     DirectoryReader reader = DirectoryReader.open(dir);
     AtomicReader subreader = getOnlySegmentReader(reader);
     TermsEnum te = subreader.fields().terms("").iterator(null);
@@ -861,7 +864,7 @@ public class TestIndexWriter extends Luc
     w.commit();
     assertTrue(w.beforeWasCalled);
     assertTrue(w.afterWasCalled);
-    w.close();
+    w.shutdown();
 
     IndexReader ir = DirectoryReader.open(dir);
     assertEquals(0, ir.numDocs());
@@ -900,7 +903,7 @@ public class TestIndexWriter extends Luc
     } catch (IllegalArgumentException iea) {
       // expected
     }
-    w.close();
+    w.shutdown();
     dir.close();
   }
 
@@ -920,7 +923,7 @@ public class TestIndexWriter extends Luc
     doc.add(f);
     doc.add(f2);
     w.addDocument(doc);
-    w.close();
+    w.shutdown();
 
     IndexReader r = DirectoryReader.open(dir);
     Terms tpv = r.getTermVectors(0).terms("field");
@@ -964,11 +967,11 @@ public class TestIndexWriter extends Luc
     Directory dir2 = newDirectory();
     IndexWriter writer2 = new IndexWriter(dir2, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random())));
     writer2.addDocument(doc);
-    writer2.close();
+    writer2.shutdown();
 
     IndexReader r1 = DirectoryReader.open(dir2);
     writer.addIndexes(r1, r1);
-    writer.close();
+    writer.shutdown();
 
     IndexReader r3 = DirectoryReader.open(dir);
     assertEquals(5, r3.numDocs());
@@ -1019,7 +1022,7 @@ public class TestIndexWriter extends Luc
       }
       w.addDocument(doc);
       w.deleteDocuments(new Term("id", "500"));
-      w.close();
+      w.shutdown();
     }
 
     @Override
@@ -1027,10 +1030,10 @@ public class TestIndexWriter extends Luc
       // LUCENE-2239: won't work with NIOFS/MMAP
       MockDirectoryWrapper dir = new MockDirectoryWrapper(random, new RAMDirectory());
 
-      // When interrupt arrives in w.close(), when it's
-      // writing liveDocs, this can lead to double-write of
-      // _X_N.del:
-      //dir.setPreventDoubleWrite(false);
+      // When interrupt arrives in w.shutdown(), this can
+      // lead to double-write of files:
+      dir.setPreventDoubleWrite(false);
+
       IndexWriter w = null;
       while(!finish) {
         try {
@@ -1042,7 +1045,12 @@ public class TestIndexWriter extends Luc
               // thing we do is try to close again,
               // i.e. we'll never try to open a new writer
               // until this one successfully closes:
-              w.close();
+              // w.rollback();
+              try {
+                w.shutdown();
+              } catch (AlreadyClosedException ace) {
+                // OK
+              }
               w = null;
             }
             IndexWriterConfig conf = newIndexWriterConfig(random,
@@ -1098,7 +1106,7 @@ public class TestIndexWriter extends Luc
                 w.forceMerge(1);
               }
             }
-            w.close();
+            w.shutdown();
             w = null;
             DirectoryReader.open(dir).close();
 
@@ -1133,6 +1141,9 @@ public class TestIndexWriter extends Luc
         }
       }
 
+      if (VERBOSE) {
+        System.out.println("TEST: now finish failed=" + failed);
+      }
       if (!failed) {
         if (VERBOSE) {
           System.out.println("TEST: now rollback");
@@ -1299,7 +1310,7 @@ public class TestIndexWriter extends Luc
     w.addDocument(doc);
     w.commit();
     w.forceMerge(1);   // force segment merge.
-    w.close();
+    w.shutdown();
 
     IndexReader ir = DirectoryReader.open(dir);
     StoredDocument doc2 = ir.document(0);
@@ -1336,7 +1347,7 @@ public class TestIndexWriter extends Luc
     IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(
         TEST_VERSION_CURRENT, new MockAnalyzer(random())));
     writer.addDocument(new Document());
-    writer.close();
+    writer.shutdown();
 
     dir.close();
   }
@@ -1425,7 +1436,7 @@ public class TestIndexWriter extends Luc
       }
       //assertTrue(files.contains("_2.cfs"));
 
-      w.close();
+      w.shutdown();
       r2.close();
 
       dir.close();
@@ -1469,7 +1480,7 @@ public class TestIndexWriter extends Luc
     writer.deleteUnusedFiles();
     assertEquals(1, DirectoryReader.listCommits(dir).size());
 
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
 
@@ -1478,7 +1489,7 @@ public class TestIndexWriter extends Luc
     // then IndexWriter ctor succeeds. Previously (LUCENE-2386) it failed
     // when listAll() was called in IndexFileDeleter.
     Directory dir = newFSDirectory(createTempDir("emptyFSDirNoLock"), NoLockFactory.getNoLockFactory());
-    new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random()))).close();
+    new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random()))).shutdown();
     dir.close();
   }
 
@@ -1559,7 +1570,7 @@ public class TestIndexWriter extends Luc
         TEST_VERSION_CURRENT, new MockAnalyzer(random())).setMaxBufferedDocs(2)
         .setOpenMode(OpenMode.CREATE));
 
-    w2.close();
+    w2.shutdown();
     // If we don't do that, the test fails on Windows
     w.rollback();
 
@@ -1595,7 +1606,7 @@ public class TestIndexWriter extends Luc
       indexWriter.addDocument(doc);
     }
 
-    indexWriter.close();
+    indexWriter.shutdown();
 
     TestUtil.checkIndex(dir);
 
@@ -1685,7 +1696,7 @@ public class TestIndexWriter extends Luc
     w.forceMerge(1);
 
     IndexReader reader = w.getReader();
-    w.close();
+    w.shutdown();
 
     // Make sure all terms < max size were indexed
     assertEquals(1, reader.docFreq(new Term("content", "abc")));
@@ -1723,7 +1734,7 @@ public class TestIndexWriter extends Luc
     w.addDocument(doc);
 
     reader = w.getReader();
-    w.close();
+    w.shutdown();
     assertEquals(1, reader.docFreq(new Term("content", bigTerm)));
 
     SortedDocValues dti = FieldCache.DEFAULT.getTermsIndex(SlowCompositeReaderWrapper.wrap(reader), "content", random().nextFloat() * PackedInts.FAST);
@@ -1754,7 +1765,7 @@ public class TestIndexWriter extends Luc
       assertTrue(d.listAll().length <= 2);
     }
 
-    w.close();
+    w.shutdown();
     d.close();
   }
 
@@ -1776,7 +1787,7 @@ public class TestIndexWriter extends Luc
 
     w.deleteDocuments(new Term("id", "0"));
     r = w.getReader();
-    w.close();
+    w.shutdown();
     long version3 = r.getVersion();
     r.close();
     assert(version3 > version2);
@@ -1797,7 +1808,7 @@ public class TestIndexWriter extends Luc
     } catch (LockObtainFailedException lofe) {
       // expected
     }
-    w1.close();
+    w1.shutdown();
     d.close();
   }
 
@@ -1820,7 +1831,7 @@ public class TestIndexWriter extends Luc
     doc = new Document();
     doc.add(new Field("field", "a b c", docsOnly));
     w.addDocument(doc);
-    w.close();
+    w.shutdown();
     dir.close();
   }
 
@@ -1833,7 +1844,7 @@ public class TestIndexWriter extends Luc
     docs.add(new Document());
     w.updateDocuments(new Term("foo", "bar"),
                       docs);
-    w.close();
+    w.shutdown();
     dir.close();
   }
 
@@ -1845,13 +1856,13 @@ public class TestIndexWriter extends Luc
 
     w.prepareCommit();
     try {
-      w.close();
+      w.shutdown();
       fail("should have hit exception");
     } catch (IllegalStateException ise) {
       // expected
     }
     w.commit();
-    w.close();
+    w.shutdown();
     IndexReader r = DirectoryReader.open(dir);
     assertEquals(0, r.maxDoc());
     r.close();
@@ -1919,7 +1930,7 @@ public class TestIndexWriter extends Luc
     doc.add(f2);
     doc.add(f);
     w.addDocument(doc);
-    w.close();
+    w.shutdown();
     dir.close();
   }
   
@@ -1931,14 +1942,14 @@ public class TestIndexWriter extends Luc
     IndexWriter iw = new IndexWriter(dir, 
         newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())));
     iw.addDocument(new Document());
-    iw.close();
+    iw.shutdown();
     try {
       // Create my own random file:
       IndexOutput out = dir.createOutput("myrandomfile", newIOContext(random()));
       out.writeByte((byte) 42);
       out.close();
       
-      new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random()))).close();
+      new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random()))).shutdown();
       
       assertTrue(slowFileExists(dir, "myrandomfile"));
     } finally {
@@ -1963,7 +1974,7 @@ public class TestIndexWriter extends Luc
     doc.add(new TextField("body", "test of gaps", Field.Store.NO));
     iw.addDocument(doc);
     IndexReader ir = iw.getReader();
-    iw.close();
+    iw.shutdown();
     IndexSearcher is = newSearcher(ir);
     PhraseQuery pq = new PhraseQuery();
     pq.add(new Term("body", "just"), 0);
@@ -1994,7 +2005,7 @@ public class TestIndexWriter extends Luc
     doc.add(new TextField("body", "test of gaps", Field.Store.NO));
     iw.addDocument(doc);
     IndexReader ir = iw.getReader();
-    iw.close();
+    iw.shutdown();
     IndexSearcher is = newSearcher(ir);
     PhraseQuery pq = new PhraseQuery();
     pq.add(new Term("body", "just"), 0);
@@ -2005,32 +2016,6 @@ public class TestIndexWriter extends Luc
     dir.close();
   }
   
-  // here we do better, there is no current segments file, so we don't delete anything.
-  // however, if you actually go and make a commit, the next time you run indexwriter
-  // this file will be gone.
-  public void testOtherFiles2() throws Throwable {
-    Directory dir = newDirectory();
-    try {
-      // Create my own random file:
-      IndexOutput out = dir.createOutput("_a.frq", newIOContext(random()));
-      out.writeByte((byte) 42);
-      out.close();
-      
-      new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random()))).close();
-      
-      assertTrue(slowFileExists(dir, "_a.frq"));
-      
-      IndexWriter iw = new IndexWriter(dir, 
-          newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())));
-      iw.addDocument(new Document());
-      iw.close();
-      
-      assertFalse(slowFileExists(dir, "_a.frq"));
-    } finally {
-      dir.close();
-    }
-  }
-
   // LUCENE-4398
   public void testRotatingFieldNames() throws Exception {
     Directory dir = newFSDirectory(createTempDir("TestIndexWriter.testChangingFields"));
@@ -2073,7 +2058,7 @@ public class TestIndexWriter extends Luc
         upto = 0;
       }
     }
-    w.close();
+    w.shutdown();
     dir.close();
   }
   
@@ -2115,7 +2100,7 @@ public class TestIndexWriter extends Luc
         "value2", r.getIndexCommit().getUserData().get("key"));
     r.close();
     
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
   
@@ -2127,12 +2112,12 @@ public class TestIndexWriter extends Luc
       put("key", "value");
     }});
     assertEquals("value", writer.getCommitData().get("key"));
-    writer.close();
+    writer.shutdown();
     
     // validate that it's also visible when opening a new IndexWriter
     writer = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, null).setOpenMode(OpenMode.APPEND));
     assertEquals("value", writer.getCommitData().get("key"));
-    writer.close();
+    writer.shutdown();
     
     dir.close();
   }
@@ -2186,7 +2171,8 @@ public class TestIndexWriter extends Luc
       }
     }
     assertTrue(liveIds.isEmpty());
-    IOUtils.close(reader, w, dir);
+    w.shutdown();
+    IOUtils.close(reader, dir);
   }
 
   private static class RandomFailingFieldIterable implements Iterable<IndexDocument> {
@@ -2246,7 +2232,7 @@ public class TestIndexWriter extends Luc
 
       try {
         if ((i & 1) == 0) {
-          new IndexWriter(dir, iwc).close();
+          new IndexWriter(dir, iwc).shutdown();
         } else {
           new IndexWriter(dir, iwc).rollback();
         }
@@ -2311,14 +2297,14 @@ public class TestIndexWriter extends Luc
     writer.waitForMerges();
     writer.commit();
     assertFalse(writer.hasUncommittedChanges());
-    writer.close();
+    writer.shutdown();
 
     writer = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random())));
     assertFalse(writer.hasUncommittedChanges());
     writer.addDocument(doc);
     assertTrue(writer.hasUncommittedChanges());
 
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
   
@@ -2346,7 +2332,7 @@ public class TestIndexWriter extends Luc
     }
     evilWriter.deleteDocuments(new MatchAllDocsQuery());
     evilWriter.forceMerge(1);
-    evilWriter.close();
+    evilWriter.shutdown();
     dir.close();
   }
 
@@ -2365,7 +2351,7 @@ public class TestIndexWriter extends Luc
     w.deleteDocuments(new Term("a", "xxx"));
     w.deleteDocuments(new Term("b", "foo"));
     IndexReader r = w.getReader();
-    w.close();
+    w.shutdown();
 
     // Make sure document was not (incorrectly) deleted:
     assertEquals(1, r.numDocs());
@@ -2373,6 +2359,151 @@ public class TestIndexWriter extends Luc
     dir.close();
   }
 
+  public void testHasUncommittedChangesAfterException() throws IOException {
+    Analyzer analyzer = new MockAnalyzer(random());
+
+    Directory directory = newDirectory();
+    // we don't use RandomIndexWriter because it might add more docvalues than we expect !!!!1
+    IndexWriterConfig iwc = newIndexWriterConfig(TEST_VERSION_CURRENT, analyzer);
+    iwc.setMergePolicy(newLogMergePolicy());
+    IndexWriter iwriter = new IndexWriter(directory, iwc);
+    Document doc = new Document();
+    doc.add(new SortedDocValuesField("dv", new BytesRef("foo!")));
+    doc.add(new SortedDocValuesField("dv", new BytesRef("bar!")));
+    try {
+      iwriter.addDocument(doc);
+      fail("didn't hit expected exception");
+    } catch (IllegalArgumentException expected) {
+      // expected
+    }
+    iwriter.commit();
+    assertFalse(iwriter.hasUncommittedChanges());
+    iwriter.shutdown();
+    directory.close();
+  }
+
+  public void testDoubleClose() throws IOException {
+    Directory dir = newDirectory();
+    IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())));
+    Document doc = new Document();
+    doc.add(new SortedDocValuesField("dv", new BytesRef("foo!")));
+    w.addDocument(doc);
+    w.close();
+    // Close again should have no effect
+    w.close();
+    dir.close();
+  }
+
+  public void testRollbackThenClose() throws IOException {
+    Directory dir = newDirectory();
+    IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())));
+    Document doc = new Document();
+    doc.add(new SortedDocValuesField("dv", new BytesRef("foo!")));
+    w.addDocument(doc);
+    w.rollback();
+    // Close after rollback should have no effect
+    w.close();
+    dir.close();
+  }
+
+  public void testCloseThenRollback() throws IOException {
+    Directory dir = newDirectory();
+    IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())));
+    Document doc = new Document();
+    doc.add(new SortedDocValuesField("dv", new BytesRef("foo!")));
+    w.addDocument(doc);
+    w.close();
+    // Rollback after close should have no effect
+    w.rollback();
+    dir.close();
+  }
+
+  public void testUncommittedChanges() throws IOException {
+    Directory dir = newDirectory();
+    // If version is < 50 IW.close should throw an exception
+    // on uncommitted changes:
+    IndexWriterConfig iwc = newIndexWriterConfig(Version.LUCENE_48, new MockAnalyzer(random()));
+    IndexWriter w = new IndexWriter(dir, iwc);
+    Document doc = new Document();
+    doc.add(new SortedDocValuesField("dv", new BytesRef("foo!")));
+    w.addDocument(doc);
+    try {
+      w.close();
+      fail("didn't hit exception");
+    } catch (RuntimeException re) {
+      // expected
+      assertTrue(re.getMessage().contains("this writer is closed, but some pending changes or running merges were discarded"));
+    }
+    w.rollback();
+    dir.close();
+  }
+
+  public void testCloseWhileMergeIsRunning() throws IOException {
+    Directory dir = newDirectory();
+
+    final CountDownLatch mergeStarted = new CountDownLatch(1);
+    final CountDownLatch closeStarted = new CountDownLatch(1);
+
+    // If version is < 50 IW.close should throw an exception
+    // on still-running merges:
+    IndexWriterConfig iwc = newIndexWriterConfig(Version.LUCENE_48, new MockAnalyzer(random()));
+    LogDocMergePolicy mp = new LogDocMergePolicy();
+    mp.setMergeFactor(2);
+    iwc.setMergePolicy(mp);
+    iwc.setInfoStream(new InfoStream() {
+        @Override
+        public boolean isEnabled(String component) {
+          return true;
+        }
+
+        @Override
+        public void message(String component, String message) {
+          if (message.equals("rollback")) {
+            closeStarted.countDown();
+          }
+        }
+
+        @Override
+        public void close() {
+        }
+      });
+
+    iwc.setMergeScheduler(new ConcurrentMergeScheduler() {
+        @Override
+        public void doMerge(MergePolicy.OneMerge merge) throws IOException {
+          mergeStarted.countDown();
+          try {
+            closeStarted.await();
+          } catch (InterruptedException ie) {
+            Thread.currentThread().interrupt();
+            throw new RuntimeException(ie);
+          }
+          super.doMerge(merge);
+        }
+
+        @Override
+        public void close() {
+        }
+      });
+    IndexWriter w = new IndexWriter(dir, iwc);
+    Document doc = new Document();
+    doc.add(new SortedDocValuesField("dv", new BytesRef("foo!")));
+    w.addDocument(doc);
+    w.commit();
+    w.addDocument(doc);
+    w.commit();
+    try {
+      w.close();
+      fail("didn't hit exception");
+    } catch (RuntimeException re) {
+      // expected
+      System.out.println("GOT: " + re.getMessage());
+      assertTrue(re.getMessage().contains("this writer is closed, but some pending changes or running merges were discarded"));
+    }
+    w.rollback();
+    dir.close();
+  }
+
   // LUCENE-5574
   public void testClosingNRTReaderDoesNotCorruptYourIndex() throws IOException {
 

Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterCommit.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterCommit.java?rev=1585759&r1=1585758&r2=1585759&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterCommit.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterCommit.java Tue Apr  8 15:34:50 2014
@@ -46,7 +46,7 @@ public class TestIndexWriterCommit exten
       for (int i = 0; i < 14; i++) {
         TestIndexWriter.addDoc(writer);
       }
-      writer.close();
+      writer.shutdown();
 
       Term searchTerm = new Term("content", "aaa");
       DirectoryReader reader = DirectoryReader.open(dir);
@@ -71,7 +71,7 @@ public class TestIndexWriterCommit exten
       }
 
       // Now, close the writer:
-      writer.close();
+      writer.shutdown();
       assertFalse("reader should not be current now", reader.isCurrent());
 
       IndexReader r = DirectoryReader.open(dir);
@@ -97,7 +97,7 @@ public class TestIndexWriterCommit exten
     for (int i = 0; i < 14; i++) {
       TestIndexWriter.addDoc(writer);
     }
-    writer.close();
+    writer.shutdown();
 
     Term searchTerm = new Term("content", "aaa");
     IndexReader reader = DirectoryReader.open(dir);
@@ -153,7 +153,7 @@ public class TestIndexWriterCommit exten
       r.close();
     }
 
-    writer.close();
+    writer.shutdown();
     IndexReader r = DirectoryReader.open(dir);
     searcher = newSearcher(r);
     hits = searcher.search(new TermQuery(searchTerm), null, 1000).scoreDocs;
@@ -212,7 +212,7 @@ public class TestIndexWriterCommit exten
     for(int j=0;j<30;j++) {
       TestIndexWriter.addDocWithIndex(writer, j);
     }
-    writer.close();
+    writer.shutdown();
     dir.resetMaxUsedSizeInBytes();
 
     dir.setTrackDiskUsage(true);
@@ -233,7 +233,7 @@ public class TestIndexWriterCommit exten
     long midDiskUsage = dir.getMaxUsedSizeInBytes();
     dir.resetMaxUsedSizeInBytes();
     writer.forceMerge(1);
-    writer.close();
+    writer.shutdown();
 
     DirectoryReader.open(dir).close();
 
@@ -275,7 +275,7 @@ public class TestIndexWriterCommit exten
     for(int j=0;j<17;j++) {
       TestIndexWriter.addDocWithIndex(writer, j);
     }
-    writer.close();
+    writer.shutdown();
 
     writer  = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random())).setOpenMode(OpenMode.APPEND));
     writer.forceMerge(1);
@@ -304,7 +304,7 @@ public class TestIndexWriterCommit exten
     }
     writer = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random())).setOpenMode(OpenMode.APPEND));
     writer.forceMerge(1);
-    writer.close();
+    writer.shutdown();
 
     if (VERBOSE) {
       System.out.println("TEST: writer closed");
@@ -373,7 +373,7 @@ public class TestIndexWriterCommit exten
       threads[i].join();
     }
     assertFalse(failed.get());
-    w.close();
+    w.shutdown();
     dir.close();
   }
 
@@ -413,7 +413,7 @@ public class TestIndexWriterCommit exten
     reader = DirectoryReader.open(dir);
     assertEquals(40, reader.numDocs());
     reader.close();
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
   
@@ -434,7 +434,7 @@ public class TestIndexWriterCommit exten
     w.addDocument(doc);
     commitData.put("tag", "second");
     w.setCommitData(commitData);
-    w.close();
+    w.shutdown();
 
     // open "first" with IndexWriter
     IndexCommit commit = null;
@@ -455,7 +455,7 @@ public class TestIndexWriterCommit exten
     w.addDocument(doc);
     commitData.put("tag", "third");
     w.setCommitData(commitData);
-    w.close();
+    w.shutdown();
 
     // make sure "second" commit is still there
     commit = null;
@@ -484,7 +484,7 @@ public class TestIndexWriterCommit exten
       // that's expected !
     }
     // No changes still should generate a commit, because it's a new index.
-    writer.close();
+    writer.shutdown();
     assertEquals("expected 1 commits!", 1, DirectoryReader.listCommits(dir).size());
     dir.close();
   }
@@ -541,7 +541,7 @@ public class TestIndexWriterCommit exten
     reader = DirectoryReader.open(dir);
     assertEquals(40, reader.numDocs());
     reader.close();
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
 
@@ -598,7 +598,7 @@ public class TestIndexWriterCommit exten
     reader = DirectoryReader.open(dir);
     assertEquals(17, reader.numDocs());
     reader.close();
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
 
@@ -609,7 +609,7 @@ public class TestIndexWriterCommit exten
     IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random())));
     writer.prepareCommit();
     writer.commit();
-    writer.close();
+    writer.shutdown();
 
     IndexReader reader = DirectoryReader.open(dir);
     assertEquals(0, reader.numDocs());
@@ -623,7 +623,7 @@ public class TestIndexWriterCommit exten
     IndexWriter w = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random())).setMaxBufferedDocs(2));
     for(int j=0;j<17;j++)
       TestIndexWriter.addDoc(w);
-    w.close();
+    w.shutdown();
 
     DirectoryReader r = DirectoryReader.open(dir);
     // commit(Map) never called for this index
@@ -636,7 +636,7 @@ public class TestIndexWriterCommit exten
     Map<String,String> data = new HashMap<>();
     data.put("label", "test1");
     w.setCommitData(data);
-    w.close();
+    w.shutdown();
 
     r = DirectoryReader.open(dir);
     assertEquals("test1", r.getIndexCommit().getUserData().get("label"));
@@ -644,7 +644,7 @@ public class TestIndexWriterCommit exten
 
     w = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random())));
     w.forceMerge(1);
-    w.close();
+    w.shutdown();
 
     dir.close();
   }

Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterConfig.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterConfig.java?rev=1585759&r1=1585758&r2=1585759&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterConfig.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterConfig.java Tue Apr  8 15:34:50 2014
@@ -144,7 +144,7 @@ public class TestIndexWriterConfig exten
     Directory dir = newDirectory();
     // test that IWC cannot be reused across two IWs
     IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, null);
-    new RandomIndexWriter(random(), dir, conf).close();
+    new RandomIndexWriter(random(), dir, conf).shutdown();
 
     // this should fail
     try {
@@ -164,8 +164,8 @@ public class TestIndexWriterConfig exten
     
     // if it's cloned in advance, it should be ok
     conf = newIndexWriterConfig(TEST_VERSION_CURRENT, null);
-    new RandomIndexWriter(random(), dir, conf.clone()).close();
-    new RandomIndexWriter(random(), dir, conf.clone()).close();
+    new RandomIndexWriter(random(), dir, conf.clone()).shutdown();
+    new RandomIndexWriter(random(), dir, conf.clone()).shutdown();
     
     dir.close();
   }
@@ -396,7 +396,7 @@ public class TestIndexWriterConfig exten
     w.forceMerge(1);
     w.commit();
     assertTrue("Expected CFS after merge", w.newestSegment().info.getUseCompoundFile());
-    w.close();
+    w.shutdown();
     dir.close();
   }
 

Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterDelete.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterDelete.java?rev=1585759&r1=1585758&r2=1585759&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterDelete.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterDelete.java Tue Apr  8 15:34:50 2014
@@ -90,7 +90,7 @@ public class TestIndexWriterDelete exten
     hitCount = getHitCount(dir, term);
     assertEquals(0, hitCount);
 
-    modifier.close();
+    modifier.shutdown();
     dir.close();
   }
 
@@ -125,7 +125,7 @@ public class TestIndexWriterDelete exten
     reader = DirectoryReader.open(dir);
     assertEquals(0, reader.numDocs());
     reader.close();
-    modifier.close();
+    modifier.shutdown();
     dir.close();
   }
 
@@ -139,7 +139,7 @@ public class TestIndexWriterDelete exten
     writer.deleteDocuments(new Term("foobar", "1"));
     writer.deleteDocuments(new Term("foobar", "1"));
     assertEquals(3, writer.getFlushDeletesCount());
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
   
@@ -180,7 +180,7 @@ public class TestIndexWriterDelete exten
       int hitCount = getHitCount(dir, new Term("id", String.valueOf(id)));
       assertEquals(1, hitCount);
       reader.close();
-      modifier.close();
+      modifier.shutdown();
       dir.close();
     }
   }
@@ -214,7 +214,7 @@ public class TestIndexWriterDelete exten
 
     IndexReader reader = DirectoryReader.open(dir);
     assertEquals(5, reader.numDocs());
-    modifier.close();
+    modifier.shutdown();
     reader.close();
     dir.close();
   }
@@ -258,7 +258,7 @@ public class TestIndexWriterDelete exten
     assertEquals(2, reader.numDocs());
     reader.close();
 
-    modifier.close();
+    modifier.shutdown();
     dir.close();
   }
 
@@ -304,7 +304,7 @@ public class TestIndexWriterDelete exten
     assertEquals(2, reader.numDocs());
     reader.close();
 
-    modifier.close();
+    modifier.shutdown();
     dir.close();
   }
   
@@ -361,7 +361,7 @@ public class TestIndexWriterDelete exten
       thread.join();
     }
     
-    modifier.close();
+    modifier.shutdown();
     DirectoryReader reader = DirectoryReader.open(dir);
     assertEquals(reader.maxDoc(), 0);
     assertEquals(reader.numDocs(), 0);
@@ -397,7 +397,6 @@ public class TestIndexWriterDelete exten
 
     // Roll it back
     modifier.rollback();
-    modifier.close();
 
     // Validate that the docs are still there
     reader = DirectoryReader.open(dir);
@@ -440,7 +439,6 @@ public class TestIndexWriterDelete exten
 
     // Roll it back
     modifier.rollback();
-    modifier.close();
 
     // Validate that the docs are still there
     reader = DirectoryReader.open(dir);
@@ -510,7 +508,7 @@ public class TestIndexWriterDelete exten
       d.add(new NumericDocValuesField("dv", i));
       writer.addDocument(d);
     }
-    writer.close();
+    writer.shutdown();
 
     long diskUsage = startDir.sizeInBytes();
     long diskFree = diskUsage + 10;
@@ -597,8 +595,8 @@ public class TestIndexWriterDelete exten
               }
               docId += 12;
             }
+            modifier.shutdown();
           }
-          modifier.close();
           success = true;
           if (0 == x) {
             done = true;
@@ -696,7 +694,6 @@ public class TestIndexWriterDelete exten
         }
       }
       dir.close();
-      modifier.close();
 
       // Try again with 10 more bytes of free space:
       diskFree += 10;
@@ -861,7 +858,7 @@ public class TestIndexWriterDelete exten
     // Make sure the delete was successfully flushed:
     assertEquals(0, hitCount);
 
-    modifier.close();
+    modifier.shutdown();
     dir.close();
   }
 
@@ -918,7 +915,7 @@ public class TestIndexWriterDelete exten
       }
     }
 
-    modifier.close();
+    modifier.shutdown();
     TestIndexWriter.assertNoUnreferencedFiles(dir, "docsWriter.abort() failed to delete unreferenced files");
     dir.close();
   }
@@ -934,7 +931,7 @@ public class TestIndexWriterDelete exten
     modifier.deleteDocuments(new TermQuery(new Term("nada", "nada")));
     modifier.commit();
     assertEquals(5, modifier.numDocs());
-    modifier.close();
+    modifier.shutdown();
     dir.close();
   }
   
@@ -966,7 +963,7 @@ public class TestIndexWriterDelete exten
       r.close();
     }
 
-    w.close();
+    w.shutdown();
     dir.close();
   }
   
@@ -1014,7 +1011,7 @@ public class TestIndexWriterDelete exten
       }
       assertTrue("flush happened too quickly during " + (doIndexing ? "indexing" : "deleting") + " count=" + count, count > 2500);
     }
-    w.close();
+    w.shutdown();
     dir.close();
   }
 
@@ -1060,7 +1057,7 @@ public class TestIndexWriterDelete exten
         fail("delete's were not applied");
       }
     }
-    w.close();
+    w.shutdown();
     dir.close();
   }
 
@@ -1099,7 +1096,7 @@ public class TestIndexWriterDelete exten
         fail("delete's were not applied at count=" + flushAtDelCount);
       }
     }
-    w.close();
+    w.shutdown();
     dir.close();
   }
 
@@ -1148,7 +1145,7 @@ public class TestIndexWriterDelete exten
     }
     closing.set(true);
     assertTrue(sawAfterFlush.get());
-    w.close();
+    w.shutdown();
     dir.close();
   }
 
@@ -1171,7 +1168,7 @@ public class TestIndexWriterDelete exten
     w.deleteDocuments(new Term("field", "0"));
     w.commit();
     assertEquals(1, w.getSegmentCount());
-    w.close();
+    w.shutdown();
 
     ByteArrayOutputStream bos = new ByteArrayOutputStream(1024);
     CheckIndex checker = new CheckIndex(dir);
@@ -1184,7 +1181,7 @@ public class TestIndexWriterDelete exten
     assertTrue(s.contains("has deletions"));
     w = new IndexWriter(dir, iwc.clone());
     w.forceMerge(1);
-    w.close();
+    w.shutdown();
 
     bos = new ByteArrayOutputStream(1024);
     checker.setInfoStream(new PrintStream(bos, false, IOUtils.UTF_8), false);
@@ -1205,7 +1202,7 @@ public class TestIndexWriterDelete exten
     w.addDocument(doc);
     w.addDocument(doc);
     w.addDocument(doc);
-    w.close();
+    w.shutdown();
 
     iwc = new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()));
     iwc.setOpenMode(IndexWriterConfig.OpenMode.APPEND);
@@ -1214,7 +1211,7 @@ public class TestIndexWriterDelete exten
     assertTrue(w.tryDeleteDocument(r, 1));
     assertTrue(w.tryDeleteDocument(r.leaves().get(0).reader(), 0));
     r.close();
-    w.close();
+    w.shutdown();
 
     r = DirectoryReader.open(d);
     assertEquals(2, r.numDeletedDocs());



Mime
View raw message