Index: lucene/spatial/src/test/org/apache/lucene/spatial/SpatialTestCase.java
===================================================================
--- lucene/spatial/src/test/org/apache/lucene/spatial/SpatialTestCase.java	(revision 1584870)
+++ lucene/spatial/src/test/org/apache/lucene/spatial/SpatialTestCase.java	(working copy)
@@ -83,7 +83,8 @@
   @Override
   @After
   public void tearDown() throws Exception {
-    IOUtils.close(indexWriter,indexReader,directory);
+    indexWriter.shutdown();
+    IOUtils.close(indexReader,directory);
     super.tearDown();
   }
 
Index: lucene/spatial/src/test/org/apache/lucene/spatial/SpatialExample.java
===================================================================
--- lucene/spatial/src/test/org/apache/lucene/spatial/SpatialExample.java	(revision 1584870)
+++ lucene/spatial/src/test/org/apache/lucene/spatial/SpatialExample.java	(working copy)
@@ -117,7 +117,7 @@
     indexWriter.addDocument(newSampleDocument(
         20, ctx.makePoint(0.1,0.1), ctx.makePoint(0, 0)));
 
-    indexWriter.close();
+    indexWriter.shutdown();
   }
 
   private Document newSampleDocument(int id, Shape... shapes) {
Index: lucene/join/src/test/org/apache/lucene/search/join/TestJoinUtil.java
===================================================================
--- lucene/join/src/test/org/apache/lucene/search/join/TestJoinUtil.java	(revision 1584870)
+++ lucene/join/src/test/org/apache/lucene/search/join/TestJoinUtil.java	(working copy)
@@ -128,7 +128,7 @@
     w.addDocument(doc);
 
     IndexSearcher indexSearcher = new IndexSearcher(w.getReader());
-    w.close();
+    w.shutdown();
 
     // Search for product
     Query joinQuery =
@@ -214,7 +214,7 @@
     w.forceMerge(1);
 
     IndexSearcher indexSearcher = new IndexSearcher(w.getReader());
-    w.close();
+    w.shutdown();
 
     // Search for product
     Query joinQuery =
@@ -302,7 +302,7 @@
     w.addDocument(doc);
 
     IndexSearcher indexSearcher = new IndexSearcher(w.getReader());
-    w.close();
+    w.shutdown();
 
     // Search for movie via subtitle
     Query joinQuery =
@@ -369,7 +369,7 @@
       IndexIterationContext context = createContext(numberOfDocumentsToIndex, w, multipleValuesPerDocument, scoreDocsInOrder);
 
       IndexReader topLevelReader = w.getReader();
-      w.close();
+      w.shutdown();
       for (int searchIter = 1; searchIter <= maxSearchIter; searchIter++) {
         if (VERBOSE) {
           System.out.println("searchIter=" + searchIter);
Index: lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoinSorting.java
===================================================================
--- lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoinSorting.java	(revision 1584870)
+++ lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoinSorting.java	(working copy)
@@ -209,7 +209,7 @@
     w.addDocument(document);
 
     IndexSearcher searcher = new IndexSearcher(DirectoryReader.open(w.w, false));
-    w.close();
+    w.shutdown();
     Filter parentFilter = new QueryWrapperFilter(new TermQuery(new Term("__type", "parent")));
     Filter childFilter = new QueryWrapperFilter(new PrefixQuery(new Term("field2")));
     ToParentBlockJoinQuery query = new ToParentBlockJoinQuery(
Index: lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoinValidation.java
===================================================================
--- lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoinValidation.java	(revision 1584870)
+++ lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoinValidation.java	(working copy)
@@ -70,7 +70,7 @@
       indexWriter.commit();
     }
     indexReader = DirectoryReader.open(indexWriter, random().nextBoolean());
-    indexWriter.close();
+    indexWriter.shutdown();
     indexSearcher = new IndexSearcher(indexReader);
     parentsFilter = new FixedBitSetCachingWrapperFilter(new QueryWrapperFilter(new WildcardQuery(new Term("parent", "*"))));
   }
Index: lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoin.java
===================================================================
--- lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoin.java	(revision 1584870)
+++ lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoin.java	(working copy)
@@ -90,7 +90,7 @@
     }
     
     IndexReader r = DirectoryReader.open(w, random().nextBoolean());
-    w.close();
+    w.shutdown();
     assertTrue(r.leaves().size() > 1);
     IndexSearcher s = new IndexSearcher(r);
     Filter parentsFilter = new FixedBitSetCachingWrapperFilter(new QueryWrapperFilter(new TermQuery(new Term("docType", "resume"))));
@@ -141,7 +141,7 @@
     w.addDocuments(docs);
     
     IndexReader r = w.getReader();
-    w.close();
+    w.shutdown();
     IndexSearcher s = newSearcher(r);
 
     // Create a filter that defines "parent" documents in the index - in this case resumes
@@ -228,7 +228,7 @@
     }
 
     IndexReader r = w.getReader();
-    w.close();
+    w.shutdown();
     IndexSearcher s = newSearcher(r);
 
     MultiTermQuery qc = NumericRangeQuery.newIntRange("year", 2007, 2007, true, true);
@@ -293,7 +293,7 @@
     addSkillless(w);
 
     IndexReader r = w.getReader();
-    w.close();
+    w.shutdown();
     IndexSearcher s = newSearcher(r);
 
     // Create a filter that defines "parent" documents in the index - in this case resumes
@@ -367,7 +367,7 @@
     final Directory dir = newDirectory();
     final RandomIndexWriter w = new RandomIndexWriter(random(), dir);
     IndexReader r = w.getReader();
-    w.close();
+    w.shutdown();
     IndexSearcher s = newSearcher(r);
     
     ToParentBlockJoinQuery q = new ToParentBlockJoinQuery(new MatchAllDocsQuery(), new QueryWrapperFilter(new MatchAllDocsQuery()), ScoreMode.Avg);
@@ -423,7 +423,7 @@
 
     s.getIndexReader().close();
     w.deleteDocuments(new Term("skill", "java"));
-    w.close();
+    w.shutdown();
     s = newSearcher(DirectoryReader.open(dir));
 
     topDocs = s.search(q, 10);
@@ -596,9 +596,9 @@
     }
 
     final IndexReader r = w.getReader();
-    w.close();
+    w.shutdown();
     final IndexReader joinR = joinW.getReader();
-    joinW.close();
+    joinW.shutdown();
 
     if (VERBOSE) {
       System.out.println("TEST: reader=" + r);
@@ -1035,7 +1035,7 @@
     w.addDocuments(docs);
 
     IndexReader r = w.getReader();
-    w.close();
+    w.shutdown();
     IndexSearcher s = newSearcher(r);
 
     // Create a filter that defines "parent" documents in the index - in this case resumes
@@ -1116,7 +1116,7 @@
     parentDoc.add(newStringField("parent", "1", Field.Store.NO));
     w.addDocuments(Arrays.asList(childDoc, parentDoc));
     IndexReader r = w.getReader();
-    w.close();
+    w.shutdown();
     IndexSearcher s = newSearcher(r);
     Query tq = new TermQuery(new Term("child", "1"));
     Filter parentFilter = new FixedBitSetCachingWrapperFilter(
@@ -1150,7 +1150,7 @@
     // Need single seg:
     w.forceMerge(1);
     IndexReader r = w.getReader();
-    w.close();
+    w.shutdown();
     IndexSearcher s = newSearcher(r);
     Query tq = new TermQuery(new Term("child", "2"));
     Filter parentFilter = new FixedBitSetCachingWrapperFilter(
@@ -1183,7 +1183,7 @@
     addSkillless(w);
 
     IndexReader r = w.getReader();
-    w.close();
+    w.shutdown();
     IndexSearcher s = new IndexSearcher(r);
 
     // Create a filter that defines "parent" documents in the index - in this case resumes
@@ -1287,7 +1287,7 @@
     w.addDocuments(docs);
     
     IndexReader r = w.getReader();
-    w.close();
+    w.shutdown();
 
     Query childQuery = new TermQuery(new Term("childText", "text"));
     Filter parentsFilter = new FixedBitSetCachingWrapperFilter(new QueryWrapperFilter(new TermQuery(new Term("isParent", "yes"))));
@@ -1351,7 +1351,7 @@
     w.addDocuments(docs);
     
     IndexReader r = w.getReader();
-    w.close();
+    w.shutdown();
 
     // never matches:
     Query childQuery = new TermQuery(new Term("childText", "bogus"));
@@ -1416,7 +1416,7 @@
     w.addDocuments(docs);
     
     IndexReader r = w.getReader();
-    w.close();
+    w.shutdown();
 
     // illegally matches parent:
     Query childQuery = new TermQuery(new Term("parentText", "text"));
@@ -1468,7 +1468,7 @@
     w.addDocuments(Arrays.asList(childDoc, parentDoc));
 
     IndexReader r = w.getReader();
-    w.close();
+    w.shutdown();
     IndexSearcher s = newSearcher(r);
 
     // Create a filter that defines "parent" documents in the index - in this case resumes
Index: lucene/replicator/src/test/org/apache/lucene/replicator/IndexRevisionTest.java
===================================================================
--- lucene/replicator/src/test/org/apache/lucene/replicator/IndexRevisionTest.java	(revision 1584870)
+++ lucene/replicator/src/test/org/apache/lucene/replicator/IndexRevisionTest.java	(working copy)
@@ -47,7 +47,8 @@
     } catch (IllegalArgumentException e) {
       // expected
     } finally {
-      IOUtils.close(writer, dir);
+      writer.shutdown();
+      IOUtils.close(dir);
     }
   }
   
@@ -63,7 +64,8 @@
     } catch (IllegalStateException e) {
       // expected
     } finally {
-      IOUtils.close(writer, dir);
+      writer.shutdown();
+      IOUtils.close(dir);
     }
   }
   
@@ -87,8 +89,9 @@
       assertNotNull(new IndexRevision(writer));
       rev1.release(); // this release should trigger the delete of segments_1
       assertFalse(slowFileExists(dir, IndexFileNames.SEGMENTS + "_1"));
+      writer.shutdown();
     } finally {
-      IOUtils.close(writer, dir);
+      IOUtils.close(dir);
     }
   }
   
@@ -108,8 +111,9 @@
       List<RevisionFile> files = sourceFiles.values().iterator().next();
       String lastFile = files.get(files.size() - 1).fileName;
       assertTrue(lastFile.startsWith(IndexFileNames.SEGMENTS) && !lastFile.equals(IndexFileNames.SEGMENTS_GEN));
+      writer.shutdown();
     } finally {
-      IOUtils.close(writer, dir);
+      IOUtils.close(dir);
     }
   }
   
@@ -147,8 +151,9 @@
         assertArrayEquals(srcBytes, inBytes);
         IOUtils.close(src, in);
       }
+      writer.shutdown();
     } finally {
-      IOUtils.close(writer, dir);
+      IOUtils.close(dir);
     }
   }
   
Index: lucene/replicator/src/test/org/apache/lucene/replicator/http/HttpReplicatorTest.java
===================================================================
--- lucene/replicator/src/test/org/apache/lucene/replicator/http/HttpReplicatorTest.java	(revision 1584870)
+++ lucene/replicator/src/test/org/apache/lucene/replicator/http/HttpReplicatorTest.java	(working copy)
@@ -83,7 +83,8 @@
   @Override
   public void tearDown() throws Exception {
     stopHttpServer(server);
-    IOUtils.close(reader, writer, handlerIndexDir, serverIndexDir);
+    writer.rollback();
+    IOUtils.close(reader, handlerIndexDir, serverIndexDir);
     System.clearProperty("org.eclipse.jetty.LEVEL");
     super.tearDown();
   }
Index: lucene/replicator/src/test/org/apache/lucene/replicator/IndexReplicationClientTest.java
===================================================================
--- lucene/replicator/src/test/org/apache/lucene/replicator/IndexReplicationClientTest.java	(revision 1584870)
+++ lucene/replicator/src/test/org/apache/lucene/replicator/IndexReplicationClientTest.java	(working copy)
@@ -150,7 +150,8 @@
   @After
   @Override
   public void tearDown() throws Exception {
-    IOUtils.close(client, callback, publishWriter, replicator, publishDir, handlerDir);
+    publishWriter.shutdown();
+    IOUtils.close(client, callback, replicator, publishDir, handlerDir);
     super.tearDown();
   }
   
Index: lucene/replicator/src/test/org/apache/lucene/replicator/IndexAndTaxonomyRevisionTest.java
===================================================================
--- lucene/replicator/src/test/org/apache/lucene/replicator/IndexAndTaxonomyRevisionTest.java	(revision 1584870)
+++ lucene/replicator/src/test/org/apache/lucene/replicator/IndexAndTaxonomyRevisionTest.java	(working copy)
@@ -62,7 +62,8 @@
     } catch (IllegalStateException e) {
       // expected
     } finally {
-      IOUtils.close(indexWriter, taxoWriter, taxoDir, indexDir);
+      indexWriter.shutdown();
+      IOUtils.close(taxoWriter, taxoDir, indexDir);
     }
   }
   
@@ -92,6 +93,7 @@
       assertNotNull(new IndexAndTaxonomyRevision(indexWriter, taxoWriter));
       rev1.release(); // this release should trigger the delete of segments_1
       assertFalse(slowFileExists(indexDir, IndexFileNames.SEGMENTS + "_1"));
+      indexWriter.shutdown();
     } finally {
       IOUtils.close(indexWriter, taxoWriter, taxoDir, indexDir);
     }
@@ -117,6 +119,7 @@
         String lastFile = files.get(files.size() - 1).fileName;
         assertTrue(lastFile.startsWith(IndexFileNames.SEGMENTS) && !lastFile.equals(IndexFileNames.SEGMENTS_GEN));
       }
+      indexWriter.shutdown();
     } finally {
       IOUtils.close(indexWriter, taxoWriter, taxoDir, indexDir);
     }
@@ -161,6 +164,7 @@
           IOUtils.close(src, in);
         }
       }
+      indexWriter.shutdown();
     } finally {
       IOUtils.close(indexWriter, taxoWriter, taxoDir, indexDir);
     }
Index: lucene/replicator/src/test/org/apache/lucene/replicator/LocalReplicatorTest.java
===================================================================
--- lucene/replicator/src/test/org/apache/lucene/replicator/LocalReplicatorTest.java	(revision 1584870)
+++ lucene/replicator/src/test/org/apache/lucene/replicator/LocalReplicatorTest.java	(working copy)
@@ -59,7 +59,8 @@
   @After
   @Override
   public void tearDown() throws Exception {
-    IOUtils.close(replicator, sourceWriter, sourceDir);
+    sourceWriter.shutdown();
+    IOUtils.close(replicator, sourceDir);
     super.tearDown();
   }
   
Index: lucene/replicator/src/test/org/apache/lucene/replicator/IndexAndTaxonomyReplicationClientTest.java
===================================================================
--- lucene/replicator/src/test/org/apache/lucene/replicator/IndexAndTaxonomyReplicationClientTest.java	(revision 1584870)
+++ lucene/replicator/src/test/org/apache/lucene/replicator/IndexAndTaxonomyReplicationClientTest.java	(working copy)
@@ -209,8 +209,9 @@
   @After
   @Override
   public void tearDown() throws Exception {
-    IOUtils.close(client, callback, publishIndexWriter, publishTaxoWriter, replicator, publishIndexDir, publishTaxoDir,
-        handlerIndexDir, handlerTaxoDir);
+    publishIndexWriter.shutdown();
+    IOUtils.close(client, callback, publishTaxoWriter, replicator, publishIndexDir, publishTaxoDir,
+            handlerIndexDir, handlerTaxoDir);
     super.tearDown();
   }
   
Index: lucene/replicator/src/test/org/apache/lucene/replicator/SessionTokenTest.java
===================================================================
--- lucene/replicator/src/test/org/apache/lucene/replicator/SessionTokenTest.java	(revision 1584870)
+++ lucene/replicator/src/test/org/apache/lucene/replicator/SessionTokenTest.java	(working copy)
@@ -57,8 +57,9 @@
     List<RevisionFile> files1 = session1.sourceFiles.values().iterator().next();
     List<RevisionFile> files2 = session2.sourceFiles.values().iterator().next();
     assertEquals(files1, files2);
-    
-    IOUtils.close(writer, dir);
+
+    writer.shutdown();
+    IOUtils.close(dir);
   }
   
 }
Index: lucene/suggest/src/java/org/apache/lucene/search/spell/SpellChecker.java
===================================================================
--- lucene/suggest/src/java/org/apache/lucene/search/spell/SpellChecker.java	(revision 1584870)
+++ lucene/suggest/src/java/org/apache/lucene/search/spell/SpellChecker.java	(working copy)
@@ -173,7 +173,7 @@
           IndexWriter writer = new IndexWriter(spellIndexDir,
             new IndexWriterConfig(Version.LUCENE_CURRENT,
                 null));
-          writer.close();
+          writer.shutdown();
       }
       swapSearcher(spellIndexDir);
     }
@@ -460,7 +460,7 @@
           Version.LUCENE_CURRENT,
           null)
           .setOpenMode(OpenMode.CREATE));
-      writer.close();
+      writer.shutdown();
       swapSearcher(dir);
     }
   }
@@ -542,7 +542,7 @@
         writer.forceMerge(1);
       }
       // close writer
-      writer.close();
+      writer.shutdown();
       // TODO: this isn't that great, maybe in the future SpellChecker should take
       // IWC in its ctor / keep its writer open?
       
Index: lucene/suggest/src/java/org/apache/lucene/search/suggest/analyzing/AnalyzingInfixSuggester.java
===================================================================
--- lucene/suggest/src/java/org/apache/lucene/search/suggest/analyzing/AnalyzingInfixSuggester.java	(revision 1584870)
+++ lucene/suggest/src/java/org/apache/lucene/search/suggest/analyzing/AnalyzingInfixSuggester.java	(working copy)
@@ -207,11 +207,10 @@
     }
 
     if (writer != null) {
-      writer.close();
+      writer.shutdown();
       writer = null;
     }
 
-    AtomicReader r = null;
     boolean success = false;
     try {
       // First pass: build a temporary normal Lucene index,
@@ -238,10 +237,8 @@
       searcherMgr = new SearcherManager(writer, true, null);
       success = true;
     } finally {
-      if (success) {
-        IOUtils.close(r);
-      } else {
-        IOUtils.closeWhileHandlingException(writer, r);
+      if (success == false) {
+        writer.rollback();
         writer = null;
       }
     }
@@ -640,7 +637,7 @@
       searcherMgr = null;
     }
     if (writer != null) {
-      writer.close();
+      writer.shutdown();
       dir.close();
       writer = null;
     }
Index: lucene/suggest/src/java/org/apache/lucene/search/suggest/analyzing/FreeTextSuggester.java
===================================================================
--- lucene/suggest/src/java/org/apache/lucene/search/suggest/analyzing/FreeTextSuggester.java	(revision 1584870)
+++ lucene/suggest/src/java/org/apache/lucene/search/suggest/analyzing/FreeTextSuggester.java	(working copy)
@@ -379,13 +379,17 @@
       pw.close();
       */
 
+      // Writer was only temporary, to count up bigrams,
+      // which we transferred to the FST, so now we
+      // rollback:
+      writer.rollback();
       success = true;
     } finally {
       try {
         if (success) {
-          IOUtils.close(writer, reader);
+          IOUtils.close(reader);
         } else {
-          IOUtils.closeWhileHandlingException(writer, reader);
+          IOUtils.closeWhileHandlingException(reader, writer);
         }
       } finally {
         for(String file : dir.listAll()) {
Index: lucene/suggest/src/test/org/apache/lucene/search/spell/TestDirectSpellChecker.java
===================================================================
--- lucene/suggest/src/test/org/apache/lucene/search/spell/TestDirectSpellChecker.java	(revision 1584870)
+++ lucene/suggest/src/test/org/apache/lucene/search/spell/TestDirectSpellChecker.java	(working copy)
@@ -56,7 +56,7 @@
     }
     
     ir.close();
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
   public void testSimpleExamples() throws Exception {
@@ -122,7 +122,7 @@
     assertEquals("thousand", similar[0].string);
 
     ir.close();
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
   
@@ -188,7 +188,7 @@
     assertEquals(2, similar.length);
 
     ir.close();
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
   
@@ -211,7 +211,7 @@
         SuggestMode.SUGGEST_WHEN_NOT_IN_INDEX);
     assertEquals(0, similar.length);
     ir.close();
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
   
@@ -236,7 +236,7 @@
     assertEquals(1, similar.length);
     assertEquals("five", similar[0].string);
     ir.close();
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
   
@@ -261,7 +261,7 @@
     assertEquals(1, similar.length);
     assertEquals("seventeen", similar[0].string);
     ir.close();
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
 }
Index: lucene/suggest/src/test/org/apache/lucene/search/spell/TestLuceneDictionary.java
===================================================================
--- lucene/suggest/src/test/org/apache/lucene/search/spell/TestLuceneDictionary.java	(revision 1584870)
+++ lucene/suggest/src/test/org/apache/lucene/search/spell/TestLuceneDictionary.java	(working copy)
@@ -74,7 +74,7 @@
     writer.addDocument(doc);
 
     writer.forceMerge(1);
-    writer.close();
+    writer.shutdown();
   }
 
   @Override
Index: lucene/suggest/src/test/org/apache/lucene/search/spell/TestSpellChecker.java
===================================================================
--- lucene/suggest/src/test/org/apache/lucene/search/spell/TestSpellChecker.java	(revision 1584870)
+++ lucene/suggest/src/test/org/apache/lucene/search/spell/TestSpellChecker.java	(working copy)
@@ -87,7 +87,7 @@
       writer.addDocument(doc);
     }
     
-    writer.close();
+    writer.shutdown();
     searchers = Collections.synchronizedList(new ArrayList<IndexSearcher>());
     // create the spellChecker
     spellindex = newDirectory();
Index: lucene/suggest/src/test/org/apache/lucene/search/spell/TestWordBreakSpellChecker.java
===================================================================
--- lucene/suggest/src/test/org/apache/lucene/search/spell/TestWordBreakSpellChecker.java	(revision 1584870)
+++ lucene/suggest/src/test/org/apache/lucene/search/spell/TestWordBreakSpellChecker.java	(working copy)
@@ -70,7 +70,7 @@
     }
     
     writer.commit();
-    writer.close();
+    writer.shutdown();
   }
   
   @Override
@@ -300,7 +300,7 @@
         writer.addDocument(doc);
       }
       writer.commit();
-      writer.close();
+      writer.shutdown();
       
       ir = DirectoryReader.open(dir);
       WordBreakSpellChecker wbsp = new WordBreakSpellChecker();
@@ -352,7 +352,7 @@
         ir.close();
       } catch (Exception e1) {}
       try {
-        writer.close();
+        writer.shutdown();
       } catch (Exception e1) {}
       try {
         dir.close();
Index: lucene/suggest/src/test/org/apache/lucene/search/suggest/DocumentValueSourceDictionaryTest.java
===================================================================
--- lucene/suggest/src/test/org/apache/lucene/search/suggest/DocumentValueSourceDictionaryTest.java	(revision 1584870)
+++ lucene/suggest/src/test/org/apache/lucene/search/suggest/DocumentValueSourceDictionaryTest.java	(working copy)
@@ -89,7 +89,7 @@
     // Make sure the index is created?
     RandomIndexWriter writer = new RandomIndexWriter(random(), dir, iwc);
     writer.commit();
-    writer.close();
+    writer.shutdown();
     IndexReader ir = DirectoryReader.open(dir);
     Dictionary dictionary = new DocumentValueSourceDictionary(ir, FIELD_NAME,  new DoubleConstValueSource(10), PAYLOAD_FIELD_NAME);
     InputIterator inputIterator = dictionary.getEntryIterator();
@@ -113,7 +113,7 @@
       writer.addDocument(doc);
     }
     writer.commit();
-    writer.close();
+    writer.shutdown();
 
     IndexReader ir = DirectoryReader.open(dir);
     ValueSource[] toAdd = new ValueSource[] {new LongFieldSource(WEIGHT_FIELD_NAME_1), new LongFieldSource(WEIGHT_FIELD_NAME_2), new LongFieldSource(WEIGHT_FIELD_NAME_3)};
@@ -145,7 +145,7 @@
       writer.addDocument(doc);
     }
     writer.commit();
-    writer.close();
+    writer.shutdown();
 
     IndexReader ir = DirectoryReader.open(dir);
     ValueSource[] toAdd = new ValueSource[] {new LongFieldSource(WEIGHT_FIELD_NAME_1), new LongFieldSource(WEIGHT_FIELD_NAME_2), new LongFieldSource(WEIGHT_FIELD_NAME_3)};
@@ -182,7 +182,7 @@
       writer.addDocument(doc);
     }
     writer.commit();
-    writer.close();
+    writer.shutdown();
 
     IndexReader ir = DirectoryReader.open(dir);
     ValueSource[] toAdd = new ValueSource[] {new LongFieldSource(WEIGHT_FIELD_NAME_1), new LongFieldSource(WEIGHT_FIELD_NAME_2), new LongFieldSource(WEIGHT_FIELD_NAME_3)};
@@ -229,7 +229,7 @@
       writer.deleteDocuments(delTerm);  
     }
     writer.commit();
-    writer.close();
+    writer.shutdown();
     
     for(String termToDel: termsToDel) {
       assertTrue(null!=docs.remove(termToDel));
@@ -268,7 +268,7 @@
       writer.addDocument(doc);
     }
     writer.commit();
-    writer.close();
+    writer.shutdown();
 
     IndexReader ir = DirectoryReader.open(dir);
     Dictionary dictionary = new DocumentValueSourceDictionary(ir, FIELD_NAME, new DoubleConstValueSource(10), PAYLOAD_FIELD_NAME);
Index: lucene/suggest/src/test/org/apache/lucene/search/suggest/TestHighFrequencyDictionary.java
===================================================================
--- lucene/suggest/src/test/org/apache/lucene/search/suggest/TestHighFrequencyDictionary.java	(revision 1584870)
+++ lucene/suggest/src/test/org/apache/lucene/search/suggest/TestHighFrequencyDictionary.java	(working copy)
@@ -32,7 +32,7 @@
     Directory dir = newDirectory();
     IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())));
     writer.commit();
-    writer.close();
+    writer.shutdown();
     IndexReader ir = DirectoryReader.open(dir);
     Dictionary dictionary = new HighFrequencyDictionary(ir, "bogus", 0.1f);
     BytesRefIterator tf = dictionary.getEntryIterator();
Index: lucene/suggest/src/test/org/apache/lucene/search/suggest/DocumentDictionaryTest.java
===================================================================
--- lucene/suggest/src/test/org/apache/lucene/search/suggest/DocumentDictionaryTest.java	(revision 1584870)
+++ lucene/suggest/src/test/org/apache/lucene/search/suggest/DocumentDictionaryTest.java	(working copy)
@@ -118,7 +118,7 @@
     // Make sure the index is created?
     RandomIndexWriter writer = new RandomIndexWriter(random(), dir, iwc);
     writer.commit();
-    writer.close();
+    writer.shutdown();
     IndexReader ir = DirectoryReader.open(dir);
     Dictionary dictionary = new DocumentDictionary(ir, FIELD_NAME, WEIGHT_FIELD_NAME, PAYLOAD_FIELD_NAME);
     InputIterator inputIterator = dictionary.getEntryIterator();
@@ -144,7 +144,7 @@
       writer.addDocument(doc);
     }
     writer.commit();
-    writer.close();
+    writer.shutdown();
     IndexReader ir = DirectoryReader.open(dir);
     Dictionary dictionary = new DocumentDictionary(ir, FIELD_NAME, WEIGHT_FIELD_NAME, PAYLOAD_FIELD_NAME);
     InputIterator inputIterator = dictionary.getEntryIterator();
@@ -179,7 +179,7 @@
       writer.addDocument(doc);
     }
     writer.commit();
-    writer.close();
+    writer.shutdown();
     IndexReader ir = DirectoryReader.open(dir);
     Dictionary dictionary = new DocumentDictionary(ir, FIELD_NAME, WEIGHT_FIELD_NAME);
     InputIterator inputIterator = dictionary.getEntryIterator();
@@ -215,7 +215,7 @@
       writer.addDocument(doc);
     }
     writer.commit();
-    writer.close();
+    writer.shutdown();
     IndexReader ir = DirectoryReader.open(dir);
     Dictionary dictionary = new DocumentDictionary(ir, FIELD_NAME, WEIGHT_FIELD_NAME, PAYLOAD_FIELD_NAME, CONTEXT_FIELD_NAME);
     InputIterator inputIterator = dictionary.getEntryIterator();
@@ -272,7 +272,7 @@
       writer.deleteDocuments(delTerm);  
     }
     writer.commit();
-    writer.close();
+    writer.shutdown();
     
     for(String termToDel: termsToDel) {
       assertTrue(null!=docs.remove(termToDel));
Index: lucene/grouping/src/test/org/apache/lucene/search/grouping/DistinctValuesCollectorTest.java
===================================================================
--- lucene/grouping/src/test/org/apache/lucene/search/grouping/DistinctValuesCollectorTest.java	(revision 1584870)
+++ lucene/grouping/src/test/org/apache/lucene/search/grouping/DistinctValuesCollectorTest.java	(working copy)
@@ -139,7 +139,7 @@
     w.addDocument(doc);
 
     IndexSearcher indexSearcher = newSearcher(w.getReader());
-    w.close();
+    w.shutdown();
 
     Comparator<AbstractDistinctValuesCollector.GroupCount<Comparable<Object>>> cmp = new Comparator<AbstractDistinctValuesCollector.GroupCount<Comparable<Object>>>() {
 
@@ -509,7 +509,7 @@
       }
     }
 
-    w.close();
+    w.shutdown();
     return new IndexContext(dir, reader, dvType, searchTermToGroupCounts, contentStrings.toArray(new String[contentStrings.size()]));
   }
 
Index: lucene/grouping/src/test/org/apache/lucene/search/grouping/TestGrouping.java
===================================================================
--- lucene/grouping/src/test/org/apache/lucene/search/grouping/TestGrouping.java	(revision 1584870)
+++ lucene/grouping/src/test/org/apache/lucene/search/grouping/TestGrouping.java	(working copy)
@@ -116,7 +116,7 @@
     w.addDocument(doc);
 
     IndexSearcher indexSearcher = newSearcher(w.getReader());
-    w.close();
+    w.shutdown();
 
     final Sort groupSort = Sort.RELEVANCE;
 
@@ -592,7 +592,7 @@
     }
 
     final DirectoryReader r = w.getReader();
-    w.close();
+    w.shutdown();
 
     return r;
   }
@@ -740,7 +740,7 @@
       System.arraycopy(groupDocs, 0, groupDocsByID, 0, groupDocs.length);
 
       final DirectoryReader r = w.getReader();
-      w.close();
+      w.shutdown();
 
       // NOTE: intentional but temporary field cache insanity!
       final FieldCache.Ints docIDToID = FieldCache.DEFAULT.getInts(SlowCompositeReaderWrapper.wrap(r), "id", false);
Index: lucene/grouping/src/test/org/apache/lucene/search/grouping/AllGroupsCollectorTest.java
===================================================================
--- lucene/grouping/src/test/org/apache/lucene/search/grouping/AllGroupsCollectorTest.java	(revision 1584870)
+++ lucene/grouping/src/test/org/apache/lucene/search/grouping/AllGroupsCollectorTest.java	(working copy)
@@ -102,7 +102,7 @@
     w.addDocument(doc);
 
     IndexSearcher indexSearcher = newSearcher(w.getReader());
-    w.close();
+    w.shutdown();
 
     AbstractAllGroupsCollector<?> allGroupsCollector = createRandomCollector(groupField);
     indexSearcher.search(new TermQuery(new Term("content", "random")), allGroupsCollector);
Index: lucene/grouping/src/test/org/apache/lucene/search/grouping/GroupingSearchTest.java
===================================================================
--- lucene/grouping/src/test/org/apache/lucene/search/grouping/GroupingSearchTest.java	(revision 1584870)
+++ lucene/grouping/src/test/org/apache/lucene/search/grouping/GroupingSearchTest.java	(working copy)
@@ -119,7 +119,7 @@
     w.addDocument(doc);
 
     IndexSearcher indexSearcher = newSearcher(w.getReader());
-    w.close();
+    w.shutdown();
 
     Sort groupSort = Sort.RELEVANCE;
     GroupingSearch groupingSearch = createRandomGroupingSearch(groupField, groupSort, 5, canUseIDV);
@@ -234,7 +234,7 @@
     w.addDocument(doc);
 
     IndexSearcher indexSearcher = newSearcher(w.getReader());
-    w.close();
+    w.shutdown();
 
     GroupingSearch gs = new GroupingSearch("group");
     gs.setAllGroups(true);
Index: lucene/grouping/src/test/org/apache/lucene/search/grouping/AllGroupHeadsCollectorTest.java
===================================================================
--- lucene/grouping/src/test/org/apache/lucene/search/grouping/AllGroupHeadsCollectorTest.java	(revision 1584870)
+++ lucene/grouping/src/test/org/apache/lucene/search/grouping/AllGroupHeadsCollectorTest.java	(working copy)
@@ -140,7 +140,7 @@
     IndexReader reader = w.getReader();
     IndexSearcher indexSearcher = newSearcher(reader);
 
-    w.close();
+    w.shutdown();
     int maxDoc = reader.maxDoc();
 
     Sort sortWithinGroup = new Sort(new SortField("id_1", SortField.Type.INT, true));
@@ -299,7 +299,7 @@
       }
 
       final DirectoryReader r = w.getReader();
-      w.close();
+      w.shutdown();
 
       // NOTE: intentional but temporary field cache insanity!
       final FieldCache.Ints docIdToFieldId = FieldCache.DEFAULT.getInts(SlowCompositeReaderWrapper.wrap(r), "id", false);
Index: lucene/grouping/src/test/org/apache/lucene/search/grouping/GroupFacetCollectorTest.java
===================================================================
--- lucene/grouping/src/test/org/apache/lucene/search/grouping/GroupFacetCollectorTest.java	(revision 1584870)
+++ lucene/grouping/src/test/org/apache/lucene/search/grouping/GroupFacetCollectorTest.java	(working copy)
@@ -271,7 +271,7 @@
     assertEquals("15", entries.get(1).getValue().utf8ToString());
     assertEquals(2, entries.get(1).getCount());
 
-    w.close();
+    w.shutdown();
     indexSearcher.getIndexReader().close();
     dir.close();
   }
@@ -344,7 +344,7 @@
     w.addDocument(doc);
     w.commit();
 
-    w.close();
+    w.shutdown();
     IndexSearcher indexSearcher = newSearcher(DirectoryReader.open(dir));
     AbstractGroupFacetCollector groupedAirportFacetCollector = createRandomCollector(groupField, "airport", null, true);
     indexSearcher.search(new MatchAllDocsQuery(), groupedAirportFacetCollector);
@@ -661,7 +661,7 @@
     }
 
     DirectoryReader reader = writer.getReader();
-    writer.close();
+    writer.shutdown();
 
     return new IndexContext(searchTermToFacetToGroups, reader, numDocs, dir, facetWithMostGroups, numGroups, contentBrs, uniqueFacetValues, useDv);
   }
Index: lucene/sandbox/src/test/org/apache/lucene/sandbox/queries/DuplicateFilterTest.java
===================================================================
--- lucene/sandbox/src/test/org/apache/lucene/sandbox/queries/DuplicateFilterTest.java	(revision 1584870)
+++ lucene/sandbox/src/test/org/apache/lucene/sandbox/queries/DuplicateFilterTest.java	(working copy)
@@ -61,7 +61,7 @@
     writer.forceMerge(1);
 
     reader = writer.getReader();
-    writer.close();
+    writer.shutdown();
     searcher = newSearcher(reader);
 
   }
Index: lucene/sandbox/src/test/org/apache/lucene/sandbox/queries/TestSlowFuzzyQuery.java
===================================================================
--- lucene/sandbox/src/test/org/apache/lucene/sandbox/queries/TestSlowFuzzyQuery.java	(revision 1584870)
+++ lucene/sandbox/src/test/org/apache/lucene/sandbox/queries/TestSlowFuzzyQuery.java	(working copy)
@@ -58,7 +58,7 @@
 
     IndexReader reader = writer.getReader();
     IndexSearcher searcher = newSearcher(reader);
-    writer.close();
+    writer.shutdown();
 
     SlowFuzzyQuery query = new SlowFuzzyQuery(new Term("field", "aaaaa"), SlowFuzzyQuery.defaultMinSimilarity, 0);   
     ScoreDoc[] hits = searcher.search(query, null, 1000).scoreDocs;
@@ -206,7 +206,7 @@
 
      IndexReader reader = writer.getReader();
      IndexSearcher searcher = newSearcher(reader);
-     writer.close();
+     writer.shutdown();
 
      SlowFuzzyQuery query;
      
@@ -229,7 +229,7 @@
 
     IndexReader reader = writer.getReader();
     IndexSearcher searcher = newSearcher(reader);
-    writer.close();
+    writer.shutdown();
 
     SlowFuzzyQuery query;
     // not similar enough:
@@ -345,8 +345,8 @@
     mr.close();
     ir1.close();
     ir2.close();
-    writer.close();
-    writer2.close();
+    writer.shutdown();
+    writer2.shutdown();
     directory.close();
     directory2.close(); 
   }
@@ -359,7 +359,7 @@
 
     IndexReader reader = writer.getReader();
     IndexSearcher searcher = newSearcher(reader);
-    writer.close();
+    writer.shutdown();
 
     Query query;
     // term not over 10 chars, so optimization shortcuts
@@ -396,7 +396,7 @@
 
     IndexReader reader = writer.getReader();
     IndexSearcher searcher = newSearcher(reader);
-    writer.close();
+    writer.shutdown();
     
     SlowFuzzyQuery query = new SlowFuzzyQuery(new Term("field", "lucene"));
     query.setRewriteMethod(new MultiTermQuery.TopTermsBoostOnlyBooleanQueryRewrite(50));
@@ -433,7 +433,7 @@
     addDoc("Brute willis", w);
     addDoc("B. willis", w);
     IndexReader r = w.getReader();
-    w.close();
+    w.shutdown();
 
     Query q = new SlowFuzzyQuery(new Term("field", "giga"), 0.9f);
 
@@ -454,7 +454,7 @@
     addDoc("working", w);
     IndexReader reader = w.getReader();
     IndexSearcher searcher = newSearcher(reader);
-    w.close();
+    w.shutdown();
     
     SlowFuzzyQuery q = new SlowFuzzyQuery(new Term("field", "fouba"), 2);
     ScoreDoc[] hits = searcher.search(q, 10).scoreDocs;
Index: lucene/sandbox/src/test/org/apache/lucene/sandbox/queries/TestSortedSetSortField.java
===================================================================
--- lucene/sandbox/src/test/org/apache/lucene/sandbox/queries/TestSortedSetSortField.java	(revision 1584870)
+++ lucene/sandbox/src/test/org/apache/lucene/sandbox/queries/TestSortedSetSortField.java	(working copy)
@@ -49,7 +49,7 @@
     doc.add(newStringField("id", "1", Field.Store.YES));
     writer.addDocument(doc);
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     Sort sort = new Sort(new SortedSetSortField("value", false));
@@ -78,7 +78,7 @@
     writer.addDocument(doc);
 
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     Sort sort = new Sort(new SortedSetSortField("value", true));
@@ -109,7 +109,7 @@
     doc.add(newStringField("id", "3", Field.Store.YES));
     writer.addDocument(doc);
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     SortField sortField = new SortedSetSortField("value", false);
@@ -144,7 +144,7 @@
     doc.add(newStringField("id", "3", Field.Store.YES));
     writer.addDocument(doc);
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     SortField sortField = new SortedSetSortField("value", false);
@@ -175,7 +175,7 @@
     doc.add(newStringField("id", "1", Field.Store.YES));
     writer.addDocument(doc);
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     Sort sort = new Sort(new SortedSetSortField("value", false));
Index: lucene/sandbox/src/test/org/apache/lucene/sandbox/queries/regex/TestRegexQuery.java
===================================================================
--- lucene/sandbox/src/test/org/apache/lucene/sandbox/queries/regex/TestRegexQuery.java	(revision 1584870)
+++ lucene/sandbox/src/test/org/apache/lucene/sandbox/queries/regex/TestRegexQuery.java	(working copy)
@@ -50,7 +50,7 @@
     doc.add(newTextField(FN, "the quick brown fox jumps over the lazy dog", Field.Store.NO));
     writer.addDocument(doc);
     reader = writer.getReader();
-    writer.close();
+    writer.shutdown();
     searcher = newSearcher(reader);
   }
 
Index: lucene/sandbox/src/test/org/apache/lucene/sandbox/queries/regex/TestSpanRegexQuery.java
===================================================================
--- lucene/sandbox/src/test/org/apache/lucene/sandbox/queries/regex/TestSpanRegexQuery.java	(revision 1584870)
+++ lucene/sandbox/src/test/org/apache/lucene/sandbox/queries/regex/TestSpanRegexQuery.java	(working copy)
@@ -66,7 +66,7 @@
     doc.add(newTextField("field", "first auto update", Field.Store.NO));
     writer.addDocument(doc);
     writer.forceMerge(1);
-    writer.close();
+    writer.shutdown();
 
     IndexReader reader = DirectoryReader.open(directory);
     IndexSearcher searcher = newSearcher(reader);
Index: lucene/sandbox/src/test/org/apache/lucene/sandbox/queries/TestSortedSetSortFieldDocValues.java
===================================================================
--- lucene/sandbox/src/test/org/apache/lucene/sandbox/queries/TestSortedSetSortFieldDocValues.java	(revision 1584870)
+++ lucene/sandbox/src/test/org/apache/lucene/sandbox/queries/TestSortedSetSortFieldDocValues.java	(working copy)
@@ -62,7 +62,7 @@
     doc.add(newStringField("id", "1", Field.Store.YES));
     writer.addDocument(doc);
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     Sort sort = new Sort(new SortedSetSortField("value", false));
@@ -92,7 +92,7 @@
     writer.addDocument(doc);
 
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     Sort sort = new Sort(new SortedSetSortField("value", true));
@@ -124,7 +124,7 @@
     doc.add(newStringField("id", "3", Field.Store.YES));
     writer.addDocument(doc);
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     SortField sortField = new SortedSetSortField("value", false);
@@ -160,7 +160,7 @@
     doc.add(newStringField("id", "3", Field.Store.YES));
     writer.addDocument(doc);
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     SortField sortField = new SortedSetSortField("value", false);
@@ -192,7 +192,7 @@
     doc.add(newStringField("id", "1", Field.Store.YES));
     writer.addDocument(doc);
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     Sort sort = new Sort(new SortedSetSortField("value", false));
Index: lucene/sandbox/src/test/org/apache/lucene/sandbox/queries/TestSlowFuzzyQuery2.java
===================================================================
--- lucene/sandbox/src/test/org/apache/lucene/sandbox/queries/TestSlowFuzzyQuery2.java	(revision 1584870)
+++ lucene/sandbox/src/test/org/apache/lucene/sandbox/queries/TestSlowFuzzyQuery2.java	(working copy)
@@ -110,7 +110,7 @@
     // otherwise scores are different!
     searcher.setSimilarity(new DefaultSimilarity());
     
-    writer.close();
+    writer.shutdown();
     String line;
     while ((line = reader.readLine()) != null) {
       String params[] = line.split(",");
Index: lucene/sandbox/src/test/org/apache/lucene/sandbox/queries/FuzzyLikeThisQueryTest.java
===================================================================
--- lucene/sandbox/src/test/org/apache/lucene/sandbox/queries/FuzzyLikeThisQueryTest.java	(revision 1584870)
+++ lucene/sandbox/src/test/org/apache/lucene/sandbox/queries/FuzzyLikeThisQueryTest.java	(working copy)
@@ -57,7 +57,7 @@
     addDoc(writer, "jonny smith", "5");
     addDoc(writer, "johnathon smythe", "6");
     reader = writer.getReader();
-    writer.close();
+    writer.shutdown();
     searcher = newSearcher(reader);
   }
 
Index: lucene/sandbox/src/test/org/apache/lucene/sandbox/queries/TestSortedSetSortFieldSelectors.java
===================================================================
--- lucene/sandbox/src/test/org/apache/lucene/sandbox/queries/TestSortedSetSortFieldSelectors.java	(revision 1584870)
+++ lucene/sandbox/src/test/org/apache/lucene/sandbox/queries/TestSortedSetSortFieldSelectors.java	(working copy)
@@ -86,7 +86,7 @@
     doc.add(newStringField("id", "2", Field.Store.YES));
     writer.addDocument(doc);
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
 
     // slow wrapper does not support random access ordinals (there is no need for that!)
     IndexSearcher searcher = newSearcher(ir, false);
@@ -117,7 +117,7 @@
     doc.add(newStringField("id", "2", Field.Store.YES));
     writer.addDocument(doc);
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     // slow wrapper does not support random access ordinals (there is no need for that!)
     IndexSearcher searcher = newSearcher(ir, false);
@@ -151,7 +151,7 @@
     doc.add(newStringField("id", "3", Field.Store.YES));
     writer.addDocument(doc);
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
 
     // slow wrapper does not support random access ordinals (there is no need for that!)
     IndexSearcher searcher = newSearcher(ir, false);
@@ -189,7 +189,7 @@
     doc.add(newStringField("id", "3", Field.Store.YES));
     writer.addDocument(doc);
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
 
     // slow wrapper does not support random access ordinals (there is no need for that!)
     IndexSearcher searcher = newSearcher(ir, false);
@@ -223,7 +223,7 @@
     doc.add(newStringField("id", "1", Field.Store.YES));
     writer.addDocument(doc);
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     // slow wrapper does not support random access ordinals (there is no need for that!)
     IndexSearcher searcher = newSearcher(ir, false);
@@ -255,7 +255,7 @@
     doc.add(newStringField("id", "1", Field.Store.YES));
     writer.addDocument(doc);
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     // slow wrapper does not support random access ordinals (there is no need for that!)
     IndexSearcher searcher = newSearcher(ir, false);
@@ -287,7 +287,7 @@
     doc.add(newStringField("id", "2", Field.Store.YES));
     writer.addDocument(doc);
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     // slow wrapper does not support random access ordinals (there is no need for that!)
     IndexSearcher searcher = newSearcher(ir, false);
@@ -322,7 +322,7 @@
     doc.add(newStringField("id", "1", Field.Store.YES));
     writer.addDocument(doc);
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     // slow wrapper does not support random access ordinals (there is no need for that!)
     IndexSearcher searcher = newSearcher(ir, false);
@@ -361,7 +361,7 @@
     doc.add(newStringField("id", "1", Field.Store.YES));
     writer.addDocument(doc);
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     // slow wrapper does not support random access ordinals (there is no need for that!)
     IndexSearcher searcher = newSearcher(ir, false);
@@ -394,7 +394,7 @@
     doc.add(newStringField("id", "1", Field.Store.YES));
     writer.addDocument(doc);
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     // slow wrapper does not support random access ordinals (there is no need for that!)
     IndexSearcher searcher = newSearcher(ir, false);
@@ -426,7 +426,7 @@
     doc.add(newStringField("id", "2", Field.Store.YES));
     writer.addDocument(doc);
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     // slow wrapper does not support random access ordinals (there is no need for that!)
     IndexSearcher searcher = newSearcher(ir, false);
@@ -458,7 +458,7 @@
     doc.add(newStringField("id", "1", Field.Store.YES));
     writer.addDocument(doc);
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     // slow wrapper does not support random access ordinals (there is no need for that!)
     IndexSearcher searcher = newSearcher(ir, false);
@@ -493,7 +493,7 @@
     doc.add(newStringField("id", "2", Field.Store.YES));
     writer.addDocument(doc);
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     // slow wrapper does not support random access ordinals (there is no need for that!)
     IndexSearcher searcher = newSearcher(ir, false);
@@ -532,7 +532,7 @@
     doc.add(newStringField("id", "2", Field.Store.YES));
     writer.addDocument(doc);
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     // slow wrapper does not support random access ordinals (there is no need for that!)
     IndexSearcher searcher = newSearcher(ir, false);
@@ -565,7 +565,7 @@
     doc.add(newStringField("id", "1", Field.Store.YES));
     writer.addDocument(doc);
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     // slow wrapper does not support random access ordinals (there is no need for that!)
     IndexSearcher searcher = newSearcher(ir, false);
Index: lucene/sandbox/src/test/org/apache/lucene/sandbox/queries/TestSlowCollationMethods.java
===================================================================
--- lucene/sandbox/src/test/org/apache/lucene/sandbox/queries/TestSlowCollationMethods.java	(revision 1584870)
+++ lucene/sandbox/src/test/org/apache/lucene/sandbox/queries/TestSlowCollationMethods.java	(working copy)
@@ -62,7 +62,7 @@
     }
     splitDoc = TestUtil.randomUnicodeString(random());
     reader = iw.getReader();
-    iw.close();
+    iw.shutdown();
 
     searcher = newSearcher(reader);
   }
@@ -168,7 +168,7 @@
       iw.addDocument(doc);
     }
     IndexReader reader = iw.getReader();
-    iw.close();
+    iw.shutdown();
 
     IndexSearcher searcher = newSearcher(reader);
 
Index: lucene/codecs/src/test/org/apache/lucene/codecs/pulsing/Test10KPulsings.java
===================================================================
--- lucene/codecs/src/test/org/apache/lucene/codecs/pulsing/Test10KPulsings.java	(revision 1584870)
+++ lucene/codecs/src/test/org/apache/lucene/codecs/pulsing/Test10KPulsings.java	(working copy)
@@ -78,7 +78,7 @@
     }
     
     IndexReader ir = iw.getReader();
-    iw.close();
+    iw.shutdown();
 
     TermsEnum te = MultiFields.getTerms(ir, "field").iterator(null);
     DocsEnum de = null;
@@ -136,7 +136,7 @@
     }
     
     IndexReader ir = iw.getReader();
-    iw.close();
+    iw.shutdown();
 
     TermsEnum te = MultiFields.getTerms(ir, "field").iterator(null);
     DocsEnum de = null;
Index: lucene/codecs/src/test/org/apache/lucene/codecs/pulsing/TestPulsingReuse.java
===================================================================
--- lucene/codecs/src/test/org/apache/lucene/codecs/pulsing/TestPulsingReuse.java	(revision 1584870)
+++ lucene/codecs/src/test/org/apache/lucene/codecs/pulsing/TestPulsingReuse.java	(working copy)
@@ -52,7 +52,7 @@
     doc.add(new TextField("foo", "a b b c c c d e f g g h i i j j k", Field.Store.NO));
     iw.addDocument(doc);
     DirectoryReader ir = iw.getReader();
-    iw.close();
+    iw.shutdown();
     
     AtomicReader segment = getOnlySegmentReader(ir);
     DocsEnum reuse = null;
@@ -93,7 +93,7 @@
     // but this seems 'good enough' for now.
     iw.addDocument(doc);
     DirectoryReader ir = iw.getReader();
-    iw.close();
+    iw.shutdown();
     
     AtomicReader segment = getOnlySegmentReader(ir);
     DocsEnum reuse = null;
Index: lucene/facet/src/test/org/apache/lucene/facet/taxonomy/TestTaxonomyFacetCounts.java
===================================================================
--- lucene/facet/src/test/org/apache/lucene/facet/taxonomy/TestTaxonomyFacetCounts.java	(revision 1584870)
+++ lucene/facet/src/test/org/apache/lucene/facet/taxonomy/TestTaxonomyFacetCounts.java	(working copy)
@@ -141,7 +141,8 @@
     assertTrue(result.indexOf("  /2012") != -1);
     assertTrue(result.indexOf("      /20") != -1);
 
-    IOUtils.close(writer, taxoWriter, searcher.getIndexReader(), taxoReader, taxoDir, dir);
+    writer.shutdown();
+    IOUtils.close(taxoWriter, searcher.getIndexReader(), taxoReader, taxoDir, dir);
   }
 
   // LUCENE-5333
@@ -198,7 +199,8 @@
     assertEquals("dim=b path=[] value=2 childCount=2\n  bar1 (1)\n  bar2 (1)\n", results.get(1).toString());
     assertEquals("dim=c path=[] value=1 childCount=1\n  baz1 (1)\n", results.get(2).toString());
 
-    IOUtils.close(writer, taxoWriter, searcher.getIndexReader(), taxoReader, taxoDir, dir);
+    writer.shutdown();
+    IOUtils.close(taxoWriter, searcher.getIndexReader(), taxoReader, taxoDir, dir);
   }
 
   public void testWrongIndexFieldName() throws Exception {
@@ -256,7 +258,8 @@
       // expected
     }
 
-    IOUtils.close(writer, taxoWriter, searcher.getIndexReader(), taxoReader, taxoDir, dir);
+    writer.shutdown();
+    IOUtils.close(taxoWriter, searcher.getIndexReader(), taxoReader, taxoDir, dir);
   }
 
   public void testReallyNoNormsForDrillDown() throws Exception {
@@ -280,7 +283,8 @@
     doc.add(newTextField("field", "text", Field.Store.NO));
     doc.add(new FacetField("a", "path"));
     writer.addDocument(config.build(taxoWriter, doc));
-    IOUtils.close(writer, taxoWriter, dir, taxoDir);
+    writer.shutdown();
+    IOUtils.close(taxoWriter, dir, taxoDir);
   }
 
   public void testMultiValuedHierarchy() throws Exception {
@@ -325,7 +329,8 @@
     assertEquals(1, result.labelValues.length);
     assertEquals(1, result.labelValues[0].value.intValue());
 
-    IOUtils.close(writer, taxoWriter, searcher.getIndexReader(), taxoReader, dir, taxoDir);
+    writer.shutdown();
+    IOUtils.close(taxoWriter, searcher.getIndexReader(), taxoReader, dir, taxoDir);
   }
 
   public void testLabelWithDelimiter() throws Exception {
@@ -358,7 +363,8 @@
 
     FacetResult result = facets.getTopChildren(10, "dim");
     assertEquals("dim=dim path=[] value=-1 childCount=2\n  test\u001Fone (1)\n  test\u001Etwo (1)\n", result.toString());
-    IOUtils.close(writer, taxoWriter, searcher.getIndexReader(), taxoReader, dir, taxoDir);
+    writer.shutdown();
+    IOUtils.close(taxoWriter, searcher.getIndexReader(), taxoReader, dir, taxoDir);
   }
 
   public void testRequireDimCount() throws Exception {
@@ -407,7 +413,8 @@
     }
     assertEquals(1, facets.getSpecificValue("dim2"));
     assertEquals(1, facets.getSpecificValue("dim3"));
-    IOUtils.close(writer, taxoWriter, searcher.getIndexReader(), taxoReader, dir, taxoDir);
+    writer.shutdown();
+    IOUtils.close(taxoWriter, searcher.getIndexReader(), taxoReader, dir, taxoDir);
   }
 
   // LUCENE-4583: make sure if we require > 32 KB for one
@@ -456,8 +463,9 @@
       assertEquals(1, labelValue.value.intValue());
     }
     assertEquals(numLabels, allLabels.size());
-    
-    IOUtils.close(searcher.getIndexReader(), taxoWriter, writer, taxoReader, dir, taxoDir);
+
+    writer.shutdown();
+    IOUtils.close(searcher.getIndexReader(), taxoWriter, taxoReader, dir, taxoDir);
   }
 
   // Make sure we catch when app didn't declare field as
@@ -478,7 +486,8 @@
     } catch (IllegalArgumentException iae) {
       // expected
     }
-    IOUtils.close(writer, taxoWriter, dir, taxoDir);
+    writer.shutdown();
+    IOUtils.close(taxoWriter, dir, taxoDir);
   }
 
   // Make sure we catch when app didn't declare field as
@@ -500,7 +509,8 @@
     } catch (IllegalArgumentException iae) {
       // expected
     }
-    IOUtils.close(writer, taxoWriter, dir, taxoDir);
+    writer.shutdown();
+    IOUtils.close(taxoWriter, dir, taxoDir);
   }
 
   public void testSeparateIndexedFields() throws Exception {
@@ -529,7 +539,8 @@
     Facets facets2 = getTaxonomyFacetCounts(taxoReader, config, sfc, "$b");
     assertEquals(r.maxDoc(), facets1.getTopChildren(10, "a").value.intValue());
     assertEquals(r.maxDoc(), facets2.getTopChildren(10, "b").value.intValue());
-    IOUtils.close(taxoWriter, iw, taxoReader, taxoDir, r, indexDir);
+    iw.shutdown();
+    IOUtils.close(taxoWriter, taxoReader, taxoDir, r, indexDir);
   }
   
   public void testCountRoot() throws Exception {
@@ -556,8 +567,9 @@
     for (FacetResult result : facets.getAllDims(10)) {
       assertEquals(r.numDocs(), result.value.intValue());
     }
-    
-    IOUtils.close(taxoWriter, iw, taxoReader, taxoDir, r, indexDir);
+
+    iw.shutdown();
+    IOUtils.close(taxoWriter, taxoReader, taxoDir, r, indexDir);
   }
 
   public void testGetFacetResultsTwice() throws Exception {
@@ -584,8 +596,9 @@
     List<FacetResult> res1 = facets.getAllDims(10);
     List<FacetResult> res2 = facets.getAllDims(10);
     assertEquals("calling getFacetResults twice should return the .equals()=true result", res1, res2);
-    
-    IOUtils.close(taxoWriter, iw, taxoReader, taxoDir, r, indexDir);
+
+    iw.shutdown();
+    IOUtils.close(taxoWriter, taxoReader, taxoDir, r, indexDir);
   }
   
   public void testChildCount() throws Exception {
@@ -611,7 +624,8 @@
     
     assertEquals(10, facets.getTopChildren(2, "a").childCount);
 
-    IOUtils.close(taxoWriter, iw, taxoReader, taxoDir, r, indexDir);
+    iw.shutdown();
+    IOUtils.close(taxoWriter, taxoReader, taxoDir, r, indexDir);
   }
 
   private void indexTwoDocs(TaxonomyWriter taxoWriter, IndexWriter indexWriter, FacetsConfig config, boolean withContent) throws Exception {
@@ -649,7 +663,8 @@
     indexTwoDocs(taxoWriter, indexWriter, null, true);         // 5th segment, with content, no categories
     indexTwoDocs(taxoWriter, indexWriter, config, true);  // 6th segment, with content, with categories
     indexTwoDocs(taxoWriter, indexWriter, null, true);         // 7th segment, with content, no categories
-    IOUtils.close(indexWriter, taxoWriter);
+    indexWriter.shutdown();
+    IOUtils.close(taxoWriter);
 
     DirectoryReader indexReader = DirectoryReader.open(indexDir);
     TaxonomyReader taxoReader = new DirectoryTaxonomyReader(taxoDir);
@@ -753,6 +768,7 @@
       assertEquals(expected, actual);
     }
 
-    IOUtils.close(w, tw, searcher.getIndexReader(), tr, indexDir, taxoDir);
+    w.shutdown();
+    IOUtils.close(tw, searcher.getIndexReader(), tr, indexDir, taxoDir);
   }
 }
Index: lucene/facet/src/test/org/apache/lucene/facet/taxonomy/TestTaxonomyFacetSumValueSource.java
===================================================================
--- lucene/facet/src/test/org/apache/lucene/facet/taxonomy/TestTaxonomyFacetSumValueSource.java	(revision 1584870)
+++ lucene/facet/src/test/org/apache/lucene/facet/taxonomy/TestTaxonomyFacetSumValueSource.java	(working copy)
@@ -106,7 +106,7 @@
 
     // NRT open
     IndexSearcher searcher = newSearcher(writer.getReader());
-    writer.close();
+    writer.shutdown();
 
     // NRT open
     TaxonomyReader taxoReader = new DirectoryTaxonomyReader(taxoWriter);
@@ -172,7 +172,7 @@
 
     // NRT open
     IndexSearcher searcher = newSearcher(writer.getReader());
-    writer.close();
+    writer.shutdown();
 
     // NRT open
     TaxonomyReader taxoReader = new DirectoryTaxonomyReader(taxoWriter);
@@ -215,7 +215,7 @@
 
     // NRT open
     IndexSearcher searcher = newSearcher(writer.getReader());
-    writer.close();
+    writer.shutdown();
 
     // NRT open
     TaxonomyReader taxoReader = new DirectoryTaxonomyReader(taxoWriter);
@@ -278,8 +278,9 @@
     
     int expected = (int) (td.getMaxScore() * td.totalHits);
     assertEquals(expected, facets.getSpecificValue("dim", "a").intValue());
-    
-    IOUtils.close(iw, taxoWriter, taxoReader, taxoDir, r, indexDir);
+
+    iw.shutdown();
+    IOUtils.close(taxoWriter, taxoReader, taxoDir, r, indexDir);
   }
   
   public void testNoScore() throws Exception {
@@ -303,8 +304,9 @@
     newSearcher(r).search(new MatchAllDocsQuery(), sfc);
     Facets facets = new TaxonomyFacetSumValueSource(taxoReader, config, sfc, new LongFieldSource("price"));
     assertEquals("dim=a path=[] value=10.0 childCount=2\n  1 (6.0)\n  0 (4.0)\n", facets.getTopChildren(10, "a").toString());
-    
-    IOUtils.close(taxoWriter, iw, taxoReader, taxoDir, r, indexDir);
+
+    iw.shutdown();
+    IOUtils.close(taxoWriter, taxoReader, taxoDir, r, indexDir);
   }
 
   public void testWithScore() throws Exception {
@@ -354,8 +356,9 @@
     Facets facets = new TaxonomyFacetSumValueSource(taxoReader, config, fc, valueSource);
     
     assertEquals("dim=a path=[] value=10.0 childCount=2\n  1 (6.0)\n  0 (4.0)\n", facets.getTopChildren(10, "a").toString());
-    
-    IOUtils.close(taxoWriter, iw, taxoReader, taxoDir, r, indexDir);
+
+    iw.shutdown();
+    IOUtils.close(taxoWriter, taxoReader, taxoDir, r, indexDir);
   }
 
   public void testRollupValues() throws Exception {
@@ -384,8 +387,9 @@
     Facets facets = new TaxonomyFacetSumValueSource(taxoReader, config, sfc, valueSource);
     
     assertEquals("dim=a path=[] value=10.0 childCount=2\n  1 (6.0)\n  0 (4.0)\n", facets.getTopChildren(10, "a").toString());
-    
-    IOUtils.close(taxoWriter, iw, taxoReader, taxoDir, r, indexDir);
+
+    iw.shutdown();
+    IOUtils.close(taxoWriter, taxoReader, taxoDir, r, indexDir);
   }
 
   public void testCountAndSumScore() throws Exception {
@@ -416,7 +420,8 @@
 
     assertEquals(r.maxDoc(), facets1.getTopChildren(10, "a").value.intValue());
     assertEquals(r.maxDoc(), facets2.getTopChildren(10, "b").value.doubleValue(), 1E-10);
-    IOUtils.close(taxoWriter, iw, taxoReader, taxoDir, r, indexDir);
+    iw.shutdown();
+    IOUtils.close(taxoWriter, taxoReader, taxoDir, r, indexDir);
   }
 
   public void testRandom() throws Exception {
@@ -512,6 +517,7 @@
       assertFloatValuesEquals(expected, actual);
     }
 
-    IOUtils.close(w, tw, searcher.getIndexReader(), tr, indexDir, taxoDir);
+    w.shutdown();
+    IOUtils.close(tw, searcher.getIndexReader(), tr, indexDir, taxoDir);
   }
 }
Index: lucene/facet/src/test/org/apache/lucene/facet/taxonomy/directory/TestDirectoryTaxonomyWriter.java
===================================================================
--- lucene/facet/src/test/org/apache/lucene/facet/taxonomy/directory/TestDirectoryTaxonomyWriter.java	(revision 1584870)
+++ lucene/facet/src/test/org/apache/lucene/facet/taxonomy/directory/TestDirectoryTaxonomyWriter.java	(working copy)
@@ -225,7 +225,7 @@
     Directory dir = newDirectory();
     
     // create an empty index first, so that DirTaxoWriter initializes indexEpoch to 1.
-    new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, null)).close();
+    new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, null)).shutdown();
     
     DirectoryTaxonomyWriter taxoWriter = new DirectoryTaxonomyWriter(dir, OpenMode.CREATE_OR_APPEND, NO_OP_CACHE);
     taxoWriter.close();
@@ -465,9 +465,10 @@
 
     // when too large components were allowed to be added, this resulted in a new added category
     assertEquals(ordinal, taxoWriter.addCategory(cp));
+
+    indexWriter.shutdown();
+    IOUtils.close(taxoWriter);
     
-    IOUtils.close(indexWriter, taxoWriter);
-    
     DirectoryReader indexReader = DirectoryReader.open(indexDir);
     TaxonomyReader taxoReader = new DirectoryTaxonomyReader(taxoDir);
     IndexSearcher searcher = new IndexSearcher(indexReader);
Index: lucene/facet/src/test/org/apache/lucene/facet/taxonomy/directory/TestConcurrentFacetedIndexing.java
===================================================================
--- lucene/facet/src/test/org/apache/lucene/facet/taxonomy/directory/TestConcurrentFacetedIndexing.java	(revision 1584870)
+++ lucene/facet/src/test/org/apache/lucene/facet/taxonomy/directory/TestConcurrentFacetedIndexing.java	(working copy)
@@ -153,7 +153,8 @@
       }
     }
 
-    IOUtils.close(tw, iw, tr, taxoDir, indexDir);
+    iw.shutdown();
+    IOUtils.close(tw, tr, taxoDir, indexDir);
   }
 
 }
Index: lucene/facet/src/test/org/apache/lucene/facet/taxonomy/TestCachedOrdinalsReader.java
===================================================================
--- lucene/facet/src/test/org/apache/lucene/facet/taxonomy/TestCachedOrdinalsReader.java	(revision 1584870)
+++ lucene/facet/src/test/org/apache/lucene/facet/taxonomy/TestCachedOrdinalsReader.java	(working copy)
@@ -80,7 +80,8 @@
         assertEquals(ramBytesUsed, ordsReader.ramBytesUsed());
       }
     }
-    
-    IOUtils.close(writer, taxoWriter, reader, indexDir, taxoDir);
+
+    writer.shutdown();
+    IOUtils.close(taxoWriter, reader, indexDir, taxoDir);
   }
 }
Index: lucene/facet/src/test/org/apache/lucene/facet/taxonomy/TestSearcherTaxonomyManager.java
===================================================================
--- lucene/facet/src/test/org/apache/lucene/facet/taxonomy/TestSearcherTaxonomyManager.java	(revision 1584870)
+++ lucene/facet/src/test/org/apache/lucene/facet/taxonomy/TestSearcherTaxonomyManager.java	(working copy)
@@ -203,7 +203,8 @@
       System.out.println("TEST: now stop");
     }
 
-    IOUtils.close(mgr, tw, w, taxoDir, dir);
+    w.shutdown();
+    IOUtils.close(mgr, tw, taxoDir, dir);
   }
   
   public void testDirectory() throws Exception {
@@ -255,7 +256,8 @@
       System.out.println("TEST: now stop");
     }
 
-    IOUtils.close(mgr, tw, w, taxoDir, indexDir);
+    w.shutdown();
+    IOUtils.close(mgr, tw, taxoDir, indexDir);
   }
   
   public void testReplaceTaxonomyNRT() throws Exception {
@@ -280,7 +282,8 @@
       // expected
     }
 
-    IOUtils.close(mgr, tw, w, taxoDir, dir);
+    w.shutdown();
+    IOUtils.close(mgr, tw, taxoDir, dir);
   }
   
   public void testReplaceTaxonomyDirectory() throws Exception {
@@ -318,7 +321,8 @@
       mgr.release(pair);
     }
 
-    IOUtils.close(mgr, tw, w, taxoDir, indexDir);
+    w.shutdown();
+    IOUtils.close(mgr, tw, taxoDir, indexDir);
   }
 
 }
Index: lucene/facet/src/test/org/apache/lucene/facet/taxonomy/TestTaxonomyFacetCounts2.java
===================================================================
--- lucene/facet/src/test/org/apache/lucene/facet/taxonomy/TestTaxonomyFacetCounts2.java	(revision 1584870)
+++ lucene/facet/src/test/org/apache/lucene/facet/taxonomy/TestTaxonomyFacetCounts2.java	(working copy)
@@ -260,8 +260,9 @@
     
     // segment w/ categories and some content
     indexDocsWithFacetsAndSomeTerms(indexWriter, taxoWriter, allExpectedCounts);
-    
-    IOUtils.close(indexWriter, taxoWriter);
+
+    indexWriter.shutdown();
+    IOUtils.close(taxoWriter);
   }
   
   @Test
Index: lucene/facet/src/test/org/apache/lucene/facet/taxonomy/TestTaxonomyFacetAssociations.java
===================================================================
--- lucene/facet/src/test/org/apache/lucene/facet/taxonomy/TestTaxonomyFacetAssociations.java	(revision 1584870)
+++ lucene/facet/src/test/org/apache/lucene/facet/taxonomy/TestTaxonomyFacetAssociations.java	(working copy)
@@ -86,7 +86,7 @@
     
     taxoWriter.close();
     reader = writer.getReader();
-    writer.close();
+    writer.shutdown();
     taxoReader = new DirectoryTaxonomyReader(taxoDir);
   }
   
@@ -182,7 +182,8 @@
     } catch (IllegalArgumentException exc) {
       // expected
     }
-    IOUtils.close(writer, taxoWriter, dir, taxoDir);
+    writer.shutdown();
+    IOUtils.close(taxoWriter, dir, taxoDir);
   }
 
   public void testNoHierarchy() throws Exception {
@@ -202,7 +203,8 @@
     } catch (IllegalArgumentException exc) {
       // expected
     }
-    IOUtils.close(writer, taxoWriter, dir, taxoDir);
+    writer.shutdown();
+    IOUtils.close(taxoWriter, dir, taxoDir);
   }
 
   public void testRequireDimCount() throws Exception {
@@ -222,7 +224,8 @@
     } catch (IllegalArgumentException exc) {
       // expected
     }
-    IOUtils.close(writer, taxoWriter, dir, taxoDir);
+    writer.shutdown();
+    IOUtils.close(taxoWriter, dir, taxoDir);
   }
   
   public void testIntSumAssociationDrillDown() throws Exception {
Index: lucene/facet/src/test/org/apache/lucene/facet/TestRandomSamplingFacetsCollector.java
===================================================================
--- lucene/facet/src/test/org/apache/lucene/facet/TestRandomSamplingFacetsCollector.java	(revision 1584870)
+++ lucene/facet/src/test/org/apache/lucene/facet/TestRandomSamplingFacetsCollector.java	(working copy)
@@ -58,7 +58,8 @@
     // NRT open
     IndexSearcher searcher = newSearcher(writer.getReader());
     TaxonomyReader taxoReader = new DirectoryTaxonomyReader(taxoWriter);
-    IOUtils.close(writer, taxoWriter);
+    writer.shutdown();
+    IOUtils.close(taxoWriter);
     
     // Test empty results
     RandomSamplingFacetsCollector collectRandomZeroResults = new RandomSamplingFacetsCollector(numDocs / 10, random.nextLong());
Index: lucene/facet/src/test/org/apache/lucene/facet/TestMultipleIndexFields.java
===================================================================
--- lucene/facet/src/test/org/apache/lucene/facet/TestMultipleIndexFields.java	(revision 1584870)
+++ lucene/facet/src/test/org/apache/lucene/facet/TestMultipleIndexFields.java	(working copy)
@@ -91,7 +91,8 @@
 
     assertOrdinalsExist("$facets", ir);
 
-    IOUtils.close(tr, ir, iw, tw, indexDir, taxoDir);
+    iw.shutdown();
+    IOUtils.close(tr, ir, tw, indexDir, taxoDir);
   }
 
   @Test
@@ -130,7 +131,8 @@
     assertOrdinalsExist("$facets", ir);
     assertOrdinalsExist("$author", ir);
 
-    IOUtils.close(tr, ir, iw, tw, indexDir, taxoDir);
+    iw.shutdown();
+    IOUtils.close(tr, ir, tw, indexDir, taxoDir);
   }
 
   @Test
@@ -173,7 +175,8 @@
     assertOrdinalsExist("$music", ir);
     assertOrdinalsExist("$music", ir);
 
-    IOUtils.close(tr, ir, iw, tw, indexDir, taxoDir);
+    iw.shutdown();
+    IOUtils.close(tr, ir, tw, indexDir, taxoDir);
   }
 
   private void assertOrdinalsExist(String field, IndexReader ir) throws IOException {
@@ -224,7 +227,8 @@
     assertOrdinalsExist("$bands", ir);
     assertOrdinalsExist("$composers", ir);
 
-    IOUtils.close(tr, ir, iw, tw, indexDir, taxoDir);
+    iw.shutdown();
+    IOUtils.close(tr, ir, tw, indexDir, taxoDir);
   }
 
   @Test
@@ -267,8 +271,8 @@
     assertOrdinalsExist("$music", ir);
     assertOrdinalsExist("$literature", ir);
 
-    IOUtils.close(tr, ir, iw, tw);
-    IOUtils.close(indexDir, taxoDir);
+    iw.shutdown();
+    IOUtils.close(tr, ir, iw, tw, indexDir, taxoDir);
   }
 
   private void assertCorrectResults(Facets facets) throws IOException {
Index: lucene/facet/src/test/org/apache/lucene/facet/range/TestRangeFacetCounts.java
===================================================================
--- lucene/facet/src/test/org/apache/lucene/facet/range/TestRangeFacetCounts.java	(revision 1584870)
+++ lucene/facet/src/test/org/apache/lucene/facet/range/TestRangeFacetCounts.java	(working copy)
@@ -88,7 +88,7 @@
     w.addDocument(doc);
 
     IndexReader r = w.getReader();
-    w.close();
+    w.shutdown();
 
     FacetsCollector fc = new FacetsCollector();
     IndexSearcher s = newSearcher(r);
@@ -152,7 +152,7 @@
     w.addDocument(doc);
 
     IndexReader r = w.getReader();
-    w.close();
+    w.shutdown();
 
     FacetsCollector fc = new FacetsCollector();
     IndexSearcher s = newSearcher(r);
@@ -188,7 +188,7 @@
     w.addDocument(doc);
 
     IndexReader r = w.getReader();
-    w.close();
+    w.shutdown();
 
     FacetsCollector fc = new FacetsCollector();
     IndexSearcher s = newSearcher(r);
@@ -306,7 +306,8 @@
     assertEquals("dim=dim path=[] value=11 childCount=2\n  b (8)\n  a (3)\n", dsr.facets.getTopChildren(10, "dim").toString());
     assertEquals("dim=field path=[] value=21 childCount=5\n  less than 10 (10)\n  less than or equal to 10 (11)\n  over 90 (9)\n  90 or above (10)\n  over 1000 (0)\n",
                  dsr.facets.getTopChildren(10, "field").toString());
-    IOUtils.close(tw, tr, td, w, r, d);
+    w.shutdown();
+    IOUtils.close(tw, tr, td, r, d);
   }
 
   public void testBasicDouble() throws Exception {
@@ -335,8 +336,8 @@
                                          
     assertEquals("dim=field path=[] value=21 childCount=5\n  less than 10 (10)\n  less than or equal to 10 (11)\n  over 90 (9)\n  90 or above (10)\n  over 1000 (0)\n",
                  facets.getTopChildren(10, "field").toString());
-
-    IOUtils.close(w, r, d);
+    w.shutdown();
+    IOUtils.close(r, d);
   }
 
   public void testBasicFloat() throws Exception {
@@ -366,8 +367,8 @@
     
     assertEquals("dim=field path=[] value=21 childCount=5\n  less than 10 (10)\n  less than or equal to 10 (11)\n  over 90 (9)\n  90 or above (10)\n  over 1000 (0)\n",
                  facets.getTopChildren(10, "field").toString());
-    
-    IOUtils.close(w, r, d);
+    w.shutdown();
+    IOUtils.close(r, d);
   }
 
   public void testRandomLongs() throws Exception {
@@ -514,7 +515,8 @@
       }
     }
 
-    IOUtils.close(w, r, dir);
+    w.shutdown();
+    IOUtils.close(r, dir);
   }
 
   public void testRandomFloats() throws Exception {
@@ -672,7 +674,8 @@
       }
     }
 
-    IOUtils.close(w, r, dir);
+    w.shutdown();
+    IOUtils.close(r, dir);
   }
 
   public void testRandomDoubles() throws Exception {
@@ -815,7 +818,8 @@
       }
     }
 
-    IOUtils.close(w, r, dir);
+    w.shutdown();
+    IOUtils.close(r, dir);
   }
 
   // LUCENE-5178
@@ -852,7 +856,8 @@
     assertEquals("dim=field path=[] value=16 childCount=5\n  less than 10 (8)\n  less than or equal to 10 (8)\n  over 90 (8)\n  90 or above (8)\n  over 1000 (0)\n",
                  facets.getTopChildren(10, "field").toString());
 
-    IOUtils.close(w, r, d);
+    w.shutdown();
+    IOUtils.close(r, d);
   }
 
   public void testCustomDoublesValueSource() throws Exception {
@@ -965,6 +970,7 @@
     assertEquals("dim=field path=[] value=3 childCount=6\n  < 1 (0)\n  < 2 (1)\n  < 5 (3)\n  < 10 (3)\n  < 20 (3)\n  < 50 (3)\n",
                  dsr.facets.getTopChildren(10, "field").toString());
 
-    IOUtils.close(r, writer, dir);
+    writer.shutdown();
+    IOUtils.close(r, dir);
   }
 }
Index: lucene/facet/src/test/org/apache/lucene/facet/TestDrillSideways.java
===================================================================
--- lucene/facet/src/test/org/apache/lucene/facet/TestDrillSideways.java	(revision 1584870)
+++ lucene/facet/src/test/org/apache/lucene/facet/TestDrillSideways.java	(working copy)
@@ -242,7 +242,8 @@
     assertEquals(0, r.hits.totalHits);
     assertNull(r.facets.getTopChildren(10, "Publish Date"));
     assertNull(r.facets.getTopChildren(10, "Author"));
-    IOUtils.close(searcher.getIndexReader(), taxoReader, writer, taxoWriter, dir, taxoDir);
+    writer.shutdown();
+    IOUtils.close(searcher.getIndexReader(), taxoReader, taxoWriter, dir, taxoDir);
   }
 
   public void testSometimesInvalidDrillDown() throws Exception {
@@ -296,7 +297,8 @@
     // published once:
     assertEquals("dim=Author path=[] value=2 childCount=2\n  Bob (1)\n  Lisa (1)\n", r.facets.getTopChildren(10, "Author").toString());
 
-    IOUtils.close(searcher.getIndexReader(), taxoReader, writer, taxoWriter, dir, taxoDir);
+    writer.shutdown();
+    IOUtils.close(searcher.getIndexReader(), taxoReader, taxoWriter, dir, taxoDir);
   }
 
   public void testMultipleRequestsPerDim() throws Exception {
@@ -351,7 +353,8 @@
     assertEquals("dim=dim path=[] value=6 childCount=4\n  a (3)\n  b (1)\n  c (1)\n  d (1)\n", r.facets.getTopChildren(10, "dim").toString());
     assertEquals("dim=dim path=[a] value=3 childCount=3\n  x (1)\n  y (1)\n  z (1)\n", r.facets.getTopChildren(10, "dim", "a").toString());
 
-    IOUtils.close(searcher.getIndexReader(), taxoReader, writer, taxoWriter, dir, taxoDir);
+    writer.shutdown();
+    IOUtils.close(searcher.getIndexReader(), taxoReader, taxoWriter, dir, taxoDir);
   }
 
   private static class Doc implements Comparable<Doc> {
@@ -755,7 +758,8 @@
       }
     }
 
-    IOUtils.close(r, tr, w, tw, d, td);
+    w.shutdown();
+    IOUtils.close(r, tr, tw, d, td);
   }
 
   private static class Counters {
@@ -1061,8 +1065,9 @@
 
     r = ds.search(ddq, null, null, 10, new Sort(new SortField("foo", SortField.Type.INT)), false, false); // this used to fail on IllegalArgEx
     assertEquals(0, r.hits.totalHits);
-    
-    IOUtils.close(writer, taxoWriter, searcher.getIndexReader(), taxoReader, dir, taxoDir);
+
+    writer.shutdown();
+    IOUtils.close(taxoWriter, searcher.getIndexReader(), taxoReader, dir, taxoDir);
   }
 }
 
Index: lucene/facet/src/test/org/apache/lucene/facet/TestDrillDownQuery.java
===================================================================
--- lucene/facet/src/test/org/apache/lucene/facet/TestDrillDownQuery.java	(revision 1584870)
+++ lucene/facet/src/test/org/apache/lucene/facet/TestDrillDownQuery.java	(working copy)
@@ -110,7 +110,7 @@
     
     taxoWriter.close();
     reader = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     taxo = new DirectoryTaxonomyReader(taxoDir);
   }
Index: lucene/facet/src/test/org/apache/lucene/facet/TestFacetsConfig.java
===================================================================
--- lucene/facet/src/test/org/apache/lucene/facet/TestFacetsConfig.java	(revision 1584870)
+++ lucene/facet/src/test/org/apache/lucene/facet/TestFacetsConfig.java	(working copy)
@@ -68,7 +68,8 @@
     // these two addDocument() used to fail
     indexWriter.addDocument(doc);
     indexWriter.addDocument(doc);
-    IOUtils.close(indexWriter, taxoWriter);
+    indexWriter.shutdown();
+    IOUtils.close(taxoWriter);
     
     DirectoryReader indexReader = DirectoryReader.open(indexDir);
     DirectoryTaxonomyReader taxoReader = new DirectoryTaxonomyReader(taxoDir);
Index: lucene/facet/src/test/org/apache/lucene/facet/sortedset/TestSortedSetDocValuesFacets.java
===================================================================
--- lucene/facet/src/test/org/apache/lucene/facet/sortedset/TestSortedSetDocValuesFacets.java	(revision 1584870)
+++ lucene/facet/src/test/org/apache/lucene/facet/sortedset/TestSortedSetDocValuesFacets.java	(working copy)
@@ -92,7 +92,8 @@
     TopDocs hits = searcher.search(q, 1);
     assertEquals(1, hits.totalHits);
 
-    IOUtils.close(writer, searcher.getIndexReader(), dir);
+    writer.shutdown();
+    IOUtils.close(searcher.getIndexReader(), dir);
   }
 
   // LUCENE-5090
@@ -134,7 +135,7 @@
     }
 
     r.close();
-    writer.close();
+    writer.shutdown();
     searcher.getIndexReader().close();
     dir.close();
   }
@@ -173,7 +174,7 @@
 
     // NRT open
     IndexSearcher searcher = newSearcher(writer.getReader());
-    writer.close();
+    writer.shutdown();
 
     // Per-top-reader state:
     SortedSetDocValuesReaderState state = new DefaultSortedSetDocValuesReaderState(searcher.getIndexReader());
@@ -218,7 +219,7 @@
 
     // NRT open
     IndexSearcher searcher = newSearcher(writer.getReader());
-    writer.close();
+    writer.shutdown();
 
     // Per-top-reader state:
     SortedSetDocValuesReaderState state = new DefaultSortedSetDocValuesReaderState(searcher.getIndexReader());
@@ -265,7 +266,8 @@
     // Ask for top 10 labels for any dims that have counts:
     assertEquals("dim=a path=[] value=2 childCount=2\n  foo1 (1)\n  foo2 (1)\n", facets.getTopChildren(10, "a").toString());
 
-    IOUtils.close(writer, searcher.getIndexReader(), dir);
+    writer.shutdown();
+    IOUtils.close(searcher.getIndexReader(), dir);
   }
 
 
@@ -353,6 +355,7 @@
       assertEquals(expected, actual);
     }
 
-    IOUtils.close(w, searcher.getIndexReader(), indexDir, taxoDir);
+    w.shutdown();
+    IOUtils.close(searcher.getIndexReader(), indexDir, taxoDir);
   }
 }
Index: lucene/facet/src/java/org/apache/lucene/facet/taxonomy/directory/DirectoryTaxonomyWriter.java
===================================================================
--- lucene/facet/src/java/org/apache/lucene/facet/taxonomy/directory/DirectoryTaxonomyWriter.java	(revision 1584870)
+++ lucene/facet/src/java/org/apache/lucene/facet/taxonomy/directory/DirectoryTaxonomyWriter.java	(working copy)
@@ -340,12 +340,12 @@
   public synchronized void close() throws IOException {
     if (!isClosed) {
       commit();
+      indexWriter.shutdown();
       doClose();
     }
   }
   
   private void doClose() throws IOException {
-    indexWriter.close();
     isClosed = true;
     closeResources();
   }
Index: lucene/queryparser/src/test/org/apache/lucene/queryparser/flexible/standard/TestMultiFieldQPHelper.java
===================================================================
--- lucene/queryparser/src/test/org/apache/lucene/queryparser/flexible/standard/TestMultiFieldQPHelper.java	(revision 1584870)
+++ lucene/queryparser/src/test/org/apache/lucene/queryparser/flexible/standard/TestMultiFieldQPHelper.java	(working copy)
@@ -324,7 +324,7 @@
     Document doc = new Document();
     doc.add(newTextField("body", "blah the footest blah", Field.Store.NO));
     iw.addDocument(doc);
-    iw.close();
+    iw.shutdown();
 
     StandardQueryParser mfqp = new StandardQueryParser();
 
Index: lucene/queryparser/src/test/org/apache/lucene/queryparser/flexible/standard/TestQPHelper.java
===================================================================
--- lucene/queryparser/src/test/org/apache/lucene/queryparser/flexible/standard/TestQPHelper.java	(revision 1584870)
+++ lucene/queryparser/src/test/org/apache/lucene/queryparser/flexible/standard/TestQPHelper.java	(working copy)
@@ -1321,7 +1321,7 @@
     assertTrue(q instanceof MultiPhraseQuery);
     assertEquals(1, s.search(q, 10).totalHits);
     r.close();
-    w.close();
+    w.shutdown();
     dir.close();
   }
 
Index: lucene/queryparser/src/test/org/apache/lucene/queryparser/flexible/standard/TestNumericQueryParser.java
===================================================================
--- lucene/queryparser/src/test/org/apache/lucene/queryparser/flexible/standard/TestNumericQueryParser.java	(revision 1584870)
+++ lucene/queryparser/src/test/org/apache/lucene/queryparser/flexible/standard/TestNumericQueryParser.java	(working copy)
@@ -247,7 +247,7 @@
     
     reader = writer.getReader();
     searcher = newSearcher(reader);
-    writer.close();
+    writer.shutdown();
     
   }
   
Index: lucene/queryparser/src/test/org/apache/lucene/queryparser/analyzing/TestAnalyzingQueryParser.java
===================================================================
--- lucene/queryparser/src/test/org/apache/lucene/queryparser/analyzing/TestAnalyzingQueryParser.java	(revision 1584870)
+++ lucene/queryparser/src/test/org/apache/lucene/queryparser/analyzing/TestAnalyzingQueryParser.java	(working copy)
@@ -281,7 +281,7 @@
     Field field = new Field(FIELD, content, fieldType);
     doc.add(field);
     writer.addDocument(doc);
-    writer.close();
+    writer.shutdown();
     DirectoryReader ir = DirectoryReader.open(ramDir);
     IndexSearcher is = new IndexSearcher(ir);
       
Index: lucene/queryparser/src/test/org/apache/lucene/queryparser/xml/TestParser.java
===================================================================
--- lucene/queryparser/src/test/org/apache/lucene/queryparser/xml/TestParser.java	(revision 1584870)
+++ lucene/queryparser/src/test/org/apache/lucene/queryparser/xml/TestParser.java	(working copy)
@@ -80,7 +80,7 @@
       line = d.readLine();
     }
     d.close();
-    writer.close();
+    writer.shutdown();
     reader = DirectoryReader.open(dir);
     searcher = newSearcher(reader);
 
Index: lucene/queryparser/src/test/org/apache/lucene/queryparser/xml/builders/TestNumericRangeFilterBuilder.java
===================================================================
--- lucene/queryparser/src/test/org/apache/lucene/queryparser/xml/builders/TestNumericRangeFilterBuilder.java	(revision 1584870)
+++ lucene/queryparser/src/test/org/apache/lucene/queryparser/xml/builders/TestNumericRangeFilterBuilder.java	(working copy)
@@ -76,7 +76,7 @@
     }
     finally {
       writer.commit();
-      writer.close();
+      writer.shutdown();
       ramDir.close();
     }
   }
Index: lucene/queryparser/src/test/org/apache/lucene/queryparser/xml/TestQueryTemplateManager.java
===================================================================
--- lucene/queryparser/src/test/org/apache/lucene/queryparser/xml/TestQueryTemplateManager.java	(revision 1584870)
+++ lucene/queryparser/src/test/org/apache/lucene/queryparser/xml/TestQueryTemplateManager.java	(working copy)
@@ -150,7 +150,7 @@
       w.addDocument(getDocumentFromString(docFieldValue));
     }
     w.forceMerge(1);
-    w.close();
+    w.shutdown();
     reader = DirectoryReader.open(dir);
     searcher = newSearcher(reader);
 
Index: lucene/queryparser/src/test/org/apache/lucene/queryparser/complexPhrase/TestComplexPhraseQuery.java
===================================================================
--- lucene/queryparser/src/test/org/apache/lucene/queryparser/complexPhrase/TestComplexPhraseQuery.java	(revision 1584870)
+++ lucene/queryparser/src/test/org/apache/lucene/queryparser/complexPhrase/TestComplexPhraseQuery.java	(working copy)
@@ -154,7 +154,7 @@
       doc.add(newTextField("role", docsContent[i].role, Field.Store.YES));
       w.addDocument(doc);
     }
-    w.close();
+    w.shutdown();
     reader = DirectoryReader.open(rd);
     searcher = newSearcher(reader);
   }
Index: lucene/queryparser/src/test/org/apache/lucene/queryparser/util/QueryParserTestBase.java
===================================================================
--- lucene/queryparser/src/test/org/apache/lucene/queryparser/util/QueryParserTestBase.java	(revision 1584870)
+++ lucene/queryparser/src/test/org/apache/lucene/queryparser/util/QueryParserTestBase.java	(working copy)
@@ -1094,7 +1094,7 @@
     doc.add(newTextField("field", "the wizard of ozzy", Field.Store.NO));
     w.addDocument(doc);
     IndexReader r = DirectoryReader.open(w, true);
-    w.close();
+    w.shutdown();
     IndexSearcher s = newSearcher(r);
     
     Query q = getQuery("\"wizard of ozzy\"",a);
Index: lucene/queryparser/src/test/org/apache/lucene/queryparser/classic/TestMultiFieldQueryParser.java
===================================================================
--- lucene/queryparser/src/test/org/apache/lucene/queryparser/classic/TestMultiFieldQueryParser.java	(revision 1584870)
+++ lucene/queryparser/src/test/org/apache/lucene/queryparser/classic/TestMultiFieldQueryParser.java	(working copy)
@@ -290,7 +290,7 @@
     Document doc = new Document();
     doc.add(newTextField("body", "blah the footest blah", Field.Store.NO));
     iw.addDocument(doc);
-    iw.close();
+    iw.shutdown();
     
     MultiFieldQueryParser mfqp = 
       new MultiFieldQueryParser(TEST_VERSION_CURRENT, new String[] {"body"}, analyzer);
Index: lucene/queryparser/src/test/org/apache/lucene/queryparser/surround/query/SingleFieldTestDb.java
===================================================================
--- lucene/queryparser/src/test/org/apache/lucene/queryparser/surround/query/SingleFieldTestDb.java	(revision 1584870)
+++ lucene/queryparser/src/test/org/apache/lucene/queryparser/surround/query/SingleFieldTestDb.java	(working copy)
@@ -48,7 +48,7 @@
         d.add(new TextField(fieldName, docs[j], Field.Store.NO));
         writer.addDocument(d);
       }
-      writer.close();
+      writer.shutdown();
     } catch (java.io.IOException ioe) {
       throw new Error(ioe);
     }
Index: lucene/expressions/src/test/org/apache/lucene/expressions/TestExpressionRescorer.java
===================================================================
--- lucene/expressions/src/test/org/apache/lucene/expressions/TestExpressionRescorer.java	(revision 1584870)
+++ lucene/expressions/src/test/org/apache/lucene/expressions/TestExpressionRescorer.java	(working copy)
@@ -65,7 +65,7 @@
     
     reader = iw.getReader();
     searcher = new IndexSearcher(reader);
-    iw.close();
+    iw.shutdown();
   }
   
   @Override
Index: lucene/expressions/src/test/org/apache/lucene/expressions/TestDemoExpressions.java
===================================================================
--- lucene/expressions/src/test/org/apache/lucene/expressions/TestDemoExpressions.java	(revision 1584870)
+++ lucene/expressions/src/test/org/apache/lucene/expressions/TestDemoExpressions.java	(working copy)
@@ -75,7 +75,7 @@
     
     reader = iw.getReader();
     searcher = new IndexSearcher(reader);
-    iw.close();
+    iw.shutdown();
   }
   
   @Override
Index: lucene/expressions/src/test/org/apache/lucene/expressions/TestExpressionSorts.java
===================================================================
--- lucene/expressions/src/test/org/apache/lucene/expressions/TestExpressionSorts.java	(revision 1584870)
+++ lucene/expressions/src/test/org/apache/lucene/expressions/TestExpressionSorts.java	(working copy)
@@ -81,7 +81,7 @@
       iw.addDocument(document);
     }
     reader = iw.getReader();
-    iw.close();
+    iw.shutdown();
     searcher = newSearcher(reader);
   }
 
Index: lucene/expressions/src/test/org/apache/lucene/expressions/TestExpressionValueSource.java
===================================================================
--- lucene/expressions/src/test/org/apache/lucene/expressions/TestExpressionValueSource.java	(revision 1584870)
+++ lucene/expressions/src/test/org/apache/lucene/expressions/TestExpressionValueSource.java	(working copy)
@@ -70,7 +70,7 @@
     iw.forceMerge(1);
     
     reader = iw.getReader();
-    iw.close();
+    iw.shutdown();
   }
   
   @Override
Index: lucene/demo/src/java/org/apache/lucene/demo/IndexFiles.java
===================================================================
--- lucene/demo/src/java/org/apache/lucene/demo/IndexFiles.java	(revision 1584870)
+++ lucene/demo/src/java/org/apache/lucene/demo/IndexFiles.java	(working copy)
@@ -118,7 +118,7 @@
       //
       // writer.forceMerge(1);
 
-      writer.close();
+      writer.shutdown();
 
       Date end = new Date();
       System.out.println(end.getTime() - start.getTime() + " total milliseconds");
Index: lucene/demo/src/java/org/apache/lucene/demo/xmlparser/FormBasedXmlQueryDemo.java
===================================================================
--- lucene/demo/src/java/org/apache/lucene/demo/xmlparser/FormBasedXmlQueryDemo.java	(revision 1584870)
+++ lucene/demo/src/java/org/apache/lucene/demo/xmlparser/FormBasedXmlQueryDemo.java	(working copy)
@@ -155,7 +155,7 @@
       }
       line = br.readLine();
     }
-    writer.close();
+    writer.shutdown();
 
     //open searcher
     // this example never closes it reader!
Index: lucene/demo/src/java/org/apache/lucene/demo/facet/SimpleSortedSetFacetsExample.java
===================================================================
--- lucene/demo/src/java/org/apache/lucene/demo/facet/SimpleSortedSetFacetsExample.java	(revision 1584870)
+++ lucene/demo/src/java/org/apache/lucene/demo/facet/SimpleSortedSetFacetsExample.java	(working copy)
@@ -82,7 +82,7 @@
     doc.add(new SortedSetDocValuesFacetField("Publish Year", "1999"));
     indexWriter.addDocument(config.build(doc));
     
-    indexWriter.close();
+    indexWriter.shutdown();
   }
 
   /** User runs a query and counts facets. */
Index: lucene/demo/src/java/org/apache/lucene/demo/facet/SimpleFacetsExample.java
===================================================================
--- lucene/demo/src/java/org/apache/lucene/demo/facet/SimpleFacetsExample.java	(revision 1584870)
+++ lucene/demo/src/java/org/apache/lucene/demo/facet/SimpleFacetsExample.java	(working copy)
@@ -88,7 +88,7 @@
     doc.add(new FacetField("Publish Date", "1999", "5", "5"));
     indexWriter.addDocument(config.build(taxoWriter, doc));
     
-    indexWriter.close();
+    indexWriter.shutdown();
     taxoWriter.close();
   }
 
Index: lucene/demo/src/java/org/apache/lucene/demo/facet/DistanceFacetsExample.java
===================================================================
--- lucene/demo/src/java/org/apache/lucene/demo/facet/DistanceFacetsExample.java	(revision 1584870)
+++ lucene/demo/src/java/org/apache/lucene/demo/facet/DistanceFacetsExample.java	(working copy)
@@ -109,7 +109,7 @@
 
     // Open near-real-time searcher
     searcher = new IndexSearcher(DirectoryReader.open(writer, true));
-    writer.close();
+    writer.shutdown();
   }
 
   private ValueSource getDistanceValueSource() {
Index: lucene/demo/src/java/org/apache/lucene/demo/facet/RangeFacetsExample.java
===================================================================
--- lucene/demo/src/java/org/apache/lucene/demo/facet/RangeFacetsExample.java	(revision 1584870)
+++ lucene/demo/src/java/org/apache/lucene/demo/facet/RangeFacetsExample.java	(working copy)
@@ -77,7 +77,7 @@
 
     // Open near-real-time searcher
     searcher = new IndexSearcher(DirectoryReader.open(indexWriter, true));
-    indexWriter.close();
+    indexWriter.shutdown();
   }
 
   private FacetsConfig getConfig() {
Index: lucene/demo/src/java/org/apache/lucene/demo/facet/AssociationsFacetsExample.java
===================================================================
--- lucene/demo/src/java/org/apache/lucene/demo/facet/AssociationsFacetsExample.java	(revision 1584870)
+++ lucene/demo/src/java/org/apache/lucene/demo/facet/AssociationsFacetsExample.java	(working copy)
@@ -86,7 +86,7 @@
     doc.add(new FloatAssociationFacetField(0.34f, "genre", "software"));
     indexWriter.addDocument(config.build(taxoWriter, doc));
 
-    indexWriter.close();
+    indexWriter.shutdown();
     taxoWriter.close();
   }
 
Index: lucene/demo/src/java/org/apache/lucene/demo/facet/ExpressionAggregationFacetsExample.java
===================================================================
--- lucene/demo/src/java/org/apache/lucene/demo/facet/ExpressionAggregationFacetsExample.java	(revision 1584870)
+++ lucene/demo/src/java/org/apache/lucene/demo/facet/ExpressionAggregationFacetsExample.java	(working copy)
@@ -76,7 +76,7 @@
     doc.add(new FacetField("A", "C"));
     indexWriter.addDocument(config.build(taxoWriter, doc));
     
-    indexWriter.close();
+    indexWriter.shutdown();
     taxoWriter.close();
   }
 
Index: lucene/demo/src/java/org/apache/lucene/demo/facet/MultiCategoryListsFacetsExample.java
===================================================================
--- lucene/demo/src/java/org/apache/lucene/demo/facet/MultiCategoryListsFacetsExample.java	(revision 1584870)
+++ lucene/demo/src/java/org/apache/lucene/demo/facet/MultiCategoryListsFacetsExample.java	(working copy)
@@ -87,7 +87,7 @@
     doc.add(new FacetField("Publish Date", "1999", "5", "5"));
     indexWriter.addDocument(config.build(taxoWriter, doc));
     
-    indexWriter.close();
+    indexWriter.shutdown();
     taxoWriter.close();
   }
 
Index: lucene/benchmark/src/test/org/apache/lucene/benchmark/byTask/TestPerfTasksLogic.java
===================================================================
--- lucene/benchmark/src/test/org/apache/lucene/benchmark/byTask/TestPerfTasksLogic.java	(revision 1584870)
+++ lucene/benchmark/src/test/org/apache/lucene/benchmark/byTask/TestPerfTasksLogic.java	(working copy)
@@ -106,7 +106,7 @@
     IndexWriter iw = new IndexWriter(benchmark.getRunData().getDirectory(),
         new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()))
             .setOpenMode(OpenMode.APPEND));
-    iw.close();
+    iw.shutdown();
     IndexReader ir = DirectoryReader.open(benchmark.getRunData().getDirectory());
     assertEquals("1000 docs were added to the index, this is what we expect to find!",1000,ir.numDocs());
     ir.close();
@@ -197,7 +197,7 @@
     assertTrue("Index does not exist?...!", DirectoryReader.indexExists(benchmark.getRunData().getDirectory()));
     // now we should be able to open the index for write.
     IndexWriter iw = new IndexWriter(benchmark.getRunData().getDirectory(), new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())).setOpenMode(OpenMode.APPEND));
-    iw.close();
+    iw.shutdown();
     IndexReader ir = DirectoryReader.open(benchmark.getRunData().getDirectory());
     assertEquals("100 docs were added to the index, this is what we expect to find!",100,ir.numDocs());
     ir.close();
@@ -237,7 +237,7 @@
     assertTrue("Index does not exist?...!", DirectoryReader.indexExists(benchmark.getRunData().getDirectory()));
     // now we should be able to open the index for write.
     IndexWriter iw = new IndexWriter(benchmark.getRunData().getDirectory(), new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())).setOpenMode(OpenMode.APPEND));
-    iw.close();
+    iw.shutdown();
     IndexReader ir = DirectoryReader.open(benchmark.getRunData().getDirectory());
     assertEquals("1000 docs were added to the index, this is what we expect to find!",1000,ir.numDocs());
     ir.close();
@@ -310,7 +310,7 @@
     assertTrue("Index does not exist?...!", DirectoryReader.indexExists(benchmark.getRunData().getDirectory()));
     // now we should be able to open the index for write. 
     IndexWriter iw = new IndexWriter(benchmark.getRunData().getDirectory(), new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())).setOpenMode(OpenMode.APPEND));
-    iw.close();
+    iw.shutdown();
     IndexReader ir = DirectoryReader.open(benchmark.getRunData().getDirectory());
     assertEquals("1 docs were added to the index, this is what we expect to find!",1,ir.numDocs());
     ir.close();
@@ -442,7 +442,7 @@
     IndexWriter iw = new IndexWriter(benchmark.getRunData().getDirectory(),
         new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()))
             .setOpenMode(OpenMode.APPEND));
-    iw.close();
+    iw.shutdown();
 
     IndexReader ir = DirectoryReader.open(benchmark.getRunData().getDirectory());
     assertEquals(numLines + " lines were created but " + ir.numDocs() + " docs are in the index", numLines, ir.numDocs());
@@ -665,7 +665,7 @@
     assertTrue("did not use the specified MergeScheduler",
         ((MyMergeScheduler) benchmark.getRunData().getIndexWriter().getConfig()
             .getMergeScheduler()).called);
-    benchmark.getRunData().getIndexWriter().close();
+    benchmark.getRunData().getIndexWriter().shutdown();
 
     // 3. test number of docs in the index
     IndexReader ir = DirectoryReader.open(benchmark.getRunData().getDirectory());
@@ -711,7 +711,7 @@
     // 2. execute the algorithm  (required in every "logic" test)
     Benchmark benchmark = execBenchmark(algLines);
     assertTrue("did not use the specified MergePolicy", ((MyMergePolicy) benchmark.getRunData().getIndexWriter().getConfig().getMergePolicy()).called);
-    benchmark.getRunData().getIndexWriter().close();
+    benchmark.getRunData().getIndexWriter().shutdown();
     
     // 3. test number of docs in the index
     IndexReader ir = DirectoryReader.open(benchmark.getRunData().getDirectory());
@@ -756,7 +756,7 @@
     assertEquals(IndexWriterConfig.DISABLE_AUTO_FLUSH, (int) writer.getConfig().getRAMBufferSizeMB());
     assertEquals(3, ((LogMergePolicy) writer.getConfig().getMergePolicy()).getMergeFactor());
     assertEquals(0.0d, writer.getConfig().getMergePolicy().getNoCFSRatio(), 0.0);
-    writer.close();
+    writer.shutdown();
     Directory dir = benchmark.getRunData().getDirectory();
     IndexReader reader = DirectoryReader.open(dir);
     Fields tfv = reader.getTermVectors(0);
Index: lucene/benchmark/src/test/org/apache/lucene/benchmark/byTask/tasks/AddIndexesTaskTest.java
===================================================================
--- lucene/benchmark/src/test/org/apache/lucene/benchmark/byTask/tasks/AddIndexesTaskTest.java	(revision 1584870)
+++ lucene/benchmark/src/test/org/apache/lucene/benchmark/byTask/tasks/AddIndexesTaskTest.java	(working copy)
@@ -51,7 +51,7 @@
       for (int i = 0; i < 10; i++) {
         writer.addDocument(new Document());
       }
-      writer.close();
+      writer.shutdown();
     } finally {
       tmpDir.close();
     }
Index: lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/PerfRunData.java
===================================================================
--- lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/PerfRunData.java	(revision 1584870)
+++ lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/PerfRunData.java	(working copy)
@@ -142,7 +142,10 @@
   
   @Override
   public void close() throws IOException {
-    IOUtils.close(indexWriter, indexReader, directory, 
+    if (indexWriter != null) {
+      indexWriter.shutdown();
+    }
+    IOUtils.close(indexReader, directory, 
                   taxonomyWriter, taxonomyReader, taxonomyDir, 
                   docMaker, facetSource, contentSource);
     
@@ -160,7 +163,10 @@
   public void reinit(boolean eraseIndex) throws Exception {
 
     // cleanup index
-    IOUtils.close(indexWriter, indexReader, directory);
+    if (indexWriter != null) {
+      indexWriter.shutdown();
+    }
+    IOUtils.close(indexReader, directory);
     indexWriter = null;
     indexReader = null;
 
Index: lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/CloseIndexTask.java
===================================================================
--- lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/CloseIndexTask.java	(revision 1584870)
+++ lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/CloseIndexTask.java	(working copy)
@@ -45,7 +45,10 @@
       if (infoStream != null) {
         infoStream.close();
       }
-      iw.close(doWait);
+      if (doWait == false) {
+        iw.abortMerges();
+      }
+      iw.shutdown();
       getRunData().setIndexWriter(null);
     }
     return 1;
Index: lucene/memory/src/test/org/apache/lucene/index/memory/MemoryIndexTest.java
===================================================================
--- lucene/memory/src/test/org/apache/lucene/index/memory/MemoryIndexTest.java	(revision 1584870)
+++ lucene/memory/src/test/org/apache/lucene/index/memory/MemoryIndexTest.java	(working copy)
@@ -156,7 +156,7 @@
     doc.add(field1);
     doc.add(field2);
     writer.addDocument(doc);
-    writer.close();
+    writer.shutdown();
     
     memory.addField("foo", fooField.toString(), analyzer);
     memory.addField("term", termField.toString(), analyzer);
@@ -451,7 +451,7 @@
       }
       
       writer.addDocument(doc);
-      writer.close();
+      writer.shutdown();
       for (IndexableField field : doc.indexableFields()) {
           memory.addField(field.name(), ((Field)field).stringValue(), mockAnalyzer);  
       }
@@ -497,7 +497,7 @@
     IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random(), TEST_VERSION_CURRENT, mockAnalyzer));
     writer.updateDocument(new Term("id", "1"), doc);
     writer.commit();
-    writer.close();
+    writer.shutdown();
     DirectoryReader reader = DirectoryReader.open(dir);
 
     //Index document in Memory index
Index: lucene/analysis/icu/src/test/org/apache/lucene/collation/TestICUCollationDocValuesField.java
===================================================================
--- lucene/analysis/icu/src/test/org/apache/lucene/collation/TestICUCollationDocValuesField.java	(revision 1584870)
+++ lucene/analysis/icu/src/test/org/apache/lucene/collation/TestICUCollationDocValuesField.java	(working copy)
@@ -67,7 +67,7 @@
     iw.addDocument(doc);
     
     IndexReader ir = iw.getReader();
-    iw.close();
+    iw.shutdown();
     
     IndexSearcher is = newSearcher(ir);
     
@@ -102,7 +102,7 @@
     }
     
     IndexReader ir = iw.getReader();
-    iw.close();
+    iw.shutdown();
     IndexSearcher is = newSearcher(ir);
     
     int numChecks = atLeast(100);
Index: lucene/analysis/common/src/test/org/apache/lucene/analysis/miscellaneous/TestEmptyTokenStream.java
===================================================================
--- lucene/analysis/common/src/test/org/apache/lucene/analysis/miscellaneous/TestEmptyTokenStream.java	(revision 1584870)
+++ lucene/analysis/common/src/test/org/apache/lucene/analysis/miscellaneous/TestEmptyTokenStream.java	(working copy)
@@ -67,7 +67,7 @@
     
     assertEquals(1, writer.numDocs());
 
-    writer.close();
+    writer.shutdown();
     directory.close();
   }
 
Index: lucene/analysis/common/src/test/org/apache/lucene/analysis/miscellaneous/TestLimitTokenCountAnalyzer.java
===================================================================
--- lucene/analysis/common/src/test/org/apache/lucene/analysis/miscellaneous/TestLimitTokenCountAnalyzer.java	(revision 1584870)
+++ lucene/analysis/common/src/test/org/apache/lucene/analysis/miscellaneous/TestLimitTokenCountAnalyzer.java	(working copy)
@@ -78,7 +78,7 @@
       b.append(" z");
       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");
Index: lucene/analysis/common/src/test/org/apache/lucene/analysis/sinks/TestTeeSinkTokenFilter.java
===================================================================
--- lucene/analysis/common/src/test/org/apache/lucene/analysis/sinks/TestTeeSinkTokenFilter.java	(revision 1584870)
+++ lucene/analysis/common/src/test/org/apache/lucene/analysis/sinks/TestTeeSinkTokenFilter.java	(working copy)
@@ -104,7 +104,7 @@
     doc.add(f1);
     doc.add(f2);
     w.addDocument(doc);
-    w.close();
+    w.shutdown();
 
     IndexReader r = DirectoryReader.open(dir);
     Terms vector = r.getTermVectors(0).terms("field");
Index: lucene/analysis/common/src/test/org/apache/lucene/analysis/query/QueryAutoStopWordAnalyzerTest.java
===================================================================
--- lucene/analysis/common/src/test/org/apache/lucene/analysis/query/QueryAutoStopWordAnalyzerTest.java	(revision 1584870)
+++ lucene/analysis/common/src/test/org/apache/lucene/analysis/query/QueryAutoStopWordAnalyzerTest.java	(working copy)
@@ -52,7 +52,7 @@
       doc.add(new TextField("repetitiveField", repetitiveFieldValue, Field.Store.YES));
       writer.addDocument(doc);
     }
-    writer.close();
+    writer.shutdown();
     reader = DirectoryReader.open(dir);
   }
 
Index: lucene/analysis/common/src/test/org/apache/lucene/analysis/shingle/ShingleAnalyzerWrapperTest.java
===================================================================
--- lucene/analysis/common/src/test/org/apache/lucene/analysis/shingle/ShingleAnalyzerWrapperTest.java	(revision 1584870)
+++ lucene/analysis/common/src/test/org/apache/lucene/analysis/shingle/ShingleAnalyzerWrapperTest.java	(working copy)
@@ -73,7 +73,7 @@
     doc.add(new TextField("content", "a sentence which contains no test", Field.Store.YES));
     writer.addDocument(doc);
 
-    writer.close();
+    writer.shutdown();
 
     reader = DirectoryReader.open(directory);
     searcher = newSearcher(reader);
Index: lucene/analysis/common/src/test/org/apache/lucene/analysis/core/TestClassicAnalyzer.java
===================================================================
--- lucene/analysis/common/src/test/org/apache/lucene/analysis/core/TestClassicAnalyzer.java	(revision 1584870)
+++ lucene/analysis/common/src/test/org/apache/lucene/analysis/core/TestClassicAnalyzer.java	(working copy)
@@ -270,7 +270,7 @@
     doc = new Document();
     doc.add(new TextField("content", "abc bbb ccc", Field.Store.NO));
     writer.addDocument(doc);
-    writer.close();
+    writer.shutdown();
 
     IndexReader reader = DirectoryReader.open(dir);
 
@@ -304,7 +304,7 @@
     sa.setMaxTokenLength(100000);
     writer  = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, sa));
     writer.addDocument(doc);
-    writer.close();
+    writer.shutdown();
     reader = DirectoryReader.open(dir);
     assertEquals(1, reader.docFreq(new Term("content", bigTerm)));
     reader.close();
Index: lucene/analysis/common/src/test/org/apache/lucene/analysis/core/TestKeywordAnalyzer.java
===================================================================
--- lucene/analysis/common/src/test/org/apache/lucene/analysis/core/TestKeywordAnalyzer.java	(revision 1584870)
+++ lucene/analysis/common/src/test/org/apache/lucene/analysis/core/TestKeywordAnalyzer.java	(working copy)
@@ -57,7 +57,7 @@
     doc.add(new TextField("description", "Illidium Space Modulator", Field.Store.YES));
     writer.addDocument(doc);
 
-    writer.close();
+    writer.shutdown();
 
     reader = DirectoryReader.open(directory);
     searcher = newSearcher(reader);
@@ -94,7 +94,7 @@
     doc = new Document();
     doc.add(new TextField("partnum", "Q37", Field.Store.YES));
     writer.addDocument(doc);
-    writer.close();
+    writer.shutdown();
 
     IndexReader reader = DirectoryReader.open(dir);
     DocsEnum td = TestUtil.docs(random(),
Index: lucene/analysis/uima/src/test/org/apache/lucene/analysis/uima/UIMABaseAnalyzerTest.java
===================================================================
--- lucene/analysis/uima/src/test/org/apache/lucene/analysis/uima/UIMABaseAnalyzerTest.java	(revision 1584870)
+++ lucene/analysis/uima/src/test/org/apache/lucene/analysis/uima/UIMABaseAnalyzerTest.java	(working copy)
@@ -114,7 +114,7 @@
     indexSearcher = newSearcher(directoryReader);
     result = indexSearcher.search(new MatchAllDocsQuery(), 2);
     assertEquals(2, result.totalHits);
-    writer.close();
+    writer.shutdown();
     indexSearcher.getIndexReader().close();
     dir.close();
   }
Index: lucene/classification/src/test/org/apache/lucene/classification/utils/DataSplitterTest.java
===================================================================
--- lucene/classification/src/test/org/apache/lucene/classification/utils/DataSplitterTest.java	(revision 1584870)
+++ lucene/classification/src/test/org/apache/lucene/classification/utils/DataSplitterTest.java	(working copy)
@@ -86,7 +86,7 @@
   @After
   public void tearDown() throws Exception {
     originalIndex.close();
-    indexWriter.close();
+    indexWriter.shutdown();
     dir.close();
     super.tearDown();
   }
Index: lucene/classification/src/test/org/apache/lucene/classification/ClassificationTestBase.java
===================================================================
--- lucene/classification/src/test/org/apache/lucene/classification/ClassificationTestBase.java	(revision 1584870)
+++ lucene/classification/src/test/org/apache/lucene/classification/ClassificationTestBase.java	(working copy)
@@ -74,7 +74,7 @@
   @After
   public void tearDown() throws Exception {
     super.tearDown();
-    indexWriter.close();
+    indexWriter.shutdown();
     dir.close();
   }
 
Index: lucene/classification/src/java/org/apache/lucene/classification/utils/DatasetSplitter.java
===================================================================
--- lucene/classification/src/java/org/apache/lucene/classification/utils/DatasetSplitter.java	(revision 1584870)
+++ lucene/classification/src/java/org/apache/lucene/classification/utils/DatasetSplitter.java	(working copy)
@@ -128,9 +128,9 @@
       cvWriter.commit();
       trainingWriter.commit();
       // close IWs
-      testWriter.close();
-      cvWriter.close();
-      trainingWriter.close();
+      testWriter.shutdown();
+      cvWriter.shutdown();
+      trainingWriter.shutdown();
     }
   }
 
Index: lucene/misc/src/test/org/apache/lucene/index/TestPKIndexSplitter.java
===================================================================
--- lucene/misc/src/test/org/apache/lucene/index/TestPKIndexSplitter.java	(revision 1584870)
+++ lucene/misc/src/test/org/apache/lucene/index/TestPKIndexSplitter.java	(working copy)
@@ -49,7 +49,7 @@
       w.addDocument(doc);
       if (x%3==0) w.commit();
     }
-    w.close();
+    w.shutdown();
     
     final Term midTerm = new Term("id", format.format(11));
     
@@ -61,7 +61,7 @@
         .setOpenMode(OpenMode.APPEND).setMergePolicy(NoMergePolicy.COMPOUND_FILES));
     w.deleteDocuments(midTerm);
     w.deleteDocuments(new Term("id", format.format(2)));
-    w.close();
+    w.shutdown();
     
     checkSplitting(dir, midTerm, 10, 8);
     
Index: lucene/misc/src/test/org/apache/lucene/index/sorter/TestEarlyTermination.java
===================================================================
--- lucene/misc/src/test/org/apache/lucene/index/sorter/TestEarlyTermination.java	(revision 1584870)
+++ lucene/misc/src/test/org/apache/lucene/index/sorter/TestEarlyTermination.java	(working copy)
@@ -100,7 +100,7 @@
   @Override
   public void tearDown() throws Exception {
     reader.close();
-    iw.close();
+    iw.shutdown();
     dir.close();
     super.tearDown();
   }
Index: lucene/misc/src/test/org/apache/lucene/index/sorter/SorterTestBase.java
===================================================================
--- lucene/misc/src/test/org/apache/lucene/index/sorter/SorterTestBase.java	(revision 1584870)
+++ lucene/misc/src/test/org/apache/lucene/index/sorter/SorterTestBase.java	(working copy)
@@ -218,7 +218,7 @@
         writer.deleteDocuments(new Term(ID_FIELD, id.toString()));
       }
     }
-    writer.close();
+    writer.shutdown();
   }
   
   @BeforeClass
Index: lucene/misc/src/test/org/apache/lucene/index/sorter/TestBlockJoinSorter.java
===================================================================
--- lucene/misc/src/test/org/apache/lucene/index/sorter/TestBlockJoinSorter.java	(revision 1584870)
+++ lucene/misc/src/test/org/apache/lucene/index/sorter/TestBlockJoinSorter.java	(working copy)
@@ -86,7 +86,7 @@
     }
     writer.forceMerge(1);
     final DirectoryReader indexReader = writer.getReader();
-    writer.close();
+    writer.shutdown();
 
     final AtomicReader reader = getOnlySegmentReader(indexReader);
     final Filter parentsFilter = new FixedBitSetCachingWrapperFilter(new QueryWrapperFilter(new TermQuery(new Term("parent", "true"))));
Index: lucene/misc/src/test/org/apache/lucene/index/sorter/IndexSortingTest.java
===================================================================
--- lucene/misc/src/test/org/apache/lucene/index/sorter/IndexSortingTest.java	(revision 1584870)
+++ lucene/misc/src/test/org/apache/lucene/index/sorter/IndexSortingTest.java	(working copy)
@@ -70,7 +70,7 @@
     IndexWriter writer = new IndexWriter(target, newIndexWriterConfig(TEST_VERSION_CURRENT, null));
     reader = SortingAtomicReader.wrap(reader, sorter);
     writer.addIndexes(reader);
-    writer.close();
+    writer.shutdown();
     reader.close();
     dir.close();
     
Index: lucene/misc/src/test/org/apache/lucene/index/sorter/TestSortingMergePolicy.java
===================================================================
--- lucene/misc/src/test/org/apache/lucene/index/sorter/TestSortingMergePolicy.java	(revision 1584870)
+++ lucene/misc/src/test/org/apache/lucene/index/sorter/TestSortingMergePolicy.java	(working copy)
@@ -141,8 +141,8 @@
     
     iw1.forceMerge(1);
     iw2.forceMerge(1);
-    iw1.close();
-    iw2.close();
+    iw1.shutdown();
+    iw2.shutdown();
     reader = DirectoryReader.open(dir1);
     sortedReader = DirectoryReader.open(dir2);
   }
Index: lucene/misc/src/test/org/apache/lucene/index/TestIndexSplitter.java
===================================================================
--- lucene/misc/src/test/org/apache/lucene/index/TestIndexSplitter.java	(revision 1584870)
+++ lucene/misc/src/test/org/apache/lucene/index/TestIndexSplitter.java	(working copy)
@@ -68,7 +68,7 @@
     DirectoryReader iwReader = iw.getReader();
     assertEquals(3, iwReader.leaves().size());
     iwReader.close();
-    iw.close();
+    iw.shutdown();
     // we should have 2 segments now
     IndexSplitter is = new IndexSplitter(dir);
     String splitSegName = is.infos.info(1).info.name;
Index: lucene/misc/src/test/org/apache/lucene/index/TestMultiPassIndexSplitter.java
===================================================================
--- lucene/misc/src/test/org/apache/lucene/index/TestMultiPassIndexSplitter.java	(revision 1584870)
+++ lucene/misc/src/test/org/apache/lucene/index/TestMultiPassIndexSplitter.java	(working copy)
@@ -43,7 +43,7 @@
     }
     w.commit();
     w.deleteDocuments(new Term("id", "" + (NUM_DOCS-1)));
-    w.close();
+    w.shutdown();
     input = DirectoryReader.open(dir);
   }
   
Index: lucene/misc/src/test/org/apache/lucene/misc/TestHighFreqTerms.java
===================================================================
--- lucene/misc/src/test/org/apache/lucene/misc/TestHighFreqTerms.java	(revision 1584870)
+++ lucene/misc/src/test/org/apache/lucene/misc/TestHighFreqTerms.java	(working copy)
@@ -227,7 +227,7 @@
     }
     doc.add(newTextField(rnd, "different_field", content, Field.Store.YES));
     writer.addDocument(doc);
-    writer.close();
+    writer.shutdown();
     
   }
   
Index: lucene/misc/src/test/org/apache/lucene/document/TestLazyDocument.java
===================================================================
--- lucene/misc/src/test/org/apache/lucene/document/TestLazyDocument.java	(revision 1584870)
+++ lucene/misc/src/test/org/apache/lucene/document/TestLazyDocument.java	(working copy)
@@ -75,7 +75,7 @@
         writer.addDocument(d);
       }
     } finally {
-      writer.close();
+      writer.shutdown();
     }
   }
 
Index: lucene/misc/src/java/org/apache/lucene/index/PKIndexSplitter.java
===================================================================
--- lucene/misc/src/java/org/apache/lucene/index/PKIndexSplitter.java	(revision 1584870)
+++ lucene/misc/src/java/org/apache/lucene/index/PKIndexSplitter.java	(working copy)
@@ -112,7 +112,7 @@
       success = true;
     } finally {
       if (success) {
-        IOUtils.close(w);
+        w.shutdown();
       } else {
         IOUtils.closeWhileHandlingException(w);
       }
Index: lucene/misc/src/java/org/apache/lucene/index/MultiPassIndexSplitter.java
===================================================================
--- lucene/misc/src/java/org/apache/lucene/index/MultiPassIndexSplitter.java	(revision 1584870)
+++ lucene/misc/src/java/org/apache/lucene/index/MultiPassIndexSplitter.java	(working copy)
@@ -103,7 +103,7 @@
       // pass the subreaders directly, as our wrapper's numDocs/hasDeletetions are not up-to-date
       final List<? extends FakeDeleteAtomicIndexReader> sr = input.getSequentialSubReaders();
       w.addIndexes(sr.toArray(new IndexReader[sr.size()])); // TODO: maybe take List<IR> here?
-      w.close();
+      w.shutdown();
     }
     System.err.println("Done.");
   }
Index: lucene/misc/src/java/org/apache/lucene/misc/IndexMergeTool.java
===================================================================
--- lucene/misc/src/java/org/apache/lucene/misc/IndexMergeTool.java	(revision 1584870)
+++ lucene/misc/src/java/org/apache/lucene/misc/IndexMergeTool.java	(working copy)
@@ -52,7 +52,7 @@
 
     System.out.println("Full merge...");
     writer.forceMerge(1);
-    writer.close();
+    writer.shutdown();
     System.out.println("Done.");
   }
 }
Index: lucene/highlighter/src/test/org/apache/lucene/search/highlight/TokenSourcesTest.java
===================================================================
--- lucene/highlighter/src/test/org/apache/lucene/search/highlight/TokenSourcesTest.java	(revision 1584870)
+++ lucene/highlighter/src/test/org/apache/lucene/search/highlight/TokenSourcesTest.java	(working copy)
@@ -101,7 +101,7 @@
       document.add(new Field(FIELD, new OverlappingTokenStream(), customType));
       indexWriter.addDocument(document);
     } finally {
-      indexWriter.close();
+      indexWriter.shutdown();
     }
     final IndexReader indexReader = DirectoryReader.open(directory);
     assertEquals(1, indexReader.numDocs());
@@ -146,7 +146,7 @@
       document.add(new Field(FIELD, new OverlappingTokenStream(), customType));
       indexWriter.addDocument(document);
     } finally {
-      indexWriter.close();
+      indexWriter.shutdown();
     }
     final IndexReader indexReader = DirectoryReader.open(directory);
     try {
@@ -190,7 +190,7 @@
       document.add(new Field(FIELD, new OverlappingTokenStream(), customType));
       indexWriter.addDocument(document);
     } finally {
-      indexWriter.close();
+      indexWriter.shutdown();
     }
     final IndexReader indexReader = DirectoryReader.open(directory);
     try {
@@ -234,7 +234,7 @@
       document.add(new Field(FIELD, new OverlappingTokenStream(), customType));
       indexWriter.addDocument(document);
     } finally {
-      indexWriter.close();
+      indexWriter.shutdown();
     }
     final IndexReader indexReader = DirectoryReader.open(directory);
     try {
@@ -278,7 +278,7 @@
       document.add(new Field(FIELD, new OverlappingTokenStream(), customType));
       indexWriter.addDocument(document);
     } finally {
-      indexWriter.close();
+      indexWriter.shutdown();
     }
     final IndexReader indexReader = DirectoryReader.open(directory);
     try {
@@ -332,7 +332,7 @@
     writer.addDocument(doc);
   
     IndexReader reader = writer.getReader();
-    writer.close();
+    writer.shutdown();
     assertEquals(1, reader.numDocs());
 
     for(int i=0;i<2;i++) {
Index: lucene/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterTest.java
===================================================================
--- lucene/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterTest.java	(revision 1584870)
+++ lucene/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterTest.java	(working copy)
@@ -1776,7 +1776,7 @@
     writer.addDocument( doc( "t_text1", "random words for highlighting tests del" ) );
     writer.addDocument( doc( "t_text1", "more random words for second field" ) );
     writer.forceMerge(1);
-    writer.close();
+    writer.shutdown();
   }
   
   private void deleteDocument() throws IOException {
@@ -1784,7 +1784,7 @@
     writer.deleteDocuments( new Term( "t_text1", "del" ) );
     // To see negative idf, keep comment the following line
     //writer.forceMerge(1);
-    writer.close();
+    writer.shutdown();
   }
   
   private void searchIndex() throws IOException, InvalidTokenOffsetsException {
@@ -1904,7 +1904,7 @@
     writer.addDocument(doc, analyzer);
 
     writer.forceMerge(1);
-    writer.close();
+    writer.shutdown();
     reader = DirectoryReader.open(ramDir);
     numHighlights = 0;
   }
Index: lucene/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterPhraseTest.java
===================================================================
--- lucene/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterPhraseTest.java	(revision 1584870)
+++ lucene/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterPhraseTest.java	(working copy)
@@ -65,7 +65,7 @@
       document.add(new Field(FIELD, new TokenStreamConcurrent(), customType));
       indexWriter.addDocument(document);
     } finally {
-      indexWriter.close();
+      indexWriter.shutdown();
     }
     final IndexReader indexReader = DirectoryReader.open(directory);
     try {
@@ -107,7 +107,7 @@
       document.add(new Field(FIELD, new TokenStreamConcurrent(), customType));
       indexWriter.addDocument(document);
     } finally {
-      indexWriter.close();
+      indexWriter.shutdown();
     }
     final IndexReader indexReader = DirectoryReader.open(directory);
     try {
@@ -175,7 +175,7 @@
       document.add(new Field(FIELD, new TokenStreamSparse(), customType));
       indexWriter.addDocument(document);
     } finally {
-      indexWriter.close();
+      indexWriter.shutdown();
     }
     final IndexReader indexReader = DirectoryReader.open(directory);
     try {
@@ -216,7 +216,7 @@
       document.add(new Field(FIELD, TEXT, customType));
       indexWriter.addDocument(document);
     } finally {
-      indexWriter.close();
+      indexWriter.shutdown();
     }
     final IndexReader indexReader = DirectoryReader.open(directory);
     try {
@@ -255,7 +255,7 @@
       document.add(new Field(FIELD, new TokenStreamSparse(), customType));
       indexWriter.addDocument(document);
     } finally {
-      indexWriter.close();
+      indexWriter.shutdown();
     }
     final IndexReader indexReader = DirectoryReader.open(directory);
     try {
Index: lucene/highlighter/src/test/org/apache/lucene/search/vectorhighlight/AbstractTestCase.java
===================================================================
--- lucene/highlighter/src/test/org/apache/lucene/search/vectorhighlight/AbstractTestCase.java	(revision 1584870)
+++ lucene/highlighter/src/test/org/apache/lucene/search/vectorhighlight/AbstractTestCase.java	(working copy)
@@ -360,7 +360,7 @@
       doc.add( new Field( F, value, customType) );
     }
     writer.addDocument( doc );
-    writer.close();
+    writer.shutdown();
     if (reader != null) reader.close();
     reader = DirectoryReader.open(dir);
   }
@@ -379,7 +379,7 @@
       //doc.add( new Field( F, value, Store.YES, Index.NOT_ANALYZED, TermVector.WITH_POSITIONS_OFFSETS ) );
     }
     writer.addDocument( doc );
-    writer.close();
+    writer.shutdown();
     if (reader != null) reader.close();
     reader = DirectoryReader.open(dir);
   }
Index: lucene/highlighter/src/test/org/apache/lucene/search/vectorhighlight/FastVectorHighlighterTest.java
===================================================================
--- lucene/highlighter/src/test/org/apache/lucene/search/vectorhighlight/FastVectorHighlighterTest.java	(revision 1584870)
+++ lucene/highlighter/src/test/org/apache/lucene/search/vectorhighlight/FastVectorHighlighterTest.java	(working copy)
@@ -83,7 +83,7 @@
     bestFragments = highlighter.getBestFragments(fieldQuery, reader, docId, "field", 30, 1);
     assertEquals("a test where <b>foo</b> is highlighed", bestFragments[0]);
     reader.close();
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
   
@@ -128,7 +128,7 @@
       assertEquals("first browser war it lost virtually all of its share to <b>Internet Explorer</b> Netscape was discontinued and support for all Netscape browsers", bestFragments[0]);
     }
     reader.close();
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
   
@@ -256,7 +256,7 @@
           bestFragments[0]);
     }
     reader.close();
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
 
@@ -301,7 +301,7 @@
     assertEquals( "junk junk junk junk junk junk junk junk <b>highlight words together</b> junk junk junk junk junk junk junk junk", fragment );
 
     reader.close();
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
 
@@ -344,7 +344,7 @@
     assertEquals("Hello this is a piece of <b>text</b> that is <b>very</b> <b>long</b> and contains too much preamble and the meat is really here which says kennedy has been shot", bestFragments[0]);
 
     reader.close();
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
   
@@ -503,7 +503,7 @@
     }
 
     reader.close();
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
   
@@ -566,7 +566,7 @@
     assertEquals("<b>Test: http://www.facebook.com</b>", bestFragments[0]);
     
     reader.close();
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
 
@@ -648,7 +648,7 @@
     assertEquals( expected, bestFragments[ 0 ] );
 
     reader.close();
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
 
Index: lucene/highlighter/src/test/org/apache/lucene/search/vectorhighlight/SimpleFragmentsBuilderTest.java
===================================================================
--- lucene/highlighter/src/test/org/apache/lucene/search/vectorhighlight/SimpleFragmentsBuilderTest.java	(revision 1584870)
+++ lucene/highlighter/src/test/org/apache/lucene/search/vectorhighlight/SimpleFragmentsBuilderTest.java	(working copy)
@@ -158,7 +158,7 @@
     doc.add( new Field( F, "aaa", customType) );
     //doc.add( new Field( F, "aaa", Store.NO, Index.ANALYZED, TermVector.WITH_POSITIONS_OFFSETS ) );
     writer.addDocument( doc );
-    writer.close();
+    writer.shutdown();
     if (reader != null) reader.close();
     reader = DirectoryReader.open(dir);
   }
@@ -269,7 +269,7 @@
       documents.add(document);
     }
     writer.addDocuments(documents);
-    writer.close();
+    writer.shutdown();
     IndexReader reader = DirectoryReader.open(dir);
 
     try {
Index: lucene/highlighter/src/test/org/apache/lucene/search/postingshighlight/TestPostingsHighlighterRanking.java
===================================================================
--- lucene/highlighter/src/test/org/apache/lucene/search/postingshighlight/TestPostingsHighlighterRanking.java	(revision 1584870)
+++ lucene/highlighter/src/test/org/apache/lucene/search/postingshighlight/TestPostingsHighlighterRanking.java	(working copy)
@@ -87,7 +87,7 @@
     for (int i = 0; i < numDocs; i++) {
       checkDocument(searcher, i, maxTopN);
     }
-    iw.close();
+    iw.shutdown();
     ir.close();
     dir.close();
   }
@@ -262,7 +262,7 @@
     iw.addDocument(doc);
     
     IndexReader ir = iw.getReader();
-    iw.close();
+    iw.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     PostingsHighlighter highlighter = new PostingsHighlighter(10000) {
@@ -301,7 +301,7 @@
     iw.addDocument(doc);
     
     IndexReader ir = iw.getReader();
-    iw.close();
+    iw.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     PostingsHighlighter highlighter = new PostingsHighlighter(10000) {
Index: lucene/highlighter/src/test/org/apache/lucene/search/postingshighlight/TestPostingsHighlighter.java
===================================================================
--- lucene/highlighter/src/test/org/apache/lucene/search/postingshighlight/TestPostingsHighlighter.java	(revision 1584870)
+++ lucene/highlighter/src/test/org/apache/lucene/search/postingshighlight/TestPostingsHighlighter.java	(working copy)
@@ -71,7 +71,7 @@
     iw.addDocument(doc);
     
     IndexReader ir = iw.getReader();
-    iw.close();
+    iw.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     PostingsHighlighter highlighter = new PostingsHighlighter();
@@ -139,7 +139,7 @@
     iw.addDocument(doc);
     
     IndexReader ir = iw.getReader();
-    iw.close();
+    iw.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     
@@ -174,7 +174,7 @@
     iw.addDocument(doc);
     
     IndexReader ir = iw.getReader();
-    iw.close();
+    iw.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     PostingsHighlighter highlighter = new PostingsHighlighter();
@@ -209,7 +209,7 @@
     iw.addDocument(doc);
     
     IndexReader ir = iw.getReader();
-    iw.close();
+    iw.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     PostingsHighlighter highlighter = new PostingsHighlighter();
@@ -246,7 +246,7 @@
     iw.addDocument(doc);
     
     IndexReader ir = iw.getReader();
-    iw.close();
+    iw.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     PostingsHighlighter highlighter = new PostingsHighlighter(40);
@@ -284,7 +284,7 @@
     iw.addDocument(doc);
     
     IndexReader ir = iw.getReader();
-    iw.close();
+    iw.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     PostingsHighlighter highlighter = new PostingsHighlighter();
@@ -321,7 +321,7 @@
     iw.addDocument(doc);
     
     IndexReader ir = iw.getReader();
-    iw.close();
+    iw.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     PostingsHighlighter highlighter = new PostingsHighlighter();
@@ -358,7 +358,7 @@
     iw.addDocument(doc);
     
     IndexReader ir = iw.getReader();
-    iw.close();
+    iw.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     PostingsHighlighter highlighter = new PostingsHighlighter();
@@ -396,7 +396,7 @@
     iw.addDocument(doc);
     
     IndexReader ir = iw.getReader();
-    iw.close();
+    iw.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     PostingsHighlighter highlighter = new PostingsHighlighter();
@@ -441,7 +441,7 @@
     document.add(body);
     iw.addDocument(document);
     IndexReader ir = iw.getReader();
-    iw.close();
+    iw.shutdown();
     IndexSearcher searcher = newSearcher(ir);
     PhraseQuery query = new PhraseQuery();
     query.add(new Term("body", "buddhist"));
@@ -471,7 +471,7 @@
     document.add(body);
     iw.addDocument(document);
     IndexReader ir = iw.getReader();
-    iw.close();
+    iw.shutdown();
     IndexSearcher searcher = newSearcher(ir);
     PhraseQuery query = new PhraseQuery();
     query.add(new Term("body", "curious"));
@@ -501,7 +501,7 @@
     document.add(body);
     iw.addDocument(document);
     IndexReader ir = iw.getReader();
-    iw.close();
+    iw.shutdown();
     IndexSearcher searcher = newSearcher(ir);
     BooleanQuery query = new BooleanQuery();
     query.add(new TermQuery(new Term("body", "porter")), BooleanClause.Occur.SHOULD);
@@ -534,7 +534,7 @@
     iw.addDocument(doc);
     
     IndexReader ir = iw.getReader();
-    iw.close();
+    iw.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     PostingsHighlighter highlighter = new PostingsHighlighter();
@@ -560,7 +560,7 @@
     document.add(body);
     iw.addDocument(document);
     IndexReader ir = iw.getReader();
-    iw.close();
+    iw.shutdown();
     IndexSearcher searcher = newSearcher(ir);
     BooleanQuery query = new BooleanQuery();
     query.add(new TermQuery(new Term("body", "terms")), BooleanClause.Occur.SHOULD);
@@ -593,7 +593,7 @@
     iw.addDocument(doc);
     
     IndexReader ir = iw.getReader();
-    iw.close();
+    iw.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     PostingsHighlighter highlighter = new PostingsHighlighter(10000) {
@@ -631,7 +631,7 @@
     iw.addDocument(doc);
     
     IndexReader ir = iw.getReader();
-    iw.close();
+    iw.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     PostingsHighlighter highlighter = new PostingsHighlighter();
@@ -667,7 +667,7 @@
     iw.addDocument(doc);
     
     IndexReader ir = iw.getReader();
-    iw.close();
+    iw.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
 
@@ -715,7 +715,7 @@
     iw.addDocument(doc);
     
     IndexReader ir = iw.getReader();
-    iw.close();
+    iw.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     PostingsHighlighter highlighter = new PostingsHighlighter();
@@ -746,7 +746,7 @@
     iw.addDocument(doc);
     
     IndexReader ir = iw.getReader();
-    iw.close();
+    iw.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     PostingsHighlighter highlighter = new PostingsHighlighter() {
@@ -782,7 +782,7 @@
     iw.addDocument(doc);
     
     IndexReader ir = iw.getReader();
-    iw.close();
+    iw.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     PostingsHighlighter highlighter = new PostingsHighlighter(10000) {
@@ -818,7 +818,7 @@
     iw.addDocument(doc);
     
     IndexReader ir = iw.getReader();
-    iw.close();
+    iw.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     PostingsHighlighter highlighter = new PostingsHighlighter();
@@ -851,7 +851,7 @@
     iw.addDocument(doc);
     
     IndexReader ir = iw.getReader();
-    iw.close();
+    iw.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     PostingsHighlighter highlighter = new PostingsHighlighter();
@@ -887,7 +887,7 @@
     iw.addDocument(doc);
     
     IndexReader ir = iw.getReader();
-    iw.close();
+    iw.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     PostingsHighlighter highlighter = new PostingsHighlighter();
@@ -930,7 +930,7 @@
     }
 
     IndexReader ir = iw.getReader();
-    iw.close();
+    iw.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     PostingsHighlighter highlighter = new PostingsHighlighter();
@@ -973,7 +973,7 @@
     iw.addDocument(doc);
     
     IndexReader ir = iw.getReader();
-    iw.close();
+    iw.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     PostingsHighlighter highlighter = new PostingsHighlighter();
@@ -1005,7 +1005,7 @@
     iw.addDocument(doc);
     
     IndexReader ir = iw.getReader();
-    iw.close();
+    iw.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     PostingsHighlighter highlighter = new PostingsHighlighter() {
@@ -1048,7 +1048,7 @@
     iw.addDocument(doc);
     
     IndexReader ir = iw.getReader();
-    iw.close();
+    iw.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     PostingsHighlighter highlighter = new PostingsHighlighter() {
@@ -1086,7 +1086,7 @@
     iw.addDocument(doc);
     
     IndexReader ir = iw.getReader();
-    iw.close();
+    iw.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     PostingsHighlighter highlighter = new PostingsHighlighter() {
Index: lucene/highlighter/src/test/org/apache/lucene/search/postingshighlight/TestMultiTermHighlighting.java
===================================================================
--- lucene/highlighter/src/test/org/apache/lucene/search/postingshighlight/TestMultiTermHighlighting.java	(revision 1584870)
+++ lucene/highlighter/src/test/org/apache/lucene/search/postingshighlight/TestMultiTermHighlighting.java	(working copy)
@@ -78,7 +78,7 @@
     iw.addDocument(doc);
     
     IndexReader ir = iw.getReader();
-    iw.close();
+    iw.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     PostingsHighlighter highlighter = new PostingsHighlighter() {
@@ -130,7 +130,7 @@
     iw.addDocument(doc);
     
     IndexReader ir = iw.getReader();
-    iw.close();
+    iw.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     PostingsHighlighter highlighter = new PostingsHighlighter() {
@@ -182,7 +182,7 @@
     iw.addDocument(doc);
     
     IndexReader ir = iw.getReader();
-    iw.close();
+    iw.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     PostingsHighlighter highlighter = new PostingsHighlighter() {
@@ -234,7 +234,7 @@
     iw.addDocument(doc);
     
     IndexReader ir = iw.getReader();
-    iw.close();
+    iw.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     PostingsHighlighter highlighter = new PostingsHighlighter() {
@@ -295,7 +295,7 @@
     iw.addDocument(doc);
     
     IndexReader ir = iw.getReader();
-    iw.close();
+    iw.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     PostingsHighlighter highlighter = new PostingsHighlighter() {
@@ -405,7 +405,7 @@
     iw.addDocument(doc);
     
     IndexReader ir = iw.getReader();
-    iw.close();
+    iw.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     PostingsHighlighter highlighter = new PostingsHighlighter() {
@@ -458,7 +458,7 @@
     iw.addDocument(doc);
     
     IndexReader ir = iw.getReader();
-    iw.close();
+    iw.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     PostingsHighlighter highlighter = new PostingsHighlighter() {
@@ -500,7 +500,7 @@
     iw.addDocument(doc);
     
     IndexReader ir = iw.getReader();
-    iw.close();
+    iw.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     PostingsHighlighter highlighter = new PostingsHighlighter() {
@@ -541,7 +541,7 @@
     iw.addDocument(doc);
     
     IndexReader ir = iw.getReader();
-    iw.close();
+    iw.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     PostingsHighlighter highlighter = new PostingsHighlighter() {
@@ -583,7 +583,7 @@
     iw.addDocument(doc);
     
     IndexReader ir = iw.getReader();
-    iw.close();
+    iw.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     PostingsHighlighter highlighter = new PostingsHighlighter() {
@@ -625,7 +625,7 @@
     iw.addDocument(doc);
     
     IndexReader ir = iw.getReader();
-    iw.close();
+    iw.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     PostingsHighlighter highlighter = new PostingsHighlighter() {
@@ -668,7 +668,7 @@
     iw.addDocument(doc);
     
     IndexReader ir = iw.getReader();
-    iw.close();
+    iw.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     PostingsHighlighter highlighter = new PostingsHighlighter() {
@@ -710,7 +710,7 @@
     iw.addDocument(doc);
     
     IndexReader ir = iw.getReader();
-    iw.close();
+    iw.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     PostingsHighlighter highlighter = new PostingsHighlighter() {
Index: lucene/test-framework/src/java/org/apache/lucene/search/ShardSearchingTestBase.java
===================================================================
--- lucene/test-framework/src/java/org/apache/lucene/search/ShardSearchingTestBase.java	(revision 1584870)
+++ lucene/test-framework/src/java/org/apache/lucene/search/ShardSearchingTestBase.java	(working copy)
@@ -537,7 +537,7 @@
       }
       searchers.close();
       mgr.close();
-      writer.close();
+      writer.shutdown();
       dir.close();
     }
   }
Index: lucene/test-framework/src/java/org/apache/lucene/search/SearchEquivalenceTestBase.java
===================================================================
--- lucene/test-framework/src/java/org/apache/lucene/search/SearchEquivalenceTestBase.java	(revision 1584870)
+++ lucene/test-framework/src/java/org/apache/lucene/search/SearchEquivalenceTestBase.java	(working copy)
@@ -88,7 +88,7 @@
     reader = iw.getReader();
     s1 = newSearcher(reader);
     s2 = newSearcher(reader);
-    iw.close();
+    iw.shutdown();
   }
   
   @AfterClass
Index: lucene/test-framework/src/java/org/apache/lucene/search/QueryUtils.java
===================================================================
--- lucene/test-framework/src/java/org/apache/lucene/search/QueryUtils.java	(revision 1584870)
+++ lucene/test-framework/src/java/org/apache/lucene/search/QueryUtils.java	(working copy)
@@ -210,8 +210,7 @@
       w.addDocument(new Document());
     }
     w.forceMerge(1);
-    w.commit();
-    w.close();
+    w.shutdown();
     DirectoryReader reader = DirectoryReader.open(d);
     return new AllDeletedFilterReader(LuceneTestCase.getOnlySegmentReader(reader));
   }
Index: lucene/test-framework/src/java/org/apache/lucene/index/RandomIndexWriter.java
===================================================================
--- lucene/test-framework/src/java/org/apache/lucene/index/RandomIndexWriter.java	(revision 1584870)
+++ lucene/test-framework/src/java/org/apache/lucene/index/RandomIndexWriter.java	(working copy)
@@ -338,6 +338,19 @@
   }
 
   /**
+   * Shuts down this writer
+   * @see IndexWriter#shutdown()
+   */
+  public void shutdown() throws IOException {
+    // if someone isn't using getReader() API, we want to be sure to
+    // forceMerge since presumably they might open a reader on the dir.
+    if (getReaderCalled == false && r.nextInt(8) == 2) {
+      doRandomForceMerge();
+    }
+    w.shutdown();
+  }
+
+  /**
    * Forces a forceMerge.
    * <p>
    * NOTE: this should be avoided in tests unless absolutely necessary,
Index: lucene/test-framework/src/java/org/apache/lucene/index/BaseMergePolicyTestCase.java
===================================================================
--- lucene/test-framework/src/java/org/apache/lucene/index/BaseMergePolicyTestCase.java	(revision 1584870)
+++ lucene/test-framework/src/java/org/apache/lucene/index/BaseMergePolicyTestCase.java	(working copy)
@@ -62,7 +62,7 @@
       mayMerge.set(segmentCount > maxNumSegments);
       writer.forceMerge(maxNumSegments);
     }
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
   
Index: lucene/test-framework/src/java/org/apache/lucene/index/BasePostingsFormatTestCase.java
===================================================================
--- lucene/test-framework/src/java/org/apache/lucene/index/BasePostingsFormatTestCase.java	(revision 1584870)
+++ lucene/test-framework/src/java/org/apache/lucene/index/BasePostingsFormatTestCase.java	(working copy)
@@ -1298,7 +1298,7 @@
     assertEquals(termsEnum.term(), new BytesRef("something"));
     assertNull(termsEnum.next());
     ir.close();
-    iw.close();
+    iw.shutdown();
     dir.close();
   }
   
@@ -1323,7 +1323,7 @@
     assertEquals(termsEnum.term(), new BytesRef(""));
     assertNull(termsEnum.next());
     ir.close();
-    iw.close();
+    iw.shutdown();
     dir.close();
   }
   
@@ -1358,7 +1358,7 @@
       }
     }
     ir.close();
-    iw.close();
+    iw.shutdown();
     dir.close();
   }
 
@@ -1555,7 +1555,7 @@
     }
 
     IndexReader r = w.getReader();
-    w.close();
+    w.shutdown();
 
     Terms terms = MultiFields.getTerms(r, "body");
     assertEquals(sumDocFreq.get(), terms.getSumDocFreq());
Index: lucene/test-framework/src/java/org/apache/lucene/index/BaseTermVectorsFormatTestCase.java
===================================================================
--- lucene/test-framework/src/java/org/apache/lucene/index/BaseTermVectorsFormatTestCase.java	(revision 1584870)
+++ lucene/test-framework/src/java/org/apache/lucene/index/BaseTermVectorsFormatTestCase.java	(working copy)
@@ -547,7 +547,7 @@
       final Fields fields = reader.getTermVectors(docWithVectorsID);
       assertEquals(doc, fields);
       reader.close();
-      writer.close();
+      writer.shutdown();
       dir.close();
     }
   }
@@ -565,7 +565,7 @@
       final IndexReader reader = writer.getReader();
       assertEquals(doc, reader.getTermVectors(0));
       reader.close();
-      writer.close();
+      writer.shutdown();
       dir.close();
     }
   }
@@ -580,7 +580,7 @@
       final IndexReader reader = writer.getReader();
       assertEquals(doc, reader.getTermVectors(0));
       reader.close();
-      writer.close();
+      writer.shutdown();
       dir.close();
     }
   }
@@ -606,7 +606,7 @@
         final int doc2ID = docID(reader, "2");
         assertEquals(doc2, reader.getTermVectors(doc2ID));
         reader.close();
-        writer.close();
+        writer.shutdown();
         dir.close();
       }
     }
@@ -630,7 +630,7 @@
       assertEquals(docs[i], reader.getTermVectors(docID));
     }
     reader.close();
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
 
@@ -668,7 +668,7 @@
         }
       }
       reader.close();
-      writer.close();
+      writer.shutdown();
       dir.close();
     }
   }
@@ -719,7 +719,7 @@
         thread.join();
       }
       reader.close();
-      writer.close();
+      writer.shutdown();
       dir.close();
       assertNull("One thread threw an exception", exception.get());
     }
Index: lucene/test-framework/src/java/org/apache/lucene/index/DocHelper.java
===================================================================
--- lucene/test-framework/src/java/org/apache/lucene/index/DocHelper.java	(revision 1584870)
+++ lucene/test-framework/src/java/org/apache/lucene/index/DocHelper.java	(working copy)
@@ -276,7 +276,7 @@
     writer.addDocument(doc);
     writer.commit();
     SegmentCommitInfo info = writer.newestSegment();
-    writer.close();
+    writer.shutdown();
     return info;
   }
 
Index: lucene/test-framework/src/java/org/apache/lucene/index/ThreadedIndexingAndSearchingTestCase.java
===================================================================
--- lucene/test-framework/src/java/org/apache/lucene/index/ThreadedIndexingAndSearchingTestCase.java	(revision 1584870)
+++ lucene/test-framework/src/java/org/apache/lucene/index/ThreadedIndexingAndSearchingTestCase.java	(working copy)
@@ -633,8 +633,9 @@
     assertEquals("index=" + writer.segString() + " addCount=" + addCount + " delCount=" + delCount, addCount.get() - delCount.get(), writer.numDocs());
 
     doClose();
-    writer.close(false);
 
+    writer.shutdown(false);
+
     // Cannot shutdown until after writer is closed because
     // writer has merged segment warmer that uses IS to run
     // searches, and that IS may be using this es!
Index: lucene/test-framework/src/java/org/apache/lucene/index/BaseDocValuesFormatTestCase.java
===================================================================
--- lucene/test-framework/src/java/org/apache/lucene/index/BaseDocValuesFormatTestCase.java	(revision 1584870)
+++ lucene/test-framework/src/java/org/apache/lucene/index/BaseDocValuesFormatTestCase.java	(working copy)
@@ -96,7 +96,7 @@
     doc.add(newTextField("fieldname", text, Field.Store.YES));
     doc.add(new NumericDocValuesField("dv", 5));
     iwriter.addDocument(doc);
-    iwriter.close();
+    iwriter.shutdown();
     
     // Now search the index:
     IndexReader ireader = DirectoryReader.open(directory); // read-only=true
@@ -128,7 +128,7 @@
     doc.add(newTextField("fieldname", text, Field.Store.YES));
     doc.add(new FloatDocValuesField("dv", 5.7f));
     iwriter.addDocument(doc);
-    iwriter.close();
+    iwriter.shutdown();
     
     // Now search the index:
     IndexReader ireader = DirectoryReader.open(directory); // read-only=true
@@ -161,7 +161,7 @@
     doc.add(new NumericDocValuesField("dv1", 5));
     doc.add(new NumericDocValuesField("dv2", 17));
     iwriter.addDocument(doc);
-    iwriter.close();
+    iwriter.shutdown();
     
     // Now search the index:
     IndexReader ireader = DirectoryReader.open(directory); // read-only=true
@@ -196,7 +196,7 @@
     doc.add(new BinaryDocValuesField("dv1", new BytesRef(longTerm)));
     doc.add(new BinaryDocValuesField("dv2", new BytesRef(text)));
     iwriter.addDocument(doc);
-    iwriter.close();
+    iwriter.shutdown();
     
     // Now search the index:
     IndexReader ireader = DirectoryReader.open(directory); // read-only=true
@@ -234,7 +234,7 @@
     doc.add(new NumericDocValuesField("dv1", 5));
     doc.add(new BinaryDocValuesField("dv2", new BytesRef("hello world")));
     iwriter.addDocument(doc);
-    iwriter.close();
+    iwriter.shutdown();
     
     // Now search the index:
     IndexReader ireader = DirectoryReader.open(directory); // read-only=true
@@ -272,7 +272,7 @@
     doc.add(new NumericDocValuesField("dv2", 5));
     doc.add(new BinaryDocValuesField("dv3", new BytesRef("hello world")));
     iwriter.addDocument(doc);
-    iwriter.close();
+    iwriter.shutdown();
     
     // Now search the index:
     IndexReader ireader = DirectoryReader.open(directory); // read-only=true
@@ -314,7 +314,7 @@
     doc.add(new SortedDocValuesField("dv2", new BytesRef("hello hello")));
     doc.add(new NumericDocValuesField("dv3", 5));
     iwriter.addDocument(doc);
-    iwriter.close();
+    iwriter.shutdown();
     
     // Now search the index:
     IndexReader ireader = DirectoryReader.open(directory); // read-only=true
@@ -359,7 +359,7 @@
     doc.add(new NumericDocValuesField("dv", 2));
     iwriter.addDocument(doc);
     iwriter.forceMerge(1);
-    iwriter.close();
+    iwriter.shutdown();
     
     // Now search the index:
     IndexReader ireader = DirectoryReader.open(directory); // read-only=true
@@ -389,7 +389,7 @@
     doc.add(new NumericDocValuesField("dv", 99));
     iwriter.addDocument(doc);
     iwriter.forceMerge(1);
-    iwriter.close();
+    iwriter.shutdown();
     
     // Now search the index:
     IndexReader ireader = DirectoryReader.open(directory); // read-only=true
@@ -424,7 +424,7 @@
     doc.add(new NumericDocValuesField("dv", Long.MAX_VALUE));
     iwriter.addDocument(doc);
     iwriter.forceMerge(1);
-    iwriter.close();
+    iwriter.shutdown();
     
     // Now search the index:
     IndexReader ireader = DirectoryReader.open(directory); // read-only=true
@@ -451,7 +451,7 @@
     doc.add(new NumericDocValuesField("dv", 9062230939892376225L));
     iwriter.addDocument(doc);
     iwriter.forceMerge(1);
-    iwriter.close();
+    iwriter.shutdown();
     
     // Now search the index:
     IndexReader ireader = DirectoryReader.open(directory); // read-only=true
@@ -476,7 +476,7 @@
     doc.add(newTextField("fieldname", text, Field.Store.YES));
     doc.add(new BinaryDocValuesField("dv", new BytesRef("hello world")));
     iwriter.addDocument(doc);
-    iwriter.close();
+    iwriter.shutdown();
     
     // Now search the index:
     IndexReader ireader = DirectoryReader.open(directory); // read-only=true
@@ -518,7 +518,7 @@
     doc.add(new BinaryDocValuesField("dv", new BytesRef("hello 2")));
     iwriter.addDocument(doc);
     iwriter.forceMerge(1);
-    iwriter.close();
+    iwriter.shutdown();
     
     // Now search the index:
     IndexReader ireader = DirectoryReader.open(directory); // read-only=true
@@ -553,7 +553,7 @@
     doc.add(newTextField("fieldname", text, Field.Store.YES));
     doc.add(new SortedDocValuesField("dv", new BytesRef("hello world")));
     iwriter.addDocument(doc);
-    iwriter.close();
+    iwriter.shutdown();
     
     // Now search the index:
     IndexReader ireader = DirectoryReader.open(directory); // read-only=true
@@ -592,7 +592,7 @@
     doc.add(new SortedDocValuesField("dv", new BytesRef("hello world 2")));
     iwriter.addDocument(doc);
     iwriter.forceMerge(1);
-    iwriter.close();
+    iwriter.shutdown();
     
     // Now search the index:
     IndexReader ireader = DirectoryReader.open(directory); // read-only=true
@@ -625,7 +625,7 @@
     doc.add(new SortedDocValuesField("dv", new BytesRef("hello world 1")));
     iwriter.addDocument(doc);
     iwriter.forceMerge(1);
-    iwriter.close();
+    iwriter.shutdown();
     
     // Now search the index:
     IndexReader ireader = DirectoryReader.open(directory); // read-only=true
@@ -662,7 +662,7 @@
     doc.add(new SortedDocValuesField("dv", new BytesRef("hello world 2")));
     iwriter.addDocument(doc);
     iwriter.forceMerge(1);
-    iwriter.close();
+    iwriter.shutdown();
     
     // Now search the index:
     IndexReader ireader = DirectoryReader.open(directory); // read-only=true
@@ -709,7 +709,7 @@
     iwriter.forceMerge(1);
     
     DirectoryReader ireader = iwriter.getReader();
-    iwriter.close();
+    iwriter.shutdown();
     
     SortedDocValues dv = getOnlySegmentReader(ireader).getSortedDocValues("field");
     if (defaultCodecSupportsDocsWithField()) {
@@ -737,7 +737,7 @@
     Document doc = new Document();
     doc.add(new BinaryDocValuesField("dv", new BytesRef("hello\nworld\r1")));
     iwriter.addDocument(doc);
-    iwriter.close();
+    iwriter.shutdown();
     
     // Now search the index:
     IndexReader ireader = DirectoryReader.open(directory); // read-only=true
@@ -763,7 +763,7 @@
     iwriter.addDocument(doc);
     // 2nd doc missing the DV field
     iwriter.addDocument(new Document());
-    iwriter.close();
+    iwriter.shutdown();
     
     // Now search the index:
     IndexReader ireader = DirectoryReader.open(directory); // read-only=true
@@ -802,7 +802,7 @@
     iwriter.forceMerge(1);
     
     DirectoryReader ireader = iwriter.getReader();
-    iwriter.close();
+    iwriter.shutdown();
 
     SortedDocValues dv = getOnlySegmentReader(ireader).getSortedDocValues("field");
     assertEquals(3, dv.getValueCount());
@@ -866,7 +866,7 @@
     doc.add(new SortedDocValuesField("dv", new BytesRef("")));
     iwriter.addDocument(doc);
     iwriter.forceMerge(1);
-    iwriter.close();
+    iwriter.shutdown();
     
     // Now search the index:
     IndexReader ireader = DirectoryReader.open(directory); // read-only=true
@@ -896,7 +896,7 @@
     doc.add(new BinaryDocValuesField("dv", new BytesRef("")));
     iwriter.addDocument(doc);
     iwriter.forceMerge(1);
-    iwriter.close();
+    iwriter.shutdown();
     
     // Now search the index:
     IndexReader ireader = DirectoryReader.open(directory); // read-only=true
@@ -925,7 +925,7 @@
     random().nextBytes(bytes);
     doc.add(new BinaryDocValuesField("dv", b));
     iwriter.addDocument(doc);
-    iwriter.close();
+    iwriter.shutdown();
     
     // Now search the index:
     IndexReader ireader = DirectoryReader.open(directory); // read-only=true
@@ -952,7 +952,7 @@
     random().nextBytes(bytes);
     doc.add(new SortedDocValuesField("dv", b));
     iwriter.addDocument(doc);
-    iwriter.close();
+    iwriter.shutdown();
     
     // Now search the index:
     IndexReader ireader = DirectoryReader.open(directory); // read-only=true
@@ -975,7 +975,7 @@
     Document doc = new Document();
     doc.add(new BinaryDocValuesField("dv", new BytesRef("boo!")));
     iwriter.addDocument(doc);
-    iwriter.close();
+    iwriter.shutdown();
     
     // Now search the index:
     IndexReader ireader = DirectoryReader.open(directory); // read-only=true
@@ -1001,7 +1001,7 @@
     Document doc = new Document();
     doc.add(new SortedDocValuesField("dv", new BytesRef("boo!")));
     iwriter.addDocument(doc);
-    iwriter.close();
+    iwriter.shutdown();
     
     // Now search the index:
     IndexReader ireader = DirectoryReader.open(directory); // read-only=true
@@ -1030,7 +1030,7 @@
     doc = new Document();
     doc.add(new BinaryDocValuesField("dv", new BytesRef("bar!")));
     iwriter.addDocument(doc);
-    iwriter.close();
+    iwriter.shutdown();
     
     // Now search the index:
     IndexReader ireader = DirectoryReader.open(directory); // read-only=true
@@ -1063,7 +1063,7 @@
     doc = new Document();
     doc.add(new SortedDocValuesField("dv", new BytesRef("bar!")));
     iwriter.addDocument(doc);
-    iwriter.close();
+    iwriter.shutdown();
     
     // Now search the index:
     IndexReader ireader = DirectoryReader.open(directory); // read-only=true
@@ -1101,7 +1101,7 @@
     writer.commit();
     writer.forceMerge(1, true);
 
-    writer.close(true);
+    writer.shutdown();
 
     DirectoryReader reader = DirectoryReader.open(dir);
     assertEquals(1, reader.leaves().size());
@@ -1209,7 +1209,7 @@
     }
 
     reader.close();
-    w.close();
+    w.shutdown();
     dir.close();
   }
 
@@ -1265,7 +1265,7 @@
     // 256 values
     writer.forceMerge(numDocs / 256);
 
-    writer.close();
+    writer.shutdown();
     
     // compare
     DirectoryReader ir = DirectoryReader.open(dir);
@@ -1334,7 +1334,7 @@
     // 256 values
     writer.forceMerge(numDocs / 256);
 
-    writer.close();
+    writer.shutdown();
     
     // compare
     DirectoryReader ir = DirectoryReader.open(dir);
@@ -1449,7 +1449,7 @@
       int id = random().nextInt(numDocs);
       writer.deleteDocuments(new Term("id", Integer.toString(id)));
     }
-    writer.close();
+    writer.shutdown();
     
     // compare
     DirectoryReader ir = DirectoryReader.open(dir);
@@ -1520,7 +1520,7 @@
       int id = random().nextInt(numDocs);
       writer.deleteDocuments(new Term("id", Integer.toString(id)));
     }
-    writer.close();
+    writer.shutdown();
     
     // compare
     DirectoryReader ir = DirectoryReader.open(dir);
@@ -1575,7 +1575,7 @@
       int id = random().nextInt(numDocs);
       writer.deleteDocuments(new Term("id", Integer.toString(id)));
     }
-    writer.close();
+    writer.shutdown();
     
     // compare
     DirectoryReader ir = DirectoryReader.open(dir);
@@ -1629,7 +1629,7 @@
     iwriter.addDocument(doc);
     
     DirectoryReader ireader = iwriter.getReader();
-    iwriter.close();
+    iwriter.shutdown();
     
     SortedSetDocValues dv = getOnlySegmentReader(ireader).getSortedSetDocValues("field");
     
@@ -1656,7 +1656,7 @@
     iwriter.addDocument(doc);
     
     DirectoryReader ireader = iwriter.getReader();
-    iwriter.close();
+    iwriter.shutdown();
     
     SortedSetDocValues dv = getOnlySegmentReader(ireader).getSortedSetDocValues("field");
     
@@ -1700,7 +1700,7 @@
     iwriter.forceMerge(1);
     
     DirectoryReader ireader = iwriter.getReader();
-    iwriter.close();
+    iwriter.shutdown();
 
     SortedSetDocValues dv = getOnlySegmentReader(ireader).getSortedSetDocValues("field");
     assertEquals(2, dv.getValueCount());
@@ -1735,7 +1735,7 @@
     iwriter.addDocument(doc);
     
     DirectoryReader ireader = iwriter.getReader();
-    iwriter.close();
+    iwriter.shutdown();
     
     SortedSetDocValues dv = getOnlySegmentReader(ireader).getSortedSetDocValues("field");
     
@@ -1766,7 +1766,7 @@
     iwriter.addDocument(doc);
     
     DirectoryReader ireader = iwriter.getReader();
-    iwriter.close();
+    iwriter.shutdown();
     
     SortedSetDocValues dv = getOnlySegmentReader(ireader).getSortedSetDocValues("field");
     
@@ -1807,7 +1807,7 @@
     iwriter.forceMerge(1);
     
     DirectoryReader ireader = iwriter.getReader();
-    iwriter.close();
+    iwriter.shutdown();
 
     SortedSetDocValues dv = getOnlySegmentReader(ireader).getSortedSetDocValues("field");
     assertEquals(3, dv.getValueCount());
@@ -1852,7 +1852,7 @@
     iwriter.addDocument(doc);
     iwriter.forceMerge(1);
     DirectoryReader ireader = iwriter.getReader();
-    iwriter.close();
+    iwriter.shutdown();
     
     SortedSetDocValues dv = getOnlySegmentReader(ireader).getSortedSetDocValues("field");
     assertEquals(1, dv.getValueCount());
@@ -1887,7 +1887,7 @@
     iwriter.forceMerge(1);
    
     DirectoryReader ireader = iwriter.getReader();
-    iwriter.close();
+    iwriter.shutdown();
     
     SortedSetDocValues dv = getOnlySegmentReader(ireader).getSortedSetDocValues("field");
     assertEquals(1, dv.getValueCount());
@@ -1921,7 +1921,7 @@
     
     iwriter.forceMerge(1);
     DirectoryReader ireader = iwriter.getReader();
-    iwriter.close();
+    iwriter.shutdown();
     
     SortedSetDocValues dv = getOnlySegmentReader(ireader).getSortedSetDocValues("field");
     assertEquals(1, dv.getValueCount());
@@ -1956,7 +1956,7 @@
     iwriter.forceMerge(1);
     
     DirectoryReader ireader = iwriter.getReader();
-    iwriter.close();
+    iwriter.shutdown();
     
     SortedSetDocValues dv = getOnlySegmentReader(ireader).getSortedSetDocValues("field");
     assertEquals(1, dv.getValueCount());
@@ -1993,7 +1993,7 @@
     iwriter.forceMerge(1);
     
     DirectoryReader ireader = iwriter.getReader();
-    iwriter.close();
+    iwriter.shutdown();
     
     SortedSetDocValues dv = getOnlySegmentReader(ireader).getSortedSetDocValues("field");
     assertEquals(0, dv.getValueCount());
@@ -2017,7 +2017,7 @@
     iwriter.addDocument(doc);
     
     DirectoryReader ireader = iwriter.getReader();
-    iwriter.close();
+    iwriter.shutdown();
 
     SortedSetDocValues dv = getOnlySegmentReader(ireader).getSortedSetDocValues("field");
     assertEquals(3, dv.getValueCount());
@@ -2115,7 +2115,7 @@
       int id = random().nextInt(numDocs);
       writer.deleteDocuments(new Term("id", Integer.toString(id)));
     }
-    writer.close();
+    writer.shutdown();
     
     // compare
     DirectoryReader ir = DirectoryReader.open(dir);
@@ -2355,7 +2355,7 @@
     assertEquals(ir.maxDoc(), expected, actual);
     ir.close();
     
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
   
@@ -2424,7 +2424,7 @@
     doc.add(new StringField("id", "1", Field.Store.YES));
     iw.addDocument(doc);
     iw.forceMerge(1);
-    iw.close();
+    iw.shutdown();
     
     IndexReader ir = DirectoryReader.open(directory);
     assertEquals(1, ir.leaves().size());
@@ -2454,7 +2454,7 @@
     doc.add(new StringField("id", "1", Field.Store.YES));
     iw.addDocument(doc);
     iw.forceMerge(1);
-    iw.close();
+    iw.shutdown();
     
     IndexReader ir = DirectoryReader.open(directory);
     assertEquals(1, ir.leaves().size());
@@ -2488,7 +2488,7 @@
     doc.add(new NumericDocValuesField("dv1", 5));
     iw.addDocument(doc);
     iw.forceMerge(1);
-    iw.close();
+    iw.shutdown();
     
     IndexReader ir = DirectoryReader.open(directory);
     assertEquals(1, ir.leaves().size());
@@ -2519,7 +2519,7 @@
     doc.add(new StringField("id", "1", Field.Store.YES));
     iw.addDocument(doc);
     iw.forceMerge(1);
-    iw.close();
+    iw.shutdown();
     
     IndexReader ir = DirectoryReader.open(directory);
     assertEquals(1, ir.leaves().size());
@@ -2552,7 +2552,7 @@
     doc.add(new StringField("id", "1", Field.Store.YES));
     iw.addDocument(doc);
     iw.forceMerge(1);
-    iw.close();
+    iw.shutdown();
     
     IndexReader ir = DirectoryReader.open(directory);
     assertEquals(1, ir.leaves().size());
@@ -2589,7 +2589,7 @@
     doc.add(new BinaryDocValuesField("dv1", new BytesRef("boo")));
     iw.addDocument(doc);
     iw.forceMerge(1);
-    iw.close();
+    iw.shutdown();
     
     IndexReader ir = DirectoryReader.open(directory);
     assertEquals(1, ir.leaves().size());
@@ -2686,7 +2686,7 @@
         return;
       }
     }
-    w.close();
+    w.shutdown();
 
     AtomicReader ar = SlowCompositeReaderWrapper.wrap(r);
 
@@ -2758,7 +2758,7 @@
     }
     
     DirectoryReader r = w.getReader();
-    w.close();
+    w.shutdown();
 
     AtomicReader ar = SlowCompositeReaderWrapper.wrap(r);
 
@@ -2820,7 +2820,7 @@
       int id = random().nextInt(numDocs);
       writer.deleteDocuments(new Term("id", Integer.toString(id)));
     }
-    writer.close();
+    writer.shutdown();
     
     // compare
     final DirectoryReader ir = DirectoryReader.open(dir);
@@ -2925,7 +2925,7 @@
       int id = random().nextInt(numDocs);
       writer.deleteDocuments(new Term("id", Integer.toString(id)));
     }
-    writer.close();
+    writer.shutdown();
     
     // compare
     final DirectoryReader ir = DirectoryReader.open(dir);
@@ -3036,7 +3036,7 @@
       doc.add(new BinaryDocValuesField("field", new BytesRef()));
       w.addDocument(doc);
       IndexReader r = w.getReader();
-      w.close();
+      w.shutdown();
 
       AtomicReader ar = SlowCompositeReaderWrapper.wrap(r);
       BinaryDocValues values = ar.getBinaryDocValues("field");
Index: lucene/test-framework/src/java/org/apache/lucene/index/BaseStoredFieldsFormatTestCase.java
===================================================================
--- lucene/test-framework/src/java/org/apache/lucene/index/BaseStoredFieldsFormatTestCase.java	(revision 1584870)
+++ lucene/test-framework/src/java/org/apache/lucene/index/BaseStoredFieldsFormatTestCase.java	(working copy)
@@ -184,7 +184,7 @@
         w.forceMerge(1);
       }
     }
-    w.close();
+    w.shutdown();
     dir.close();
   }
   
@@ -219,7 +219,7 @@
     assertEquals(f.stringValue(), "1 2 3");
     assertFalse(it.hasNext());
     r.close();
-    w.close();
+    w.shutdown();
     d.close();
   }
   
@@ -240,7 +240,7 @@
     assertEquals(17, f.binaryValue().length);
     doc.add(f);
     w.addDocument(doc);
-    w.close();
+    w.shutdown();
 
     IndexReader ir = DirectoryReader.open(dir);
     StoredDocument doc2 = ir.document(0);
@@ -306,7 +306,7 @@
       w.addDocument(doc);
     }
     final DirectoryReader r = w.getReader();
-    w.close();
+    w.shutdown();
     
     assertEquals(numDocs, r.numDocs());
 
@@ -334,7 +334,7 @@
     doc.add(new StringField("field2", "value", Field.Store.YES));
     w.addDocument(doc);
     IndexReader r = w.getReader();
-    w.close();
+    w.shutdown();
     assertFalse(r.document(0).getField("field").fieldType().indexed());
     assertTrue(r.document(0).getField("field2").fieldType().indexed());
     r.close();
@@ -390,7 +390,7 @@
       }
     }
     reader.close();
-    iw.close();
+    iw.shutdown();
     dir.close();
   }
   
@@ -415,7 +415,7 @@
     }
     rd.close();
     
-    iw.close();
+    iw.shutdown();
     dir.close();
   }
   
@@ -488,7 +488,7 @@
       throw ex.get();
     }
     
-    iw.close();
+    iw.shutdown();
     dir.close();
   }
   
@@ -543,7 +543,7 @@
       }
       iw.w.addDocument(doc);
       if (random().nextBoolean() && (i % (data.length / 10) == 0)) {
-        iw.w.close();
+        iw.w.shutdown();
         // test merging against a non-compressing codec
         if (iwConf.getCodec() == otherCodec) {
           iwConf.setCodec(Codec.getDefault());
@@ -589,7 +589,7 @@
     iw.commit();
     iw.forceMerge(1);
     
-    iw.close();
+    iw.shutdown();
     dir.close();
   }
   
@@ -658,7 +658,7 @@
       }
     }
     rd.close();
-    iw.close();
+    iw.shutdown();
     dir.close();
   }
 }
Index: lucene/test-framework/src/java/org/apache/lucene/store/MockDirectoryWrapper.java
===================================================================
--- lucene/test-framework/src/java/org/apache/lucene/store/MockDirectoryWrapper.java	(revision 1584870)
+++ lucene/test-framework/src/java/org/apache/lucene/store/MockDirectoryWrapper.java	(working copy)
@@ -777,7 +777,7 @@
           DirectoryReader ir1 = DirectoryReader.open(this);
           int numDocs1 = ir1.numDocs();
           ir1.close();
-          new IndexWriter(this, new IndexWriterConfig(LuceneTestCase.TEST_VERSION_CURRENT, null)).close();
+          new IndexWriter(this, new IndexWriterConfig(LuceneTestCase.TEST_VERSION_CURRENT, null)).shutdown();
           DirectoryReader ir2 = DirectoryReader.open(this);
           int numDocs2 = ir2.numDocs();
           ir2.close();
Index: lucene/test-framework/src/java/org/apache/lucene/analysis/BaseTokenStreamTestCase.java
===================================================================
--- lucene/test-framework/src/java/org/apache/lucene/analysis/BaseTokenStreamTestCase.java	(revision 1584870)
+++ lucene/test-framework/src/java/org/apache/lucene/analysis/BaseTokenStreamTestCase.java	(working copy)
@@ -533,12 +533,15 @@
           throw new RuntimeException("some thread(s) failed");
         }
       }
+      if (iw != null) {
+        iw.shutdown();
+      }
       success = true;
     } finally {
       if (success) {
-        IOUtils.close(iw, dir);
+        IOUtils.close(dir);
       } else {
-        IOUtils.closeWhileHandlingException(iw, dir); // checkindex
+        IOUtils.closeWhileHandlingException(dir); // checkindex
       }
     }
   }
Index: lucene/test-framework/src/java/org/apache/lucene/analysis/CollationTestBase.java
===================================================================
--- lucene/test-framework/src/java/org/apache/lucene/analysis/CollationTestBase.java	(revision 1584870)
+++ lucene/test-framework/src/java/org/apache/lucene/analysis/CollationTestBase.java	(working copy)
@@ -70,7 +70,7 @@
     doc.add(new TextField("content", "\u0633\u0627\u0628", Field.Store.YES));
     doc.add(new StringField("body", "body", Field.Store.YES));
     writer.addDocument(doc);
-    writer.close();
+    writer.shutdown();
     IndexReader reader = DirectoryReader.open(dir);
     IndexSearcher searcher = new IndexSearcher(reader);
     Query query = new TermQuery(new Term("body","body"));
@@ -106,7 +106,7 @@
     // Collator (or an Arabic one for the case when Farsi is not supported).
     doc.add(new TextField("content", "\u0633\u0627\u0628", Field.Store.YES));
     writer.addDocument(doc);
-    writer.close();
+    writer.shutdown();
     IndexReader reader = DirectoryReader.open(dir);
     IndexSearcher searcher = new IndexSearcher(reader);
 
@@ -131,7 +131,7 @@
     doc.add(new TextField("content", "\u0633\u0627\u0628", Field.Store.YES));
     doc.add(new StringField("body", "body", Field.Store.YES));
     writer.addDocument(doc);
-    writer.close();
+    writer.shutdown();
 
     IndexReader reader = DirectoryReader.open(farsiIndex);
     IndexSearcher search = newSearcher(reader);
@@ -208,7 +208,7 @@
       writer.addDocument(doc);
     }
     writer.forceMerge(1);
-    writer.close();
+    writer.shutdown();
     IndexReader reader = DirectoryReader.open(indexStore);
     IndexSearcher searcher = new IndexSearcher(reader);
 
Index: lucene/queries/src/test/org/apache/lucene/queries/mlt/TestMoreLikeThis.java
===================================================================
--- lucene/queries/src/test/org/apache/lucene/queries/mlt/TestMoreLikeThis.java	(revision 1584870)
+++ lucene/queries/src/test/org/apache/lucene/queries/mlt/TestMoreLikeThis.java	(working copy)
@@ -55,7 +55,7 @@
     addDoc(writer, "lucene release");
 
     reader = writer.getReader();
-    writer.close();
+    writer.shutdown();
     searcher = newSearcher(reader);
   }
   
Index: lucene/queries/src/test/org/apache/lucene/queries/TermFilterTest.java
===================================================================
--- lucene/queries/src/test/org/apache/lucene/queries/TermFilterTest.java	(revision 1584870)
+++ lucene/queries/src/test/org/apache/lucene/queries/TermFilterTest.java	(working copy)
@@ -62,7 +62,7 @@
     IndexReader reader = SlowCompositeReaderWrapper.wrap(w.getReader());
     assertTrue(reader.getContext() instanceof AtomicReaderContext);
     AtomicReaderContext context = (AtomicReaderContext) reader.getContext();
-    w.close();
+    w.shutdown();
 
     DocIdSet idSet = termFilter(fieldName, "value1").getDocIdSet(context, context.reader().getLiveDocs());
     assertNotNull("must not be null", idSet);
@@ -94,7 +94,7 @@
       w.addDocument(doc);
     }
     IndexReader reader = w.getReader();
-    w.close();
+    w.shutdown();
     
     IndexSearcher searcher = newSearcher(reader);
     
Index: lucene/queries/src/test/org/apache/lucene/queries/BooleanFilterTest.java
===================================================================
--- lucene/queries/src/test/org/apache/lucene/queries/BooleanFilterTest.java	(revision 1584870)
+++ lucene/queries/src/test/org/apache/lucene/queries/BooleanFilterTest.java	(working copy)
@@ -57,7 +57,7 @@
     addDoc(writer, "admin", "020", "20050101", "Maybe");
     addDoc(writer, "admin guest", "030", "20050101", "N");
     reader = SlowCompositeReaderWrapper.wrap(writer.getReader());
-    writer.close();
+    writer.shutdown();
   }
 
   @Override
Index: lucene/queries/src/test/org/apache/lucene/queries/CommonTermsQueryTest.java
===================================================================
--- lucene/queries/src/test/org/apache/lucene/queries/CommonTermsQueryTest.java	(revision 1584870)
+++ lucene/queries/src/test/org/apache/lucene/queries/CommonTermsQueryTest.java	(working copy)
@@ -127,7 +127,7 @@
       
     }
     r.close();
-    w.close();
+    w.shutdown();
     dir.close();
   }
   
@@ -322,7 +322,7 @@
               r.document(search.scoreDocs[1].doc).get("id"))));
     }
     r.close();
-    w.close();
+    w.shutdown();
     dir.close();
   }
   
@@ -396,7 +396,7 @@
       assertEquals("0", r.document(search.scoreDocs[2].doc).get("id"));
     }
     r.close();
-    w.close();
+    w.shutdown();
     dir.close();
   }
   
@@ -498,7 +498,7 @@
     } finally {
       reader.close();
       wrapper.close();
-      w.close();
+      w.shutdown();
       dir.close();
     }
     
Index: lucene/queries/src/test/org/apache/lucene/queries/TermsFilterTest.java
===================================================================
--- lucene/queries/src/test/org/apache/lucene/queries/TermsFilterTest.java	(revision 1584870)
+++ lucene/queries/src/test/org/apache/lucene/queries/TermsFilterTest.java	(working copy)
@@ -77,7 +77,7 @@
     IndexReader reader = SlowCompositeReaderWrapper.wrap(w.getReader());
     assertTrue(reader.getContext() instanceof AtomicReaderContext);
     AtomicReaderContext context = (AtomicReaderContext) reader.getContext();
-    w.close();
+    w.shutdown();
 
     List<Term> terms = new ArrayList<>();
     terms.add(new Term(fieldName, "19"));
@@ -108,7 +108,7 @@
     doc.add(newStringField(fieldName, "content1", Field.Store.YES));
     w1.addDocument(doc);
     IndexReader reader1 = w1.getReader();
-    w1.close();
+    w1.shutdown();
     
     fieldName = "field2";
     Directory rd2 = newDirectory();
@@ -117,7 +117,7 @@
     doc.add(newStringField(fieldName, "content2", Field.Store.YES));
     w2.addDocument(doc);
     IndexReader reader2 = w2.getReader();
-    w2.close();
+    w2.shutdown();
     
     TermsFilter tf = new TermsFilter(new Term(fieldName, "content1"));
     MultiReader multi = new MultiReader(reader1, reader2);
@@ -155,7 +155,7 @@
     
     w.forceMerge(1);
     IndexReader reader = w.getReader();
-    w.close();
+    w.shutdown();
     assertEquals(1, reader.leaves().size());
     
     
@@ -194,7 +194,7 @@
     }
     w.forceMerge(1);
     IndexReader reader = w.getReader();
-    w.close();
+    w.shutdown();
     assertEquals(1, reader.leaves().size());
     AtomicReaderContext context = reader.leaves().get(0);
     TermsFilter tf = new TermsFilter(new ArrayList<>(terms));
@@ -220,7 +220,7 @@
       w.addDocument(doc);
     }
     IndexReader reader = w.getReader();
-    w.close();
+    w.shutdown();
     
     IndexSearcher searcher = newSearcher(reader);
     
Index: lucene/queries/src/test/org/apache/lucene/queries/ChainedFilterTest.java
===================================================================
--- lucene/queries/src/test/org/apache/lucene/queries/ChainedFilterTest.java	(revision 1584870)
+++ lucene/queries/src/test/org/apache/lucene/queries/ChainedFilterTest.java	(working copy)
@@ -73,7 +73,7 @@
       cal.add(Calendar.DATE, 1);
     }
     reader = writer.getReader();
-    writer.close();
+    writer.shutdown();
 
     searcher = newSearcher(reader);
 
@@ -194,7 +194,7 @@
     Directory dir = newDirectory();
     RandomIndexWriter writer = new RandomIndexWriter(random(), dir);
     IndexReader reader = writer.getReader();
-    writer.close();
+    writer.shutdown();
   
     IndexSearcher searcher = newSearcher(reader);
   
Index: lucene/queries/src/test/org/apache/lucene/queries/function/TestDocValuesFieldSources.java
===================================================================
--- lucene/queries/src/test/org/apache/lucene/queries/function/TestDocValuesFieldSources.java	(revision 1584870)
+++ lucene/queries/src/test/org/apache/lucene/queries/function/TestDocValuesFieldSources.java	(working copy)
@@ -91,7 +91,7 @@
         iw.commit();
       }
     }
-    iw.close();
+    iw.shutdown();
 
     DirectoryReader rd = DirectoryReader.open(d);
     for (AtomicReaderContext leave : rd.leaves()) {
Index: lucene/queries/src/test/org/apache/lucene/queries/function/FunctionTestSetup.java
===================================================================
--- lucene/queries/src/test/org/apache/lucene/queries/function/FunctionTestSetup.java	(revision 1584870)
+++ lucene/queries/src/test/org/apache/lucene/queries/function/FunctionTestSetup.java	(working copy)
@@ -135,7 +135,7 @@
       }
       iw.forceMerge(1);
     }
-    iw.close();
+    iw.shutdown();
     if (VERBOSE) {
       System.out.println("TEST: setUp done close");
     }
Index: lucene/queries/src/test/org/apache/lucene/queries/function/TestLongNormValueSource.java
===================================================================
--- lucene/queries/src/test/org/apache/lucene/queries/function/TestLongNormValueSource.java	(revision 1584870)
+++ lucene/queries/src/test/org/apache/lucene/queries/function/TestLongNormValueSource.java	(working copy)
@@ -66,7 +66,7 @@
 
     reader = iw.getReader();
     searcher = newSearcher(reader);
-    iw.close();
+    iw.shutdown();
   }
 
   @AfterClass
Index: lucene/queries/src/test/org/apache/lucene/queries/function/TestValueSources.java
===================================================================
--- lucene/queries/src/test/org/apache/lucene/queries/function/TestValueSources.java	(revision 1584870)
+++ lucene/queries/src/test/org/apache/lucene/queries/function/TestValueSources.java	(working copy)
@@ -127,7 +127,7 @@
     
     reader = iw.getReader();
     searcher = newSearcher(reader);
-    iw.close();
+    iw.shutdown();
   }
   
   @AfterClass
Index: lucene/queries/src/test/org/apache/lucene/queries/function/TestFunctionQuerySort.java
===================================================================
--- lucene/queries/src/test/org/apache/lucene/queries/function/TestFunctionQuerySort.java	(revision 1584870)
+++ lucene/queries/src/test/org/apache/lucene/queries/function/TestFunctionQuerySort.java	(working copy)
@@ -59,7 +59,7 @@
 
     // Open index
     IndexReader reader = writer.getReader();
-    writer.close();
+    writer.shutdown();
     IndexSearcher searcher = newSearcher(reader);
 
     // Get ValueSource from FieldCache
Index: lucene/queries/src/test/org/apache/lucene/queries/function/TestBoostedQuery.java
===================================================================
--- lucene/queries/src/test/org/apache/lucene/queries/function/TestBoostedQuery.java	(revision 1584870)
+++ lucene/queries/src/test/org/apache/lucene/queries/function/TestBoostedQuery.java	(working copy)
@@ -60,7 +60,7 @@
     iw.addDocument(document);
     ir = iw.getReader();
     is = newSearcher(ir);
-    iw.close();
+    iw.shutdown();
   }
   
   @AfterClass
Index: lucene/core/src/test/org/apache/lucene/TestDemo.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/TestDemo.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/TestDemo.java	(working copy)
@@ -53,7 +53,7 @@
     String text = "This is the text to be indexed. " + longTerm;
     doc.add(newTextField("fieldname", text, Field.Store.YES));
     iwriter.addDocument(doc);
-    iwriter.close();
+    iwriter.shutdown();
     
     // Now search the index:
     IndexReader ireader = DirectoryReader.open(directory); // read-only=true
Index: lucene/core/src/test/org/apache/lucene/search/TestDisjunctionMaxQuery.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestDisjunctionMaxQuery.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/TestDisjunctionMaxQuery.java	(working copy)
@@ -159,7 +159,7 @@
     }
     
     r = SlowCompositeReaderWrapper.wrap(writer.getReader());
-    writer.close();
+    writer.shutdown();
     s = newSearcher(r);
     s.setSimilarity(sim);
   }
@@ -488,7 +488,7 @@
     Document d = new Document();
     d.add(new TextField(FIELD, "clockwork orange", Field.Store.YES));
     writer.addDocument(d);
-    writer.close();
+    writer.shutdown();
 
     IndexReader indexReader = DirectoryReader.open(directory);
     IndexSearcher searcher = newSearcher(indexReader);
Index: lucene/core/src/test/org/apache/lucene/search/TestSearchAfter.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestSearchAfter.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/TestSearchAfter.java	(working copy)
@@ -165,7 +165,7 @@
       }
     }
     reader = iw.getReader();
-    iw.close();
+    iw.shutdown();
     searcher = newSearcher(reader);
     if (VERBOSE) {
       System.out.println("  searcher=" + searcher);
Index: lucene/core/src/test/org/apache/lucene/search/TestBooleanScorer.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestBooleanScorer.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/TestBooleanScorer.java	(working copy)
@@ -50,7 +50,7 @@
       writer.addDocument(doc);
     }
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
 
     BooleanQuery booleanQuery1 = new BooleanQuery();
     booleanQuery1.add(new TermQuery(new Term(FIELD, "1")), BooleanClause.Occur.SHOULD);
@@ -77,7 +77,7 @@
     RandomIndexWriter writer = new RandomIndexWriter(random(), directory);
     writer.commit();
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
     IndexSearcher searcher = newSearcher(ir);
     BooleanWeight weight = (BooleanWeight) new BooleanQuery().createWeight(searcher);
     BulkScorer[] scorers = new BulkScorer[] {new BulkScorer() {
@@ -137,7 +137,7 @@
     doc.add(new TextField("field", "33", Field.Store.NO));
     w.addDocument(doc);
     final IndexReader r = w.getReader();
-    w.close();
+    w.shutdown();
     // we don't wrap with AssertingIndexSearcher in order to have the original scorer in setScorer.
     final IndexSearcher s = newSearcher(r, true, false);
 
@@ -236,7 +236,7 @@
     doc.add(newTextField("field", "doctors are people who prescribe medicines of which they know little, to cure diseases of which they know less, in human beings of whom they know nothing", Field.Store.NO));
     w.addDocument(doc);
     IndexReader r = w.getReader();
-    w.close();
+    w.shutdown();
 
     IndexSearcher s = newSearcher(r);
     BooleanQuery q1 = new BooleanQuery();
Index: lucene/core/src/test/org/apache/lucene/search/TestAutomatonQuery.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestAutomatonQuery.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/TestAutomatonQuery.java	(working copy)
@@ -65,7 +65,7 @@
     writer.addDocument(doc);
     reader = writer.getReader();
     searcher = newSearcher(reader);
-    writer.close();
+    writer.shutdown();
   }
   
   @Override
Index: lucene/core/src/test/org/apache/lucene/search/TestCachingWrapperFilter.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestCachingWrapperFilter.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/TestCachingWrapperFilter.java	(working copy)
@@ -66,7 +66,8 @@
   
   @Override
   public void tearDown() throws Exception {
-    IOUtils.close(iw, ir, dir);
+    iw.shutdown();
+    IOUtils.close(ir, dir);
     super.tearDown();
   }
   
@@ -143,7 +144,7 @@
   public void testCachingWorks() throws Exception {
     Directory dir = newDirectory();
     RandomIndexWriter writer = new RandomIndexWriter(random(), dir);
-    writer.close();
+    writer.shutdown();
 
     IndexReader reader = SlowCompositeReaderWrapper.wrap(DirectoryReader.open(dir));
     AtomicReaderContext context = (AtomicReaderContext) reader.getContext();
@@ -169,7 +170,7 @@
   public void testNullDocIdSet() throws Exception {
     Directory dir = newDirectory();
     RandomIndexWriter writer = new RandomIndexWriter(random(), dir);
-    writer.close();
+    writer.shutdown();
 
     IndexReader reader = SlowCompositeReaderWrapper.wrap(DirectoryReader.open(dir));
     AtomicReaderContext context = (AtomicReaderContext) reader.getContext();
@@ -192,7 +193,7 @@
   public void testNullDocIdSetIterator() throws Exception {
     Directory dir = newDirectory();
     RandomIndexWriter writer = new RandomIndexWriter(random(), dir);
-    writer.close();
+    writer.shutdown();
 
     IndexReader reader = SlowCompositeReaderWrapper.wrap(DirectoryReader.open(dir));
     AtomicReaderContext context = (AtomicReaderContext) reader.getContext();
@@ -244,7 +245,7 @@
     Directory dir = newDirectory();
     RandomIndexWriter writer = new RandomIndexWriter(random(), dir);
     writer.addDocument(new Document());
-    writer.close();
+    writer.shutdown();
 
     IndexReader reader = SlowCompositeReaderWrapper.wrap(DirectoryReader.open(dir));
 
@@ -403,7 +404,7 @@
     assertTrue(oldReader != null);
 
     reader.close();
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
 
Index: lucene/core/src/test/org/apache/lucene/search/TestPrefixFilter.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestPrefixFilter.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/TestPrefixFilter.java	(working copy)
@@ -100,7 +100,7 @@
     hits = searcher.search(query, null, 1000).scoreDocs;
     assertEquals(0, hits.length);
     
-    writer.close();
+    writer.shutdown();
     reader.close();
     directory.close();
   }
Index: lucene/core/src/test/org/apache/lucene/search/TestBooleanQuery.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestBooleanQuery.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/TestBooleanQuery.java	(working copy)
@@ -138,7 +138,7 @@
     assertEquals(1, s.search(dmq, 10).totalHits);
     
     r.close();
-    w.close();
+    w.shutdown();
     dir.close();
   }
 
@@ -149,7 +149,7 @@
     doc1.add(newTextField("field", "foo bar", Field.Store.NO));
     iw1.addDocument(doc1);
     IndexReader reader1 = iw1.getReader();
-    iw1.close();
+    iw1.shutdown();
     
     Directory dir2 = newDirectory();
     RandomIndexWriter iw2 = new RandomIndexWriter(random(), dir2);
@@ -157,7 +157,7 @@
     doc2.add(newTextField("field", "foo baz", Field.Store.NO));
     iw2.addDocument(doc2);
     IndexReader reader2 = iw2.getReader();
-    iw2.close();
+    iw2.shutdown();
 
     BooleanQuery query = new BooleanQuery(); // Query: +foo -ba*
     query.add(new TermQuery(new Term("field", "foo")), BooleanClause.Occur.MUST);
@@ -212,7 +212,7 @@
     w.forceMerge(1);
     final IndexReader r = w.getReader();
     final IndexSearcher s = newSearcher(r);
-    w.close();
+    w.shutdown();
 
     for(int iter=0;iter<10*RANDOM_MULTIPLIER;iter++) {
       if (VERBOSE) {
@@ -304,7 +304,7 @@
     Document d = new Document();
     d.add(new TextField(FIELD, "clockwork orange", Field.Store.YES));
     writer.addDocument(d);
-    writer.close();
+    writer.shutdown();
 
     IndexReader indexReader = DirectoryReader.open(directory);
     IndexSearcher searcher = newSearcher(indexReader);
@@ -334,7 +334,7 @@
     doc.add(newTextField("field", "some text here", Field.Store.NO));
     w.addDocument(doc);
     IndexReader r = w.getReader();
-    w.close();
+    w.shutdown();
     IndexSearcher s = new IndexSearcher(r) {
         @Override
         protected void search(List<AtomicReaderContext> leaves, Weight weight, Collector collector) throws IOException {
Index: lucene/core/src/test/org/apache/lucene/search/TestTotalHitCountCollector.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestTotalHitCountCollector.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/TestTotalHitCountCollector.java	(working copy)
@@ -37,7 +37,7 @@
       writer.addDocument(doc);
     }
     IndexReader reader = writer.getReader();
-    writer.close();
+    writer.shutdown();
 
     IndexSearcher searcher = newSearcher(reader);
     TotalHitCountCollector c = new TotalHitCountCollector();
Index: lucene/core/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java	(working copy)
@@ -123,7 +123,7 @@
   
     reader = writer.getReader();
     searcher=newSearcher(reader);
-    writer.close();
+    writer.shutdown();
   }
   
   @AfterClass
@@ -322,7 +322,7 @@
       writer.addDocument(doc);
     }
     
-    writer.close();
+    writer.shutdown();
     
     IndexReader r = DirectoryReader.open(dir);
     IndexSearcher s = newSearcher(r);
Index: lucene/core/src/test/org/apache/lucene/search/TestScorerPerf.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestScorerPerf.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/TestScorerPerf.java	(working copy)
@@ -51,7 +51,7 @@
     d = newDirectory();
     IndexWriter iw = new IndexWriter(d, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random())));
     iw.addDocument(new Document());
-    iw.close();
+    iw.shutdown();
     r = DirectoryReader.open(d);
     s = newSearcher(r);
   }
@@ -77,7 +77,7 @@
       iw.addDocument(d);
     }
     iw.forceMerge(1);
-    iw.close();
+    iw.shutdown();
   }
 
 
Index: lucene/core/src/test/org/apache/lucene/search/TestFuzzyQuery.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestFuzzyQuery.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/TestFuzzyQuery.java	(working copy)
@@ -51,7 +51,7 @@
 
     IndexReader reader = writer.getReader();
     IndexSearcher searcher = newSearcher(reader);
-    writer.close();
+    writer.shutdown();
 
     FuzzyQuery query = new FuzzyQuery(new Term("field", "aaaaa"), FuzzyQuery.defaultMaxEdits, 0);   
     ScoreDoc[] hits = searcher.search(query, null, 1000).scoreDocs;
@@ -214,7 +214,7 @@
 
     IndexReader reader = writer.getReader();
     IndexSearcher searcher = newSearcher(reader);
-    writer.close();
+    writer.shutdown();
 
     FuzzyQuery query = new FuzzyQuery(new Term("field", "WEBER"), 2, 1);
     //query.setRewriteMethod(FuzzyQuery.SCORING_BOOLEAN_QUERY_REWRITE);
@@ -260,8 +260,8 @@
     mr.close();
     ir1.close();
     ir2.close();
-    writer.close();
-    writer2.close();
+    writer.shutdown();
+    writer2.shutdown();
     directory.close();
     directory2.close(); 
   }
@@ -276,7 +276,7 @@
 
     IndexReader reader = writer.getReader();
     IndexSearcher searcher = newSearcher(reader);
-    writer.close();
+    writer.shutdown();
     
     FuzzyQuery query = new FuzzyQuery(new Term("field", "lucene"));
     query.setRewriteMethod(new MultiTermQuery.TopTermsBoostOnlyBooleanQueryRewrite(50));
@@ -314,7 +314,7 @@
     addDoc("Brute willis", w);
     addDoc("B. willis", w);
     IndexReader r = w.getReader();
-    w.close();
+    w.shutdown();
 
     Query q = new FuzzyQuery(new Term("field", "giga"), 0);
 
@@ -335,7 +335,7 @@
     addDoc("working", w);
     IndexReader reader = w.getReader();
     IndexSearcher searcher = newSearcher(reader);
-    w.close();
+    w.shutdown();
     
     FuzzyQuery q = new FuzzyQuery(new Term("field", "fouba"), 2);
     ScoreDoc[] hits = searcher.search(q, 10).scoreDocs;
Index: lucene/core/src/test/org/apache/lucene/search/similarities/TestSimilarity2.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/similarities/TestSimilarity2.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/similarities/TestSimilarity2.java	(working copy)
@@ -78,7 +78,7 @@
     Directory dir = newDirectory();
     RandomIndexWriter iw = new RandomIndexWriter(random(), dir);
     IndexReader ir = iw.getReader();
-    iw.close();
+    iw.shutdown();
     IndexSearcher is = newSearcher(ir);
     
     for (Similarity sim : sims) {
@@ -97,7 +97,7 @@
     doc.add(newTextField("foo", "bar", Field.Store.NO));
     iw.addDocument(doc);
     IndexReader ir = iw.getReader();
-    iw.close();
+    iw.shutdown();
     IndexSearcher is = newSearcher(ir);
     
     for (Similarity sim : sims) {
@@ -119,7 +119,7 @@
     doc.add(newTextField("foo", "bar", Field.Store.NO));
     iw.addDocument(doc);
     IndexReader ir = iw.getReader();
-    iw.close();
+    iw.shutdown();
     IndexSearcher is = newSearcher(ir);
     
     for (Similarity sim : sims) {
@@ -144,7 +144,7 @@
     doc.add(newField("foo", "bar", ft));
     iw.addDocument(doc);
     IndexReader ir = iw.getReader();
-    iw.close();
+    iw.shutdown();
     IndexSearcher is = newSearcher(ir);
     
     for (Similarity sim : sims) {
@@ -169,7 +169,7 @@
     doc.add(f);
     iw.addDocument(doc);
     IndexReader ir = iw.getReader();
-    iw.close();
+    iw.shutdown();
     IndexSearcher is = newSearcher(ir);
     
     for (Similarity sim : sims) {
@@ -195,7 +195,7 @@
     doc.add(f);
     iw.addDocument(doc);
     IndexReader ir = iw.getReader();
-    iw.close();
+    iw.shutdown();
     IndexSearcher is = newSearcher(ir);
     
     for (Similarity sim : sims) {
@@ -221,7 +221,7 @@
     doc.add(newField("foo", "bar", ft));
     iw.addDocument(doc);
     IndexReader ir = iw.getReader();
-    iw.close();
+    iw.shutdown();
     IndexSearcher is = newSearcher(ir);
     
     for (Similarity sim : sims) {
Index: lucene/core/src/test/org/apache/lucene/search/similarities/TestSimilarityBase.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/similarities/TestSimilarityBase.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/similarities/TestSimilarityBase.java	(working copy)
@@ -119,7 +119,7 @@
     
     reader = writer.getReader();
     searcher = newSearcher(reader);
-    writer.close();
+    writer.shutdown();
     
     sims = new ArrayList<>();
     for (BasicModel basicModel : BASIC_MODELS) {
Index: lucene/core/src/test/org/apache/lucene/search/TestMultiThreadTermVectors.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestMultiThreadTermVectors.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/TestMultiThreadTermVectors.java	(working copy)
@@ -52,7 +52,7 @@
       doc.add(fld);
       writer.addDocument(doc);
     }
-    writer.close();
+    writer.shutdown();
     
   }
   
Index: lucene/core/src/test/org/apache/lucene/search/TestLiveFieldValues.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestLiveFieldValues.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/TestLiveFieldValues.java	(working copy)
@@ -170,7 +170,7 @@
 
     rt.close();
     mgr.close();
-    w.close();
+    w.shutdown();
     dir.close();
   }
 }
Index: lucene/core/src/test/org/apache/lucene/search/TestPrefixQuery.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestPrefixQuery.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/TestPrefixQuery.java	(working copy)
@@ -60,7 +60,7 @@
     assertFalse(query.getTermsEnum(terms) instanceof PrefixTermsEnum);
     hits = searcher.search(query, null, 1000).scoreDocs;
     assertEquals("everything", 3, hits.length);
-    writer.close();
+    writer.shutdown();
     reader.close();
     directory.close();
   }
Index: lucene/core/src/test/org/apache/lucene/search/TestDateFilter.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestDateFilter.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/TestDateFilter.java	(working copy)
@@ -52,7 +52,7 @@
     writer.addDocument(doc);
     
     IndexReader reader = writer.getReader();
-    writer.close();
+    writer.shutdown();
     IndexSearcher searcher = newSearcher(reader);
     
     // filter that should preserve matches
@@ -115,7 +115,7 @@
     writer.addDocument(doc);
     
     IndexReader reader = writer.getReader();
-    writer.close();
+    writer.shutdown();
     IndexSearcher searcher = newSearcher(reader);
     
     // filter that should preserve matches
Index: lucene/core/src/test/org/apache/lucene/search/TestIndexSearcher.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestIndexSearcher.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/TestIndexSearcher.java	(working copy)
@@ -51,7 +51,7 @@
       iw.addDocument(doc);
     }
     reader = iw.getReader();
-    iw.close();
+    iw.shutdown();
   }
   
   @Override
@@ -126,7 +126,7 @@
     RandomIndexWriter w = new RandomIndexWriter(random(), dir);
     w.addDocument(new Document());
     IndexReader r = w.getReader();
-    w.close();
+    w.shutdown();
     
     IndexSearcher s = new IndexSearcher(r);
     try {
Index: lucene/core/src/test/org/apache/lucene/search/TestFilteredSearch.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestFilteredSearch.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/TestFilteredSearch.java	(working copy)
@@ -51,11 +51,9 @@
     searchFiltered(writer, directory, filter, enforceSingleSegment);
     // run the test on more than one segment
     enforceSingleSegment = false;
-    writer.close();
     writer = new IndexWriter(directory, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random())).setOpenMode(OpenMode.CREATE).setMaxBufferedDocs(10).setMergePolicy(newLogMergePolicy()));
     // we index 60 docs - this will create 6 segments
     searchFiltered(writer, directory, filter, enforceSingleSegment);
-    writer.close();
     directory.close();
   }
 
@@ -68,7 +66,7 @@
     if (fullMerge) {
       writer.forceMerge(1);
     }
-    writer.close();
+    writer.shutdown();
 
     BooleanQuery booleanQuery = new BooleanQuery();
     booleanQuery.add(new TermQuery(new Term(FIELD, "36")), BooleanClause.Occur.SHOULD);
Index: lucene/core/src/test/org/apache/lucene/search/TestDateSort.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestDateSort.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/TestDateSort.java	(working copy)
@@ -63,7 +63,7 @@
     writer.addDocument(createDocument("Document 5", 1192209943000L));
 
     reader = writer.getReader();
-    writer.close();
+    writer.shutdown();
   }
 
   @Override
Index: lucene/core/src/test/org/apache/lucene/search/TestSimilarity.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestSimilarity.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/TestSimilarity.java	(working copy)
@@ -67,7 +67,7 @@
     writer.addDocument(d1);
     writer.addDocument(d2);
     IndexReader reader = writer.getReader();
-    writer.close();
+    writer.shutdown();
 
     IndexSearcher searcher = newSearcher(reader);
     searcher.setSimilarity(new SimpleSimilarity());
Index: lucene/core/src/test/org/apache/lucene/search/TestPhrasePrefixQuery.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestPhrasePrefixQuery.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/TestPhrasePrefixQuery.java	(working copy)
@@ -58,7 +58,7 @@
     writer.addDocument(doc4);
     writer.addDocument(doc5);
     IndexReader reader = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     IndexSearcher searcher = newSearcher(reader);
     
Index: lucene/core/src/test/org/apache/lucene/search/TestEarlyTermination.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestEarlyTermination.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/TestEarlyTermination.java	(working copy)
@@ -48,7 +48,7 @@
   @Override
   public void tearDown() throws Exception {
     super.tearDown();
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
 
Index: lucene/core/src/test/org/apache/lucene/search/TestSort.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestSort.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/TestSort.java	(working copy)
@@ -72,7 +72,7 @@
     doc.add(newStringField("value", "bar", Field.Store.YES));
     writer.addDocument(doc);
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     Sort sort = new Sort(new SortField("value", SortField.Type.STRING));
@@ -100,7 +100,7 @@
     doc.add(newStringField("value", "bar", Field.Store.YES));
     writer.addDocument(doc);
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     Sort sort = new Sort(new SortField("value", SortField.Type.STRING));
@@ -127,7 +127,7 @@
     doc.add(newStringField("value", "foo", Field.Store.YES));
     writer.addDocument(doc);
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     Sort sort = new Sort(new SortField("value", SortField.Type.STRING, true));
@@ -153,7 +153,7 @@
     doc.add(newStringField("value", "bar", Field.Store.YES));
     writer.addDocument(doc);
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     Sort sort = new Sort(new SortField("value", SortField.Type.STRING_VAL));
@@ -181,7 +181,7 @@
     doc.add(newStringField("value", "bar", Field.Store.YES));
     writer.addDocument(doc);
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     Sort sort = new Sort(new SortField("value", SortField.Type.STRING_VAL));
@@ -211,7 +211,7 @@
     doc.add(newStringField("value", "bar", Field.Store.YES));
     writer.addDocument(doc);
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     SortField sf = new SortField("value", SortField.Type.STRING);
@@ -242,7 +242,7 @@
     doc.add(newStringField("value", "bar", Field.Store.YES));
     writer.addDocument(doc);
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     SortField sf = new SortField("value", SortField.Type.STRING, true);
@@ -273,7 +273,7 @@
     doc.add(newStringField("value", "bar", Field.Store.YES));
     writer.addDocument(doc);
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     SortField sf = new SortField("value", SortField.Type.STRING);
@@ -305,7 +305,7 @@
     doc.add(newStringField("value", "bar", Field.Store.YES));
     writer.addDocument(doc);
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     SortField sf = new SortField("value", SortField.Type.STRING, true);
@@ -334,7 +334,7 @@
     doc.add(newStringField("value", "foo", Field.Store.YES));
     writer.addDocument(doc);
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     Sort sort = new Sort(new SortField("value", SortField.Type.STRING_VAL, true));
@@ -360,7 +360,7 @@
     doc.add(newStringField("value", "bar", Field.Store.NO));
     writer.addDocument(doc);
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     Sort sort = new Sort(SortField.FIELD_DOC);
@@ -386,7 +386,7 @@
     doc.add(newStringField("value", "bar", Field.Store.NO));
     writer.addDocument(doc);
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     Sort sort = new Sort(new SortField(null, SortField.Type.DOC, true));
@@ -412,7 +412,7 @@
     doc.add(newTextField("value", "foo foo foo foo foo", Field.Store.NO));
     writer.addDocument(doc);
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     Sort sort = new Sort();
@@ -442,7 +442,7 @@
     doc.add(newTextField("value", "foo foo foo foo foo", Field.Store.NO));
     writer.addDocument(doc);
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     Sort sort = new Sort(new SortField(null, SortField.Type.SCORE, true));
@@ -474,7 +474,7 @@
     doc.add(new IntField("value", 4, Field.Store.YES));
     writer.addDocument(doc);
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     Sort sort = new Sort(new SortField("value", SortField.Type.INT));
@@ -503,7 +503,7 @@
     doc.add(new IntField("value", 4, Field.Store.YES));
     writer.addDocument(doc);
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     Sort sort = new Sort(new SortField("value", SortField.Type.INT));
@@ -532,7 +532,7 @@
     doc.add(new IntField("value", 4, Field.Store.YES));
     writer.addDocument(doc);
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     SortField sortField = new SortField("value", SortField.Type.INT);
@@ -564,7 +564,7 @@
     doc.add(new IntField("value", 4, Field.Store.YES));
     writer.addDocument(doc);
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     Sort sort = new Sort(new SortField("value", SortField.Type.INT, true));
@@ -594,7 +594,7 @@
     doc.add(new LongField("value", 4, Field.Store.YES));
     writer.addDocument(doc);
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     Sort sort = new Sort(new SortField("value", SortField.Type.LONG));
@@ -623,7 +623,7 @@
     doc.add(new LongField("value", 4, Field.Store.YES));
     writer.addDocument(doc);
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     Sort sort = new Sort(new SortField("value", SortField.Type.LONG));
@@ -652,7 +652,7 @@
     doc.add(new LongField("value", 4, Field.Store.YES));
     writer.addDocument(doc);
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     SortField sortField = new SortField("value", SortField.Type.LONG);
@@ -684,7 +684,7 @@
     doc.add(new LongField("value", 4, Field.Store.YES));
     writer.addDocument(doc);
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     Sort sort = new Sort(new SortField("value", SortField.Type.LONG, true));
@@ -714,7 +714,7 @@
     doc.add(new FloatField("value", 4.2f, Field.Store.YES));
     writer.addDocument(doc);
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     Sort sort = new Sort(new SortField("value", SortField.Type.FLOAT));
@@ -743,7 +743,7 @@
     doc.add(new FloatField("value", 4.2f, Field.Store.YES));
     writer.addDocument(doc);
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     Sort sort = new Sort(new SortField("value", SortField.Type.FLOAT));
@@ -772,7 +772,7 @@
     doc.add(new FloatField("value", 4.2f, Field.Store.YES));
     writer.addDocument(doc);
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     SortField sortField = new SortField("value", SortField.Type.FLOAT);
@@ -804,7 +804,7 @@
     doc.add(new FloatField("value", 4.2f, Field.Store.YES));
     writer.addDocument(doc);
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     Sort sort = new Sort(new SortField("value", SortField.Type.FLOAT, true));
@@ -837,7 +837,7 @@
     doc.add(new DoubleField("value", 4.2333333333332, Field.Store.YES));
     writer.addDocument(doc);
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     Sort sort = new Sort(new SortField("value", SortField.Type.DOUBLE));
@@ -866,7 +866,7 @@
     writer.addDocument(doc);
     doc = new Document();
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     Sort sort = new Sort(new SortField("value", SortField.Type.DOUBLE));
@@ -902,7 +902,7 @@
     doc.add(new DoubleField("value", 4.2333333333332, Field.Store.YES));
     writer.addDocument(doc);
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     Sort sort = new Sort(new SortField("value", SortField.Type.DOUBLE));
@@ -935,7 +935,7 @@
     doc.add(new DoubleField("value", 4.2333333333332, Field.Store.YES));
     writer.addDocument(doc);
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     SortField sortField = new SortField("value", SortField.Type.DOUBLE);
@@ -971,7 +971,7 @@
     doc.add(new DoubleField("value", 4.2333333333332, Field.Store.YES));
     writer.addDocument(doc);
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     Sort sort = new Sort(new SortField("value", SortField.Type.DOUBLE, true));
@@ -1002,7 +1002,7 @@
     w.addDocument(doc);
 
     IndexReader r = DirectoryReader.open(w, true);
-    w.close();
+    w.shutdown();
     IndexSearcher s = newSearcher(r);
     TopDocs hits = s.search(new TermQuery(new Term("t", "1")), null, 10, new Sort(new SortField("f", SortField.Type.STRING)));
     assertEquals(2, hits.totalHits);
@@ -1025,7 +1025,7 @@
         writer.addDocument(doc);
     }
     writer.forceMerge(1); // enforce one segment to have a higher unique term count in all cases
-    writer.close();
+    writer.shutdown();
     Sort sort = new Sort(
         new SortField("string", SortField.Type.STRING),
         SortField.FIELD_DOC);
@@ -1059,7 +1059,7 @@
     }
 
     IndexReader r = DirectoryReader.open(w, true);
-    w.close();
+    w.shutdown();
     Query q = new TermQuery(new Term("body", "text"));
     IndexSearcher s = newSearcher(r);
     float maxScore = s.search(q , 10).getMaxScore();
@@ -1117,7 +1117,7 @@
     }
     
     IndexReader ir = iw.getReader();
-    iw.close();
+    iw.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     Sort sort = new Sort(new SortField("parser", new FieldCache.IntParser() {
@@ -1161,7 +1161,7 @@
     }
     
     IndexReader ir = iw.getReader();
-    iw.close();
+    iw.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     Sort sort = new Sort(new SortField("parser", new FieldCache.LongParser() {
@@ -1205,7 +1205,7 @@
     }
     
     IndexReader ir = iw.getReader();
-    iw.close();
+    iw.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     Sort sort = new Sort(new SortField("parser", new FieldCache.FloatParser() {
@@ -1249,7 +1249,7 @@
     }
     
     IndexReader ir = iw.getReader();
-    iw.close();
+    iw.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     Sort sort = new Sort(new SortField("parser", new FieldCache.DoubleParser() {
@@ -1285,7 +1285,7 @@
     doc.add(newStringField("value", "foo", Field.Store.YES));
     writer.addDocument(doc);
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     Sort sort = new Sort(new SortField("value", SortField.Type.STRING));
@@ -1306,7 +1306,7 @@
     doc.add(newStringField("value", "foo", Field.Store.YES));
     writer.addDocument(doc);
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     Sort sort = new Sort(new SortField("value", SortField.Type.STRING));
@@ -1335,7 +1335,7 @@
     doc.add(newStringField("value", "bar", Field.Store.YES));
     writer.addDocument(doc);
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     // tievalue, then value
@@ -1362,7 +1362,7 @@
     doc.add(newStringField("value", "foo", Field.Store.NO));
     writer.addDocument(doc);
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
 
     IndexSearcher searcher = newSearcher(ir);
     Sort sort = new Sort(SortField.FIELD_SCORE);
Index: lucene/core/src/test/org/apache/lucene/search/TestControlledRealTimeReopenThread.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestControlledRealTimeReopenThread.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/TestControlledRealTimeReopenThread.java	(working copy)
@@ -371,7 +371,8 @@
     }
     thread.close();
     thread.join();
-    IOUtils.close(manager, _writer, d);
+    _writer.shutdown();
+    IOUtils.close(manager, d);
   }
   
   public static class LatchedIndexWriter extends IndexWriter {
@@ -425,7 +426,7 @@
     } catch (IllegalStateException ise) {
       // expected
     }
-    w.close();
+    w.shutdown();
     other.close();
     dir.close();
   }
@@ -452,7 +453,7 @@
     sm.maybeRefreshBlocking();
     assertTrue(afterRefreshCalled.get());
     sm.close();
-    iw.close();
+    iw.shutdown();
     dir.close();
   }
 
@@ -531,7 +532,7 @@
 
     controlledRealTimeReopenThread.close();
     sm.close();
-    iw.close();
+    iw.shutdown();
     dir.close();
   }
 }
Index: lucene/core/src/test/org/apache/lucene/search/TestSortRescorer.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestSortRescorer.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/TestSortRescorer.java	(working copy)
@@ -63,7 +63,7 @@
     
     reader = iw.getReader();
     searcher = new IndexSearcher(reader);
-    iw.close();
+    iw.shutdown();
   }
   
   @Override
@@ -129,7 +129,7 @@
       w.addDocument(doc);
     }
     final IndexReader r = w.getReader();
-    w.close();
+    w.shutdown();
 
     IndexSearcher s = newSearcher(r);
     int numHits = TestUtil.nextInt(random(), 1, numDocs);
Index: lucene/core/src/test/org/apache/lucene/search/TestNGramPhraseQuery.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestNGramPhraseQuery.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/TestNGramPhraseQuery.java	(working copy)
@@ -35,7 +35,7 @@
   public static void beforeClass() throws Exception {
     directory = newDirectory();
     RandomIndexWriter writer = new RandomIndexWriter(random(), directory);
-    writer.close();
+    writer.shutdown();
     reader = DirectoryReader.open(directory);
   }
 
Index: lucene/core/src/test/org/apache/lucene/search/TestDocIdSet.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestDocIdSet.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/TestDocIdSet.java	(working copy)
@@ -110,7 +110,7 @@
     doc.add(newStringField("c", "val", Field.Store.NO));
     writer.addDocument(doc);
     IndexReader reader = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     // First verify the document is searchable.
     IndexSearcher searcher = newSearcher(reader);
@@ -136,7 +136,7 @@
     doc.add(newStringField("c", "val", Field.Store.NO));
     writer.addDocument(doc);
     IndexReader reader = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     // First verify the document is searchable.
     IndexSearcher searcher = newSearcher(reader);
Index: lucene/core/src/test/org/apache/lucene/search/TestCustomSearcherSort.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestCustomSearcherSort.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/TestCustomSearcherSort.java	(working copy)
@@ -68,7 +68,7 @@
       writer.addDocument(doc);
     }
     reader = writer.getReader();
-    writer.close();
+    writer.shutdown();
     query = new TermQuery(new Term("content", "test"));
   }
   
Index: lucene/core/src/test/org/apache/lucene/search/TestNot.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestNot.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/TestNot.java	(working copy)
@@ -50,7 +50,7 @@
 
     ScoreDoc[] hits = searcher.search(query, null, 1000).scoreDocs;
     assertEquals(0, hits.length);
-    writer.close();
+    writer.shutdown();
     reader.close();
     store.close();
   }
Index: lucene/core/src/test/org/apache/lucene/search/TestSimilarityProvider.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestSimilarityProvider.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/TestSimilarityProvider.java	(working copy)
@@ -61,7 +61,7 @@
     field2.setStringValue("jumps over lazy brown dog");
     iw.addDocument(doc);
     reader = iw.getReader();
-    iw.close();
+    iw.shutdown();
     searcher = newSearcher(reader);
     searcher.setSimilarity(sim);
   }
Index: lucene/core/src/test/org/apache/lucene/search/TestMinShouldMatch2.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestMinShouldMatch2.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/TestMinShouldMatch2.java	(working copy)
@@ -82,7 +82,7 @@
       iw.addDocument(doc);
     }
     iw.forceMerge(1);
-    iw.close();
+    iw.shutdown();
     r = DirectoryReader.open(dir);
     reader = getOnlySegmentReader(r);
     searcher = new IndexSearcher(reader);
Index: lucene/core/src/test/org/apache/lucene/search/TestPhraseQuery.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestPhraseQuery.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/TestPhraseQuery.java	(working copy)
@@ -79,7 +79,7 @@
     writer.addDocument(doc);
 
     reader = writer.getReader();
-    writer.close();
+    writer.shutdown();
 
     searcher = newSearcher(reader);
   }
@@ -220,7 +220,7 @@
     doc.add(newTextField("field", "the stop words are here", Field.Store.YES));
     writer.addDocument(doc);
     IndexReader reader = writer.getReader();
-    writer.close();
+    writer.shutdown();
 
     IndexSearcher searcher = newSearcher(reader);
 
@@ -250,7 +250,7 @@
     writer.addDocument(doc);
     
     IndexReader reader = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     IndexSearcher searcher = newSearcher(reader);
     
@@ -288,7 +288,7 @@
     writer.addDocument(doc);
 
     reader = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     searcher = newSearcher(reader);
     
@@ -341,7 +341,7 @@
     writer.addDocument(doc3);
     
     IndexReader reader = writer.getReader();
-    writer.close();
+    writer.shutdown();
 
     IndexSearcher searcher = newSearcher(reader);
     searcher.setSimilarity(new DefaultSimilarity());
@@ -644,7 +644,7 @@
 
     IndexReader reader = w.getReader();
     IndexSearcher s = newSearcher(reader);
-    w.close();
+    w.shutdown();
 
     // now search
     int num = atLeast(10);
Index: lucene/core/src/test/org/apache/lucene/search/TestMultiValuedNumericRangeQuery.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestMultiValuedNumericRangeQuery.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/TestMultiValuedNumericRangeQuery.java	(working copy)
@@ -58,7 +58,7 @@
       writer.addDocument(doc);
     }
     IndexReader reader = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     IndexSearcher searcher=newSearcher(reader);
     num = atLeast(50);
Index: lucene/core/src/test/org/apache/lucene/search/TestFieldValueFilter.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestFieldValueFilter.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/TestFieldValueFilter.java	(working copy)
@@ -108,7 +108,7 @@
       writer.deleteDocuments(new Term("id", "" + docID));
       docStates[docID] = 2;
     }
-    writer.close();
+    writer.shutdown();
     return docStates;
   }
 
Index: lucene/core/src/test/org/apache/lucene/search/TestSortRandom.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestSortRandom.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/TestSortRandom.java	(working copy)
@@ -41,7 +41,6 @@
 import org.apache.lucene.util.FixedBitSet;
 import org.apache.lucene.util.LuceneTestCase;
 import org.apache.lucene.util.TestUtil;
-import org.apache.lucene.util.TestUtil;
 
 /** random sorting tests */
 public class TestSortRandom extends LuceneTestCase {
@@ -111,7 +110,7 @@
     }
 
     final IndexReader r = writer.getReader();
-    writer.close();
+    writer.shutdown();
     if (VERBOSE) {
       System.out.println("  reader=" + r);
     }
Index: lucene/core/src/test/org/apache/lucene/search/TestWildcard.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestWildcard.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/TestWildcard.java	(working copy)
@@ -253,7 +253,7 @@
       doc.add(newTextField(field, contents[i], Field.Store.YES));
       writer.addDocument(doc);
     }
-    writer.close();
+    writer.shutdown();
 
     return indexStore;
   }
@@ -352,7 +352,7 @@
       doc.add(newTextField(field, docs[i], Field.Store.NO));
       iw.addDocument(doc);
     }
-    iw.close();
+    iw.shutdown();
     
     IndexReader reader = DirectoryReader.open(dir);
     IndexSearcher searcher = newSearcher(reader);
Index: lucene/core/src/test/org/apache/lucene/search/payloads/TestPayloadNearQuery.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/payloads/TestPayloadNearQuery.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/payloads/TestPayloadNearQuery.java	(working copy)
@@ -118,7 +118,7 @@
       writer.addDocument(doc);
     }
     reader = writer.getReader();
-    writer.close();
+    writer.shutdown();
 
     searcher = newSearcher(reader);
     searcher.setSimilarity(similarity);
Index: lucene/core/src/test/org/apache/lucene/search/payloads/TestPayloadTermQuery.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/payloads/TestPayloadTermQuery.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/payloads/TestPayloadTermQuery.java	(working copy)
@@ -130,7 +130,7 @@
       writer.addDocument(doc);
     }
     reader = writer.getReader();
-    writer.close();
+    writer.shutdown();
 
     searcher = newSearcher(reader);
     searcher.setSimilarity(similarity);
Index: lucene/core/src/test/org/apache/lucene/search/payloads/PayloadHelper.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/payloads/PayloadHelper.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/payloads/PayloadHelper.java	(working copy)
@@ -131,7 +131,7 @@
       writer.addDocument(doc);
     }
     reader = DirectoryReader.open(writer, true);
-    writer.close();
+    writer.shutdown();
 
     IndexSearcher searcher = LuceneTestCase.newSearcher(reader);
     searcher.setSimilarity(similarity);
Index: lucene/core/src/test/org/apache/lucene/search/TestBoolean2.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestBoolean2.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/TestBoolean2.java	(working copy)
@@ -64,7 +64,7 @@
       doc.add(newTextField(field, docFields[i], Field.Store.NO));
       writer.addDocument(doc);
     }
-    writer.close();
+    writer.shutdown();
     littleReader = DirectoryReader.open(directory);
     searcher = newSearcher(littleReader);
     // this is intentionally using the baseline sim, because it compares against bigSearcher (which uses a random one)
@@ -87,7 +87,7 @@
       RandomIndexWriter w = new RandomIndexWriter(random(), dir2);
       w.addIndexes(copy);
       docCount = w.maxDoc();
-      w.close();
+      w.shutdown();
       mulFactor *= 2;
     } while(docCount < 3000);
 
@@ -106,7 +106,7 @@
     }
     reader = w.getReader();
     bigSearcher = newSearcher(reader);
-    w.close();
+    w.shutdown();
   }
 
   @AfterClass
Index: lucene/core/src/test/org/apache/lucene/search/TestTermRangeQuery.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestTermRangeQuery.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/TestTermRangeQuery.java	(working copy)
@@ -249,14 +249,14 @@
     for (int i = 0; i < values.length; i++) {
       insertDoc(writer, values[i]);
     }
-    writer.close();
+    writer.shutdown();
   }
 
   // shouldnt create an analyzer for every doc?
   private void addDoc(String content) throws IOException {
     IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random(), MockTokenizer.WHITESPACE, false)).setOpenMode(OpenMode.APPEND));
     insertDoc(writer, content);
-    writer.close();
+    writer.shutdown();
   }
 
   private void insertDoc(IndexWriter writer, String content) throws IOException {
Index: lucene/core/src/test/org/apache/lucene/search/TestMultiTermConstantScore.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestMultiTermConstantScore.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/TestMultiTermConstantScore.java	(working copy)
@@ -73,7 +73,7 @@
     }
 
     reader = writer.getReader();
-    writer.close();
+    writer.shutdown();
   }
 
   @AfterClass
Index: lucene/core/src/test/org/apache/lucene/search/TestDocTermOrdsRewriteMethod.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestDocTermOrdsRewriteMethod.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/TestDocTermOrdsRewriteMethod.java	(working copy)
@@ -91,7 +91,7 @@
     reader = writer.getReader();
     searcher1 = newSearcher(reader);
     searcher2 = newSearcher(reader);
-    writer.close();
+    writer.shutdown();
   }
   
   @Override
Index: lucene/core/src/test/org/apache/lucene/search/TestFieldCacheTermsFilter.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestFieldCacheTermsFilter.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/TestFieldCacheTermsFilter.java	(working copy)
@@ -45,7 +45,7 @@
       w.addDocument(doc);
     }
     IndexReader reader = w.getReader();
-    w.close();
+    w.shutdown();
 
     IndexSearcher searcher = newSearcher(reader);
     int numDocs = reader.numDocs();
Index: lucene/core/src/test/org/apache/lucene/search/TestRegexpRandom.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestRegexpRandom.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/TestRegexpRandom.java	(working copy)
@@ -65,7 +65,7 @@
     }
     
     reader = writer.getReader();
-    writer.close();
+    writer.shutdown();
     searcher = newSearcher(reader);
   }
   
Index: lucene/core/src/test/org/apache/lucene/search/TestTopScoreDocCollector.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestTopScoreDocCollector.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/TestTopScoreDocCollector.java	(working copy)
@@ -60,7 +60,7 @@
         assertEquals("expected doc Id " + j + " found " + sd[j].doc, j, sd[j].doc);
       }
     }
-    writer.close();
+    writer.shutdown();
     reader.close();
     dir.close();
   }
Index: lucene/core/src/test/org/apache/lucene/search/TestPrefixRandom.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestPrefixRandom.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/TestPrefixRandom.java	(working copy)
@@ -65,7 +65,7 @@
     }
     reader = writer.getReader();
     searcher = newSearcher(reader);
-    writer.close();
+    writer.shutdown();
   }
 
   @Override
Index: lucene/core/src/test/org/apache/lucene/search/TestBooleanQueryVisitSubscorers.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestBooleanQueryVisitSubscorers.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/TestBooleanQueryVisitSubscorers.java	(working copy)
@@ -60,7 +60,7 @@
     writer.addDocument(doc("solr", "solr is a very popular search server and is using lucene"));
     writer.addDocument(doc("nutch", "nutch is an internet search engine with web crawler and is using lucene and hadoop"));
     reader = writer.getReader();
-    writer.close();
+    writer.shutdown();
     searcher = newSearcher(reader);
   }
   
Index: lucene/core/src/test/org/apache/lucene/search/TestTimeLimitingCollector.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestTimeLimitingCollector.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/TestTimeLimitingCollector.java	(working copy)
@@ -86,7 +86,7 @@
       add(docText[i%docText.length], iw);
     }
     reader = iw.getReader();
-    iw.close();
+    iw.shutdown();
     searcher = newSearcher(reader);
 
     BooleanQuery booleanQuery = new BooleanQuery();
Index: lucene/core/src/test/org/apache/lucene/search/TestAutomatonQueryUnicode.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestAutomatonQueryUnicode.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/TestAutomatonQueryUnicode.java	(working copy)
@@ -80,7 +80,7 @@
     writer.addDocument(doc);
     reader = writer.getReader();
     searcher = newSearcher(reader);
-    writer.close();
+    writer.shutdown();
   }
 
   @Override
Index: lucene/core/src/test/org/apache/lucene/search/TestSubScorerFreqs.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestSubScorerFreqs.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/TestSubScorerFreqs.java	(working copy)
@@ -54,7 +54,7 @@
     }
 
     s = newSearcher(w.getReader());
-    w.close();
+    w.shutdown();
   }
 
   @AfterClass
Index: lucene/core/src/test/org/apache/lucene/search/TestPositionIncrement.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestPositionIncrement.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/TestPositionIncrement.java	(working copy)
@@ -96,7 +96,7 @@
     d.add(newTextField("field", "bogus", Field.Store.YES));
     writer.addDocument(d);
     IndexReader reader = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
 
     IndexSearcher searcher = newSearcher(reader);
@@ -283,7 +283,7 @@
     }
     assertEquals(5, count);
     assertTrue(sawZero);
-    writer.close();
+    writer.shutdown();
     is.getIndexReader().close();
     dir.close();
   }
Index: lucene/core/src/test/org/apache/lucene/search/TestQueryRescorer.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestQueryRescorer.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/TestQueryRescorer.java	(working copy)
@@ -64,7 +64,7 @@
     doc.add(newTextField("field", "wizard oz the the the the the the", Field.Store.NO));
     w.addDocument(doc);
     IndexReader r = w.getReader();
-    w.close();
+    w.shutdown();
 
     // Do ordinary BooleanQuery:
     BooleanQuery bq = new BooleanQuery();
@@ -121,7 +121,7 @@
     doc.add(newTextField("field", "wizard oz the the the the the the", Field.Store.NO));
     w.addDocument(doc);
     IndexReader r = w.getReader();
-    w.close();
+    w.shutdown();
 
     // Do ordinary BooleanQuery:
     BooleanQuery bq = new BooleanQuery();
@@ -175,7 +175,7 @@
     doc.add(newTextField("field", "wizard oz the the the the the the", Field.Store.NO));
     w.addDocument(doc);
     IndexReader r = w.getReader();
-    w.close();
+    w.shutdown();
 
     // Do ordinary BooleanQuery:
     BooleanQuery bq = new BooleanQuery();
@@ -253,7 +253,7 @@
     doc.add(newTextField("field", "wizard oz the the the the the the", Field.Store.NO));
     w.addDocument(doc);
     IndexReader r = w.getReader();
-    w.close();
+    w.shutdown();
 
     // Do ordinary BooleanQuery:
     BooleanQuery bq = new BooleanQuery();
@@ -315,7 +315,7 @@
       w.addDocument(doc);
     }
     final IndexReader r = w.getReader();
-    w.close();
+    w.shutdown();
 
     IndexSearcher s = newSearcher(r);
     int numHits = TestUtil.nextInt(random(), 1, numDocs);
Index: lucene/core/src/test/org/apache/lucene/search/TestSearchWithThreads.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestSearchWithThreads.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/TestSearchWithThreads.java	(working copy)
@@ -65,7 +65,7 @@
       sb.delete(0, sb.length());
     }
     final IndexReader r = w.getReader();
-    w.close();
+    w.shutdown();
 
     final long endTime = System.currentTimeMillis();
     if (VERBOSE) System.out.println("BUILD took " + (endTime-startTime));
Index: lucene/core/src/test/org/apache/lucene/search/TestQueryWrapperFilter.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestQueryWrapperFilter.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/TestQueryWrapperFilter.java	(working copy)
@@ -38,7 +38,7 @@
     doc.add(newTextField("field", "value", Field.Store.NO));
     writer.addDocument(doc);
     IndexReader reader = writer.getReader();
-    writer.close();
+    writer.shutdown();
 
     TermQuery termQuery = new TermQuery(new Term("field", "value"));
 
@@ -112,7 +112,7 @@
     }
 
     final IndexReader r = w.getReader();
-    w.close();
+    w.shutdown();
     final TopDocs hits = newSearcher(r).search(new MatchAllDocsQuery(),
                                                      new QueryWrapperFilter(new TermQuery(new Term("field", "a"))),
                                                      numDocs);
@@ -134,7 +134,7 @@
     }
     
     IndexReader reader = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     IndexSearcher searcher = newSearcher(reader);
     
Index: lucene/core/src/test/org/apache/lucene/search/TestDocBoost.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestDocBoost.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/TestDocBoost.java	(working copy)
@@ -52,7 +52,7 @@
     writer.addDocument(d2);
 
     IndexReader reader = writer.getReader();
-    writer.close();
+    writer.shutdown();
 
     final float[] scores = new float[4];
 
Index: lucene/core/src/test/org/apache/lucene/search/TestSloppyPhraseQuery.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestSloppyPhraseQuery.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/TestSloppyPhraseQuery.java	(working copy)
@@ -148,7 +148,7 @@
     assertEquals("slop: "+slop+"  query: "+query+"  doc: "+doc+"  Wrong number of hits", expectedNumResults, c.totalHits);
 
     //QueryUtils.check(query,searcher);
-    writer.close();
+    writer.shutdown();
     reader.close();
     ramDir.close();
 
@@ -239,7 +239,7 @@
     f.setStringValue("drug druggy drug druggy drug");
     iw.addDocument(doc);
     IndexReader ir = iw.getReader();
-    iw.close();
+    iw.shutdown();
     IndexSearcher is = newSearcher(ir);
     
     PhraseQuery pq = new PhraseQuery();
@@ -266,7 +266,7 @@
     doc.add(newField("lyrics", document, new FieldType(TextField.TYPE_NOT_STORED)));
     iw.addDocument(doc);
     IndexReader ir = iw.getReader();
-    iw.close();
+    iw.shutdown();
     
     IndexSearcher is = newSearcher(ir);
     PhraseQuery pq = new PhraseQuery();
@@ -319,7 +319,7 @@
      doc.add(newField("lyrics", document, new FieldType(TextField.TYPE_NOT_STORED)));
      iw.addDocument(doc);
      IndexReader ir = iw.getReader();
-     iw.close();
+     iw.shutdown();
         
      IndexSearcher is = newSearcher(ir);
      
Index: lucene/core/src/test/org/apache/lucene/search/TestRegexpQuery.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestRegexpQuery.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/TestRegexpQuery.java	(working copy)
@@ -51,7 +51,7 @@
     doc.add(newTextField(FN, "the quick brown fox jumps over the lazy ??? dog 493432 49344", Field.Store.NO));
     writer.addDocument(doc);
     reader = writer.getReader();
-    writer.close();
+    writer.shutdown();
     searcher = newSearcher(reader);
   }
   
Index: lucene/core/src/test/org/apache/lucene/search/TestBooleanOr.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestBooleanOr.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/TestBooleanOr.java	(working copy)
@@ -149,7 +149,7 @@
     reader = writer.getReader();
     //
     searcher = newSearcher(reader);
-    writer.close();
+    writer.shutdown();
   }
 
   @Override
@@ -173,7 +173,7 @@
 
     riw.forceMerge(1);
     IndexReader r = riw.getReader();
-    riw.close();
+    riw.shutdown();
 
     IndexSearcher s = newSearcher(r);
     BooleanQuery bq = new BooleanQuery();
Index: lucene/core/src/test/org/apache/lucene/search/TestTermScorer.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestTermScorer.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/TestTermScorer.java	(working copy)
@@ -58,7 +58,7 @@
       writer.addDocument(doc);
     }
     indexReader = SlowCompositeReaderWrapper.wrap(writer.getReader());
-    writer.close();
+    writer.shutdown();
     indexSearcher = newSearcher(indexReader);
     indexSearcher.setSimilarity(new DefaultSimilarity());
   }
Index: lucene/core/src/test/org/apache/lucene/search/FuzzyTermOnShortTermsTest.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/FuzzyTermOnShortTermsTest.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/FuzzyTermOnShortTermsTest.java	(working copy)
@@ -92,7 +92,7 @@
          writer.addDocument(d);
             
       }
-      writer.close();
+      writer.shutdown();
       return directory;
    }
 }
Index: lucene/core/src/test/org/apache/lucene/search/TestFieldCache.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestFieldCache.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/TestFieldCache.java	(working copy)
@@ -123,7 +123,7 @@
     }
     IndexReader r = writer.getReader();
     reader = SlowCompositeReaderWrapper.wrap(r);
-    writer.close();
+    writer.shutdown();
   }
 
   @AfterClass
@@ -304,7 +304,7 @@
   public void testEmptyIndex() throws Exception {
     Directory dir = newDirectory();
     IndexWriter writer= new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random())).setMaxBufferedDocs(500));
-    writer.close();
+    writer.shutdown();
     IndexReader r = DirectoryReader.open(dir);
     AtomicReader reader = SlowCompositeReaderWrapper.wrap(r);
     FieldCache.DEFAULT.getTerms(reader, "foobar", true);
@@ -451,7 +451,7 @@
     }
     iw.addDocument(doc);
     DirectoryReader ir = iw.getReader();
-    iw.close();
+    iw.shutdown();
     AtomicReader ar = getOnlySegmentReader(ir);
     
     BytesRef scratch = new BytesRef();
@@ -584,7 +584,7 @@
     Document doc = new Document();
     iw.addDocument(doc);
     DirectoryReader ir = iw.getReader();
-    iw.close();
+    iw.shutdown();
     
     AtomicReader ar = getOnlySegmentReader(ir);
     
@@ -643,7 +643,7 @@
     doc.add(new StoredField("bogusbits", "bogus"));
     iw.addDocument(doc);
     DirectoryReader ir = iw.getReader();
-    iw.close();
+    iw.shutdown();
     
     AtomicReader ar = getOnlySegmentReader(ir);
     
@@ -728,7 +728,7 @@
       assertEquals(values[i], longs.get(i));
     }
     reader.close();
-    iw.close();
+    iw.shutdown();
     dir.close();
   }
 
@@ -774,7 +774,7 @@
       assertEquals(values[i], ints.get(i));
     }
     reader.close();
-    iw.close();
+    iw.shutdown();
     dir.close();
   }
 
Index: lucene/core/src/test/org/apache/lucene/search/TestSameScoresWithThreads.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestSameScoresWithThreads.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/TestSameScoresWithThreads.java	(working copy)
@@ -58,7 +58,7 @@
     }
     IndexReader r = w.getReader();
     //System.out.println("numDocs=" + r.numDocs());
-    w.close();
+    w.shutdown();
 
     final IndexSearcher s = newSearcher(r);
     Terms terms = MultiFields.getFields(r).terms("body");
Index: lucene/core/src/test/org/apache/lucene/search/TestConstantScoreQuery.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestConstantScoreQuery.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/TestConstantScoreQuery.java	(working copy)
@@ -90,7 +90,7 @@
       writer.addDocument(doc);
 
       reader = writer.getReader();
-      writer.close();
+      writer.shutdown();
       // we don't wrap with AssertingIndexSearcher in order to have the original scorer in setScorer.
       searcher = newSearcher(reader, true, false);
       
@@ -137,7 +137,7 @@
     doc.add(newStringField("field", "b", Field.Store.NO));
     w.addDocument(doc);
     IndexReader r = w.getReader();
-    w.close();
+    w.shutdown();
 
     Filter filterB = new CachingWrapperFilter(new QueryWrapperFilter(new TermQuery(new Term("field", "b"))));
     Query query = new ConstantScoreQuery(filterB);
@@ -163,7 +163,7 @@
     doc.add(newStringField("field", "a", Field.Store.NO));
     w.addDocument(doc);
     IndexReader r = w.getReader();
-    w.close();
+    w.shutdown();
 
     Filter filter = new QueryWrapperFilter(AssertingQuery.wrap(random(), new TermQuery(new Term("field", "a"))));
     IndexSearcher s = newSearcher(r);
Index: lucene/core/src/test/org/apache/lucene/search/TestTopFieldCollector.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestTopFieldCollector.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/TestTopFieldCollector.java	(working copy)
@@ -41,7 +41,7 @@
       iw.addDocument(doc);
     }
     ir = iw.getReader();
-    iw.close();
+    iw.shutdown();
     is = newSearcher(ir);
   }
   
Index: lucene/core/src/test/org/apache/lucene/search/TestElevationComparator.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestElevationComparator.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/TestElevationComparator.java	(working copy)
@@ -52,7 +52,7 @@
     writer.addDocument(adoc(new String[] {"id", "z", "title", "boosted boosted boosted","str_s", "z"}));
 
     IndexReader r = DirectoryReader.open(writer, true);
-    writer.close();
+    writer.shutdown();
 
     IndexSearcher searcher = newSearcher(r);
     searcher.setSimilarity(new DefaultSimilarity());
Index: lucene/core/src/test/org/apache/lucene/search/TestNumericRangeQuery64.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestNumericRangeQuery64.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/TestNumericRangeQuery64.java	(working copy)
@@ -133,7 +133,7 @@
     }
     reader = writer.getReader();
     searcher=newSearcher(reader);
-    writer.close();
+    writer.shutdown();
   }
   
   @AfterClass
@@ -350,7 +350,7 @@
       writer.addDocument(doc);
     }
     
-    writer.close();
+    writer.shutdown();
     
     IndexReader r = DirectoryReader.open(dir);
     IndexSearcher s = newSearcher(r);
Index: lucene/core/src/test/org/apache/lucene/search/TestSearcherManager.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestSearcherManager.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/TestSearcherManager.java	(working copy)
@@ -285,7 +285,7 @@
     assertFalse(success.get());
     assertTrue(triedReopen.get());
     assertNull("" + exc[0], exc[0]);
-    writer.close();
+    writer.shutdown();
     dir.close();
     if (es != null) {
       es.shutdown();
@@ -296,7 +296,7 @@
   public void testCloseTwice() throws Exception {
     // test that we can close SM twice (per Closeable's contract).
     Directory dir = newDirectory();
-    new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, null)).close();
+    new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, null)).shutdown();
     SearcherManager sm = new SearcherManager(dir, null);
     sm.close();
     sm.close();
@@ -329,14 +329,14 @@
     }
 
     // sm.close(); -- already closed
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
 
 
   public void testEnsureOpen() throws Exception {
     Directory dir = newDirectory();
-    new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, null)).close();
+    new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, null)).shutdown();
     SearcherManager sm = new SearcherManager(dir, null);
     IndexSearcher s = sm.acquire();
     sm.close();
@@ -382,7 +382,7 @@
     sm.maybeRefreshBlocking();
     assertTrue(afterRefreshCalled.get());
     sm.close();
-    iw.close();
+    iw.shutdown();
     dir.close();
   }
 
@@ -411,7 +411,7 @@
     } catch (IllegalStateException ise) {
       // expected
     }
-    w.close();
+    w.shutdown();
     other.close();
     dir.close();
   }
@@ -421,7 +421,7 @@
     // threads cannot obtain it.
     final Directory dir = newDirectory();
     final RandomIndexWriter w = new RandomIndexWriter(random(), dir);
-    w.close();
+    w.shutdown();
     
     final SearcherManager sm = new SearcherManager(dir, null);
     
Index: lucene/core/src/test/org/apache/lucene/search/TestPositiveScoresOnlyCollector.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestPositiveScoresOnlyCollector.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/TestPositiveScoresOnlyCollector.java	(working copy)
@@ -82,7 +82,7 @@
     writer.addDocument(new Document());
     writer.commit();
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
     IndexSearcher searcher = newSearcher(ir);
     Weight fake = new TermQuery(new Term("fake", "weight")).createWeight(searcher);
     Scorer s = new SimpleScorer(fake);
Index: lucene/core/src/test/org/apache/lucene/search/spans/TestSpans.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/spans/TestSpans.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/spans/TestSpans.java	(working copy)
@@ -61,7 +61,7 @@
       writer.addDocument(doc);
     }
     reader = writer.getReader();
-    writer.close();
+    writer.shutdown();
     searcher = newSearcher(reader);
   }
   
@@ -483,7 +483,7 @@
     addDoc(writer, "2", "the cat chased the mouse, then the cat ate the mouse quickly");
     
     // Commit
-    writer.close();
+    writer.shutdown();
 
     // Get searcher
     final IndexReader reader = DirectoryReader.open(dir);
Index: lucene/core/src/test/org/apache/lucene/search/spans/TestSpanMultiTermQueryWrapper.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/spans/TestSpanMultiTermQueryWrapper.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/spans/TestSpanMultiTermQueryWrapper.java	(working copy)
@@ -54,7 +54,7 @@
     field.setStringValue("jumps over extremely very lazy broxn dog");
     iw.addDocument(doc);
     reader = iw.getReader();
-    iw.close();
+    iw.shutdown();
     searcher = newSearcher(reader);
   }
   
Index: lucene/core/src/test/org/apache/lucene/search/spans/TestSpansAdvanced2.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/spans/TestSpansAdvanced2.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/spans/TestSpansAdvanced2.java	(working copy)
@@ -57,7 +57,7 @@
     addDocument(writer, "C", "It shouldn't.");
     addDocument(writer, "D", "Should we, should we, should we.");
     reader2 = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     // re-open the searcher since we added more docs
     searcher2 = newSearcher(reader2);
Index: lucene/core/src/test/org/apache/lucene/search/spans/TestPayloadSpans.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/spans/TestPayloadSpans.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/spans/TestPayloadSpans.java	(working copy)
@@ -117,7 +117,7 @@
     doc.add(newTextField(PayloadHelper.FIELD, "one two three one four three", Field.Store.YES));
     writer.addDocument(doc);
     IndexReader reader = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
 
     checkSpans(MultiSpansWrapper.wrap(reader.getContext(), snq), 1,new int[]{2});
@@ -262,7 +262,7 @@
 
     IndexReader reader = writer.getReader();
     IndexSearcher is = newSearcher(reader);
-    writer.close();
+    writer.shutdown();
 
     SpanTermQuery stq1 = new SpanTermQuery(new Term("content", "a"));
     SpanTermQuery stq2 = new SpanTermQuery(new Term("content", "k"));
@@ -298,7 +298,7 @@
     writer.addDocument(doc);
     IndexReader reader = writer.getReader();
     IndexSearcher is = newSearcher(reader);
-    writer.close();
+    writer.shutdown();
 
     SpanTermQuery stq1 = new SpanTermQuery(new Term("content", "a"));
     SpanTermQuery stq2 = new SpanTermQuery(new Term("content", "k"));
@@ -333,7 +333,7 @@
     writer.addDocument(doc);
     IndexReader reader = writer.getReader();
     IndexSearcher is = newSearcher(reader);
-    writer.close();
+    writer.shutdown();
 
     SpanTermQuery stq1 = new SpanTermQuery(new Term("content", "a"));
     SpanTermQuery stq2 = new SpanTermQuery(new Term("content", "k"));
@@ -374,7 +374,7 @@
     writer.addDocument(doc);
   
     IndexReader reader = writer.getReader();
-    writer.close();
+    writer.shutdown();
     IndexSearcher searcher = newSearcher(reader);
 
     PayloadSpanUtil psu = new PayloadSpanUtil(searcher.getTopReaderContext());
@@ -438,7 +438,7 @@
     }
 
     closeIndexReader = writer.getReader();
-    writer.close();
+    writer.shutdown();
 
     IndexSearcher searcher = newSearcher(closeIndexReader);
     return searcher;
Index: lucene/core/src/test/org/apache/lucene/search/spans/TestSpanFirstQuery.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/spans/TestSpanFirstQuery.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/spans/TestSpanFirstQuery.java	(working copy)
@@ -59,7 +59,7 @@
     sfq = new SpanNotQuery(include, sfq);
     assertEquals(1, searcher.search(sfq, 10).totalHits);
     
-    writer.close();
+    writer.shutdown();
     reader.close();
     dir.close();
   }
Index: lucene/core/src/test/org/apache/lucene/search/spans/TestNearSpansOrdered.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/spans/TestNearSpansOrdered.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/spans/TestNearSpansOrdered.java	(working copy)
@@ -58,7 +58,7 @@
       writer.addDocument(doc);
     }
     reader = writer.getReader();
-    writer.close();
+    writer.shutdown();
     searcher = newSearcher(reader);
   }
 
Index: lucene/core/src/test/org/apache/lucene/search/spans/TestBasics.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/spans/TestBasics.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/spans/TestBasics.java	(working copy)
@@ -120,7 +120,7 @@
     }
     reader = writer.getReader();
     searcher = newSearcher(reader);
-    writer.close();
+    writer.shutdown();
   }
 
   @AfterClass
Index: lucene/core/src/test/org/apache/lucene/search/spans/TestFieldMaskingSpanQuery.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/spans/TestFieldMaskingSpanQuery.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/spans/TestFieldMaskingSpanQuery.java	(working copy)
@@ -113,7 +113,7 @@
                                          field("first",  "bubba"),
                                          field("last",   "jones")     }));
     reader = writer.getReader();
-    writer.close();
+    writer.shutdown();
     searcher = newSearcher(reader);
   }
 
Index: lucene/core/src/test/org/apache/lucene/search/spans/TestSpansAdvanced.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/spans/TestSpansAdvanced.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/spans/TestSpansAdvanced.java	(working copy)
@@ -67,7 +67,7 @@
     addDocument(writer, "3", "I think it should work.");
     addDocument(writer, "4", "I think it should work.");
     reader = writer.getReader();
-    writer.close();
+    writer.shutdown();
     searcher = newSearcher(reader);
     searcher.setSimilarity(new DefaultSimilarity());
   }
Index: lucene/core/src/test/org/apache/lucene/search/TestDocValuesScoring.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestDocValuesScoring.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/TestDocValuesScoring.java	(working copy)
@@ -62,7 +62,7 @@
     dvField.setFloatValue(4f); // boost x4
     iw.addDocument(doc);
     IndexReader ir = iw.getReader();
-    iw.close();
+    iw.shutdown();
     
     // no boosting
     IndexSearcher searcher1 = newSearcher(ir, false);
Index: lucene/core/src/test/org/apache/lucene/search/TestConjunctions.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestConjunctions.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/TestConjunctions.java	(working copy)
@@ -57,7 +57,7 @@
     writer.addDocument(doc("solr", "solr is a very popular search server and is using lucene"));
     writer.addDocument(doc("nutch", "nutch is an internet search engine with web crawler and is using lucene and hadoop"));
     reader = writer.getReader();
-    writer.close();
+    writer.shutdown();
     searcher = newSearcher(reader);
     searcher.setSimilarity(new TFSimilarity());
   }
Index: lucene/core/src/test/org/apache/lucene/search/TestRegexpRandom2.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestRegexpRandom2.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/TestRegexpRandom2.java	(working copy)
@@ -87,7 +87,7 @@
     reader = writer.getReader();
     searcher1 = newSearcher(reader);
     searcher2 = newSearcher(reader);
-    writer.close();
+    writer.shutdown();
   }
 
   @Override
Index: lucene/core/src/test/org/apache/lucene/search/TestTopDocsCollector.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestTopDocsCollector.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/TestTopDocsCollector.java	(working copy)
@@ -112,7 +112,7 @@
       writer.addDocument(new Document());
     }
     reader = writer.getReader();
-    writer.close();
+    writer.shutdown();
   }
   
   @Override
Index: lucene/core/src/test/org/apache/lucene/search/TestMatchAllDocsQuery.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestMatchAllDocsQuery.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/TestMatchAllDocsQuery.java	(working copy)
@@ -83,7 +83,7 @@
     hits = is.search(new MatchAllDocsQuery(), null, 1000).scoreDocs;
     assertEquals(2, hits.length);
 
-    iw.close();
+    iw.shutdown();
     ir.close();
     dir.close();
   }
Index: lucene/core/src/test/org/apache/lucene/search/TestFieldCacheRangeFilter.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestFieldCacheRangeFilter.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/TestFieldCacheRangeFilter.java	(working copy)
@@ -448,7 +448,7 @@
     BytesRef term0 = new BytesRef();
     NumericUtils.intToPrefixCoded(0, 0, term0);
     writer.deleteDocuments(new Term("id_int", term0));
-    writer.close();
+    writer.shutdown();
 
     IndexReader reader = DirectoryReader.open(dir);
     IndexSearcher search = newSearcher(reader);
Index: lucene/core/src/test/org/apache/lucene/search/TestTopDocsMerge.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestTopDocsMerge.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/TestTopDocsMerge.java	(working copy)
@@ -122,7 +122,7 @@
       }
 
       reader = w.getReader();
-      w.close();
+      w.shutdown();
     }
 
     // NOTE: sometimes reader has just one segment, which is
Index: lucene/core/src/test/org/apache/lucene/search/TestSortDocValues.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestSortDocValues.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/TestSortDocValues.java	(working copy)
@@ -64,7 +64,7 @@
     doc.add(newStringField("value", "bar", Field.Store.YES));
     writer.addDocument(doc);
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     Sort sort = new Sort(new SortField("value", SortField.Type.STRING));
@@ -93,7 +93,7 @@
     doc.add(newStringField("value", "foo", Field.Store.YES));
     writer.addDocument(doc);
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     Sort sort = new Sort(new SortField("value", SortField.Type.STRING, true));
@@ -122,7 +122,7 @@
     doc.add(newStringField("value", "bar", Field.Store.YES));
     writer.addDocument(doc);
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     Sort sort = new Sort(new SortField("value", SortField.Type.STRING_VAL));
@@ -151,7 +151,7 @@
     doc.add(newStringField("value", "foo", Field.Store.YES));
     writer.addDocument(doc);
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     Sort sort = new Sort(new SortField("value", SortField.Type.STRING_VAL, true));
@@ -180,7 +180,7 @@
     doc.add(newStringField("value", "bar", Field.Store.YES));
     writer.addDocument(doc);
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     Sort sort = new Sort(new SortField("value", SortField.Type.STRING_VAL));
@@ -209,7 +209,7 @@
     doc.add(newStringField("value", "foo", Field.Store.YES));
     writer.addDocument(doc);
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     Sort sort = new Sort(new SortField("value", SortField.Type.STRING_VAL, true));
@@ -242,7 +242,7 @@
     doc.add(newStringField("value", "4", Field.Store.YES));
     writer.addDocument(doc);
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     Sort sort = new Sort(new SortField("value", SortField.Type.INT));
@@ -276,7 +276,7 @@
     doc.add(newStringField("value", "4", Field.Store.YES));
     writer.addDocument(doc);
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     Sort sort = new Sort(new SortField("value", SortField.Type.INT, true));
@@ -308,7 +308,7 @@
     doc.add(newStringField("value", "4", Field.Store.YES));
     writer.addDocument(doc);
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     Sort sort = new Sort(new SortField("value", SortField.Type.INT));
@@ -339,7 +339,7 @@
     doc.add(newStringField("value", "4", Field.Store.YES));
     writer.addDocument(doc);
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     SortField sortField = new SortField("value", SortField.Type.INT);
@@ -374,7 +374,7 @@
     doc.add(newStringField("value", "4", Field.Store.YES));
     writer.addDocument(doc);
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     Sort sort = new Sort(new SortField("value", SortField.Type.LONG));
@@ -408,7 +408,7 @@
     doc.add(newStringField("value", "4", Field.Store.YES));
     writer.addDocument(doc);
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     Sort sort = new Sort(new SortField("value", SortField.Type.LONG, true));
@@ -440,7 +440,7 @@
     doc.add(newStringField("value", "4", Field.Store.YES));
     writer.addDocument(doc);
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     Sort sort = new Sort(new SortField("value", SortField.Type.LONG));
@@ -471,7 +471,7 @@
     doc.add(newStringField("value", "4", Field.Store.YES));
     writer.addDocument(doc);
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     SortField sortField = new SortField("value", SortField.Type.LONG);
@@ -506,7 +506,7 @@
     doc.add(newStringField("value", "4.2", Field.Store.YES));
     writer.addDocument(doc);
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     Sort sort = new Sort(new SortField("value", SortField.Type.FLOAT));
@@ -540,7 +540,7 @@
     doc.add(newStringField("value", "4.2", Field.Store.YES));
     writer.addDocument(doc);
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     Sort sort = new Sort(new SortField("value", SortField.Type.FLOAT, true));
@@ -572,7 +572,7 @@
     doc.add(newStringField("value", "4.2", Field.Store.YES));
     writer.addDocument(doc);
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     Sort sort = new Sort(new SortField("value", SortField.Type.FLOAT));
@@ -603,7 +603,7 @@
     doc.add(newStringField("value", "4.2", Field.Store.YES));
     writer.addDocument(doc);
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     SortField sortField = new SortField("value", SortField.Type.FLOAT);
@@ -642,7 +642,7 @@
     doc.add(newStringField("value", "4.2333333333332", Field.Store.YES));
     writer.addDocument(doc);
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     Sort sort = new Sort(new SortField("value", SortField.Type.DOUBLE));
@@ -674,7 +674,7 @@
     writer.addDocument(doc);
     doc = new Document();
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     Sort sort = new Sort(new SortField("value", SortField.Type.DOUBLE));
@@ -710,7 +710,7 @@
     doc.add(newStringField("value", "4.2333333333332", Field.Store.YES));
     writer.addDocument(doc);
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     Sort sort = new Sort(new SortField("value", SortField.Type.DOUBLE, true));
@@ -747,7 +747,7 @@
     doc.add(newStringField("value", "4.2333333333332", Field.Store.YES));
     writer.addDocument(doc);
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     Sort sort = new Sort(new SortField("value", SortField.Type.DOUBLE));
@@ -783,7 +783,7 @@
     doc.add(newStringField("value", "4.2333333333332", Field.Store.YES));
     writer.addDocument(doc);
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     IndexSearcher searcher = newSearcher(ir);
     SortField sortField = new SortField("value", SortField.Type.DOUBLE);
Index: lucene/core/src/test/org/apache/lucene/search/TestExplanations.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestExplanations.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/TestExplanations.java	(working copy)
@@ -80,7 +80,7 @@
       writer.addDocument(doc);
     }
     reader = writer.getReader();
-    writer.close();
+    writer.shutdown();
     searcher = newSearcher(reader);
   }
 
Index: lucene/core/src/test/org/apache/lucene/search/TestTermVectors.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestTermVectors.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/TestTermVectors.java	(working copy)
@@ -76,7 +76,7 @@
       writer.addDocument(doc);
     }
     reader = writer.getReader();
-    writer.close();
+    writer.shutdown();
   }
   
   @AfterClass
@@ -118,7 +118,7 @@
     doc.add(newField("field", "one", ft5));
     writer.addDocument(doc);
     IndexReader reader = writer.getReader();
-    writer.close();
+    writer.shutdown();
 
     IndexSearcher searcher = newSearcher(reader);
 
@@ -164,7 +164,7 @@
   private void createDir(Directory dir) throws IOException {
     IndexWriter writer = createWriter(dir);
     writer.addDocument(createDoc());
-    writer.close();
+    writer.shutdown();
   }
 
   private Document createDoc() {
@@ -195,7 +195,7 @@
       writer.addDocument(createDoc());
     }
     writer.forceMerge(1);
-    writer.close();
+    writer.shutdown();
     
     verifyIndex(target);
     target.close();
@@ -212,7 +212,7 @@
     IndexWriter writer = createWriter(target);
     writer.addIndexes(input);
     writer.forceMerge(1);
-    writer.close();
+    writer.shutdown();
 
     verifyIndex(target);
 
@@ -234,7 +234,7 @@
       r.close();
     }
     writer.forceMerge(1);
-    writer.close();
+    writer.shutdown();
     
     verifyIndex(target);
     IOUtils.close(target, input[0], input[1]);
Index: lucene/core/src/test/org/apache/lucene/search/TestFilteredQuery.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestFilteredQuery.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/TestFilteredQuery.java	(working copy)
@@ -87,7 +87,7 @@
     writer.forceMerge(1);
 
     reader = writer.getReader();
-    writer.close ();
+    writer.shutdown();
 
     searcher = newSearcher(reader);
 
@@ -415,7 +415,7 @@
       writer.addDocument(doc);
     }
     IndexReader reader = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     IndexSearcher searcher = newSearcher(reader);
     Query query = new FilteredQuery(new TermQuery(new Term("field", "0")),
@@ -471,9 +471,8 @@
         }, FilteredQuery.QUERY_FIRST_FILTER_STRATEGY);
     
     TopDocs search = searcher.search(query, 10);
-    assertEquals(totalDocsWithZero, search.totalHits);
-    IOUtils.close(reader, writer, directory);
-    
+    assertEquals(totalDocsWithZero, search.totalHits);  
+    IOUtils.close(reader, directory);
   }
   
   /*
@@ -495,7 +494,7 @@
       writer.addDocument (doc);  
     }
     IndexReader reader = writer.getReader();
-    writer.close ();
+    writer.shutdown();
     final boolean queryFirst = random().nextBoolean();
     IndexSearcher searcher = newSearcher(reader);
     Query query = new FilteredQuery(new TermQuery(new Term("field", "0")), new Filter() {
@@ -551,8 +550,7 @@
     
     TopDocs search = searcher.search(query, 10);
     assertEquals(totalDocsWithZero, search.totalHits);
-    IOUtils.close(reader, writer, directory);
-     
+    IOUtils.close(reader, directory);
   }
 }
 
Index: lucene/core/src/test/org/apache/lucene/search/TestWildcardRandom.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestWildcardRandom.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/TestWildcardRandom.java	(working copy)
@@ -63,7 +63,7 @@
     
     reader = writer.getReader();
     searcher = newSearcher(reader);
-    writer.close();
+    writer.shutdown();
     if (VERBOSE) {
       System.out.println("TEST: setUp searcher=" + searcher);
     }
Index: lucene/core/src/test/org/apache/lucene/search/TestMultiTermQueryRewrites.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestMultiTermQueryRewrites.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/TestMultiTermQueryRewrites.java	(working copy)
@@ -58,7 +58,7 @@
       ((i % 2 == 0) ? swriter1 : swriter2).addDocument(doc);
     }
     writer.forceMerge(1); swriter1.forceMerge(1); swriter2.forceMerge(1);
-    writer.close(); swriter1.close(); swriter2.close();
+    writer.shutdown(); swriter1.shutdown(); swriter2.shutdown();
     
     reader = DirectoryReader.open(dir);
     searcher = newSearcher(reader);
Index: lucene/core/src/test/org/apache/lucene/search/BaseTestRangeFilter.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/BaseTestRangeFilter.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/BaseTestRangeFilter.java	(working copy)
@@ -176,7 +176,7 @@
         // exceedingly rare (Yonik calculates 1 in ~429,000)
         // times) that this loop requires more than one try:
         IndexReader ir = writer.getReader();
-        writer.close();
+        writer.shutdown();
         return ir;
       }
 
Index: lucene/core/src/test/org/apache/lucene/search/TestDocTermOrdsRangeFilter.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestDocTermOrdsRangeFilter.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/TestDocTermOrdsRangeFilter.java	(working copy)
@@ -89,7 +89,7 @@
     reader = writer.getReader();
     searcher1 = newSearcher(reader);
     searcher2 = newSearcher(reader);
-    writer.close();
+    writer.shutdown();
   }
   
   @Override
Index: lucene/core/src/test/org/apache/lucene/search/TestPrefixInBooleanQuery.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestPrefixInBooleanQuery.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/TestPrefixInBooleanQuery.java	(working copy)
@@ -70,7 +70,7 @@
     
     reader = writer.getReader();
     searcher = newSearcher(reader);
-    writer.close();
+    writer.shutdown();
   }
   
   @AfterClass
Index: lucene/core/src/test/org/apache/lucene/search/TestScoreCachingWrappingScorer.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestScoreCachingWrappingScorer.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/TestScoreCachingWrappingScorer.java	(working copy)
@@ -107,7 +107,7 @@
     RandomIndexWriter writer = new RandomIndexWriter(random(), directory);
     writer.commit();
     IndexReader ir = writer.getReader();
-    writer.close();
+    writer.shutdown();
     IndexSearcher searcher = newSearcher(ir);
     Weight fake = new TermQuery(new Term("fake", "weight")).createWeight(searcher);
     Scorer s = new SimpleScorer(fake);
Index: lucene/core/src/test/org/apache/lucene/search/TestBooleanMinShouldMatch.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestBooleanMinShouldMatch.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/TestBooleanMinShouldMatch.java	(working copy)
@@ -71,7 +71,7 @@
 
         r = w.getReader();
         s = newSearcher(r);
-        w.close();
+        w.shutdown();
 //System.out.println("Set up " + getName());
     }
     
Index: lucene/core/src/test/org/apache/lucene/search/TestMultiPhraseQuery.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestMultiPhraseQuery.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/search/TestMultiPhraseQuery.java	(working copy)
@@ -135,7 +135,7 @@
       // okay, all terms must belong to the same field
     }
     
-    writer.close();
+    writer.shutdown();
     reader.close();
     indexStore.close();
   }
@@ -147,7 +147,7 @@
     add("blueberry chocolate pie", writer);
     add("blueberry chocolate tart", writer);
     IndexReader r = writer.getReader();
-    writer.close();
+    writer.shutdown();
 
     IndexSearcher searcher = newSearcher(r);
     MultiPhraseQuery q = new MultiPhraseQuery();
@@ -165,7 +165,7 @@
     RandomIndexWriter writer = new RandomIndexWriter(random(), indexStore);
     add("a b c d e f g h i k", writer);
     IndexReader r = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     IndexSearcher searcher = newSearcher(r);
     
@@ -185,7 +185,7 @@
     RandomIndexWriter writer = new RandomIndexWriter(random(), indexStore);
     add("a b c d e f g h i k", writer);
     IndexReader r = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     IndexSearcher searcher = newSearcher(r);
     MultiPhraseQuery q = new MultiPhraseQuery();
@@ -233,7 +233,7 @@
     // just make sure no exc:
     searcher.explain(q, 0);
     
-    writer.close();
+    writer.shutdown();
     reader.close();
     indexStore.close();
   }
@@ -260,7 +260,7 @@
     // exception will be thrown here without fix for #35626:
     ScoreDoc[] hits = searcher.search(q, null, 1000).scoreDocs;
     assertEquals("Wrong number of hits", 0, hits.length);
-    writer.close();
+    writer.shutdown();
     reader.close();
     indexStore.close();
   }
@@ -282,7 +282,7 @@
     // just make sure no exc:
     searcher.explain(q, 0);
     
-    writer.close();
+    writer.shutdown();
     reader.close();
     indexStore.close();
   }
@@ -349,7 +349,7 @@
     Weight weight = query.createWeight(searcher);
     assertEquals(10f * 10f, weight.getValueForNormalization(), 0.001f);
 
-    writer.close();
+    writer.shutdown();
     reader.close();
     indexStore.close();
   }
@@ -375,7 +375,7 @@
     doc.add(new TextField("field", new CannedTokenStream(tokens)));
     writer.addDocument(doc);
     IndexReader r = writer.getReader();
-    writer.close();
+    writer.shutdown();
     IndexSearcher s = newSearcher(r);
     MultiPhraseQuery mpq = new MultiPhraseQuery();
     //mpq.setSlop(1);
@@ -473,7 +473,7 @@
     doc.add(new TextField("field", new CannedTokenStream(INCR_0_DOC_TOKENS)));
     writer.addDocument(doc);
     IndexReader r = DirectoryReader.open(writer,false);
-    writer.close();
+    writer.shutdown();
     IndexSearcher s = newSearcher(r);
     
     if (VERBOSE) {
Index: lucene/core/src/test/org/apache/lucene/index/TestIndexableField.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestIndexableField.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestIndexableField.java	(working copy)
@@ -280,7 +280,7 @@
     }
 
     final IndexReader r = w.getReader();
-    w.close();
+    w.shutdown();
 
     final IndexSearcher s = newSearcher(r);
     int counter = 0;
Index: lucene/core/src/test/org/apache/lucene/index/TestDirectoryReaderReopen.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestDirectoryReaderReopen.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestDirectoryReaderReopen.java	(working copy)
@@ -142,7 +142,7 @@
         }
       }
     } finally {
-      iwriter.close();
+      iwriter.shutdown();
       reader.close();
     }
   }
@@ -203,7 +203,7 @@
       writer.addDocument(createDocument(i, 3));
     }
     writer.forceMerge(1);
-    writer.close();
+    writer.shutdown();
 
     final TestReopen test = new TestReopen() {      
       @Override
@@ -211,7 +211,7 @@
        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 @@
       w.forceMerge(1);
     }
     
-    w.close();
+    w.shutdown();
 
     DirectoryReader r = DirectoryReader.open(dir);
     if (multiSegment) {
@@ -485,13 +485,13 @@
         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 @@
         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 @@
       writer.setCommitData(data);
       writer.commit();
     }
-    writer.close();
+    writer.shutdown();
 
     DirectoryReader r = DirectoryReader.open(dir);
     assertEquals(0, r.numDocs());
@@ -614,7 +614,7 @@
     assertNotNull(r2);
     r.close();
     assertEquals(1, r2.numDocs());
-    w.close();
+    w.shutdown();
     r2.close();
     dir.close();
   }
Index: lucene/core/src/test/org/apache/lucene/index/TestTermdocPerf.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestTermdocPerf.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestTermdocPerf.java	(working copy)
@@ -100,7 +100,7 @@
     }
 
     writer.forceMerge(1);
-    writer.close();
+    writer.shutdown();
   }
 
 
Index: lucene/core/src/test/org/apache/lucene/index/TestDocumentWriter.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestDocumentWriter.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestDocumentWriter.java	(working copy)
@@ -35,7 +35,6 @@
 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 @@
     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 @@
     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 @@
     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 @@
     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 @@
     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 @@
         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);
 
Index: lucene/core/src/test/org/apache/lucene/index/TestTieredMergePolicy.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestTieredMergePolicy.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestTieredMergePolicy.java	(working copy)
@@ -63,7 +63,7 @@
     w.forceMergeDeletes();
     assertEquals(60, w.maxDoc());
     assertEquals(60, w.numDocs());
-    w.close();
+    w.shutdown();
     dir.close();
   }
 
@@ -104,7 +104,7 @@
       w.forceMerge(targetCount);
       assertEquals(targetCount, w.getSegmentCount());
 
-      w.close();
+      w.shutdown();
       dir.close();
     }
   }
@@ -152,7 +152,7 @@
     assertEquals(numDocs-1, r.numDocs());
     r.close();
 
-    w.close();
+    w.shutdown();
 
     dir.close();
   }
Index: lucene/core/src/test/org/apache/lucene/index/TestCodecHoldsOpenFiles.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestCodecHoldsOpenFiles.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestCodecHoldsOpenFiles.java	(working copy)
@@ -38,7 +38,7 @@
     }
 
     IndexReader r = w.getReader();
-    w.close();
+    w.shutdown();
 
     for(String fileName : d.listAll()) {
       try {
Index: lucene/core/src/test/org/apache/lucene/index/TestTermsEnum.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestTermsEnum.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestTermsEnum.java	(working copy)
@@ -52,7 +52,7 @@
       w.addDocument(docs.nextDoc());
     }
     final IndexReader r = w.getReader();
-    w.close();
+    w.shutdown();
 
     final List<BytesRef> terms = new ArrayList<>();
     final TermsEnum termsEnum = MultiFields.getTerms(r, "body").iterator(null);
@@ -224,7 +224,7 @@
     }
 
     final IndexReader r = w.getReader();
-    w.close();
+    w.shutdown();
 
     // NOTE: intentional insanity!!
     final FieldCache.Ints docIDToID = FieldCache.DEFAULT.getInts(SlowCompositeReaderWrapper.wrap(r), "id", false);
@@ -374,7 +374,7 @@
       close();
     }
     r = w.getReader();
-    w.close();
+    w.shutdown();
     return r;
   }
 
@@ -513,7 +513,7 @@
     w.deleteDocuments(new Term("field", "one"));
     w.forceMerge(1);
     IndexReader r = w.getReader();
-    w.close();
+    w.shutdown();
     assertEquals(1, r.numDocs());
     assertEquals(1, r.maxDoc());
     Terms terms = MultiFields.getTerms(r, "field");
@@ -741,7 +741,7 @@
 
     w.forceMerge(1);
     DirectoryReader r = w.getReader();
-    w.close();
+    w.shutdown();
     AtomicReader sub = getOnlySegmentReader(r);
     Terms terms = sub.fields().terms("field");
     Automaton automaton = new RegExp(".*", RegExp.NONE).toAutomaton();    
@@ -795,7 +795,7 @@
 
     w.forceMerge(1);
     DirectoryReader r = w.getReader();
-    w.close();
+    w.shutdown();
     AtomicReader sub = getOnlySegmentReader(r);
     Terms terms = sub.fields().terms("field");
 
@@ -849,7 +849,7 @@
 
     w.forceMerge(1);
     DirectoryReader r = w.getReader();
-    w.close();
+    w.shutdown();
     AtomicReader sub = getOnlySegmentReader(r);
     Terms terms = sub.fields().terms("field");
 
Index: lucene/core/src/test/org/apache/lucene/index/TestBinaryDocValuesUpdates.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestBinaryDocValuesUpdates.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestBinaryDocValuesUpdates.java	(working copy)
@@ -106,7 +106,7 @@
     writer.getConfig().setRAMBufferSizeMB(1000d);
     writer.updateBinaryDocValue(new Term("id", "doc-2"), "val", toBytes(7));
     assertEquals(4, writer.getFlushDeletesCount());
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
   
@@ -126,11 +126,11 @@
     
     final DirectoryReader reader;
     if (random().nextBoolean()) { // not NRT
-      writer.close();
+      writer.shutdown();
       reader = DirectoryReader.open(dir);
     } else { // NRT
       reader = DirectoryReader.open(writer, true);
-      writer.close();
+      writer.shutdown();
     }
     
     assertEquals(1, reader.leaves().size());
@@ -169,11 +169,11 @@
     
     final DirectoryReader reader;
     if (random().nextBoolean()) { // not NRT
-      writer.close();
+      writer.shutdown();
       reader = DirectoryReader.open(dir);
     } else { // NRT
       reader = DirectoryReader.open(writer, true);
-      writer.close();
+      writer.shutdown();
     }
     
     BytesRef scratch = new BytesRef();
@@ -224,8 +224,9 @@
     BinaryDocValues bdv2 = reader2.leaves().get(0).reader().getBinaryDocValues("val");
     assertEquals(1, getValue(bdv1, 0, scratch));
     assertEquals(10, getValue(bdv2, 0, scratch));
-    
-    IOUtils.close(writer, reader1, reader2, dir);
+
+    writer.shutdown();
+    IOUtils.close(reader1, reader2, dir);
   }
   
   public void testUpdatesAndDeletes() throws Exception {
@@ -253,11 +254,11 @@
     
     final DirectoryReader reader;
     if (random().nextBoolean()) { // not NRT
-      writer.close();
+      writer.shutdown();
       reader = DirectoryReader.open(dir);
     } else { // NRT
       reader = DirectoryReader.open(writer, true);
-      writer.close();
+      writer.shutdown();
     }
     
     AtomicReader slow = SlowCompositeReaderWrapper.wrap(reader);
@@ -298,11 +299,11 @@
     
     final DirectoryReader reader;
     if (random().nextBoolean()) { // not NRT
-      writer.close();
+      writer.shutdown();
       reader = DirectoryReader.open(dir);
     } else { // NRT
       reader = DirectoryReader.open(writer, true);
-      writer.close();
+      writer.shutdown();
     }
     
     AtomicReader r = reader.leaves().get(0).reader();
@@ -332,11 +333,11 @@
     
     final DirectoryReader reader;
     if (random().nextBoolean()) { // not NRT
-      writer.close();
+      writer.shutdown();
       reader = DirectoryReader.open(dir);
     } else { // NRT
       reader = DirectoryReader.open(writer, true);
-      writer.close();
+      writer.shutdown();
     }
     
     AtomicReader r = reader.leaves().get(0).reader();
@@ -367,7 +368,7 @@
     
     // update all docs' bdv field
     writer.updateBinaryDocValue(new Term("dvUpdateKey", "dv"), "bdv", toBytes(17L));
-    writer.close();
+    writer.shutdown();
     
     final DirectoryReader reader = DirectoryReader.open(dir);
     AtomicReader r = reader.leaves().get(0).reader();
@@ -414,7 +415,7 @@
     
     // update all docs' bdv1 field
     writer.updateBinaryDocValue(new Term("dvUpdateKey", "dv"), "bdv1", toBytes(17L));
-    writer.close();
+    writer.shutdown();
     
     final DirectoryReader reader = DirectoryReader.open(dir);
     AtomicReader r = reader.leaves().get(0).reader();
@@ -448,7 +449,7 @@
     
     // update all docs' bdv field
     writer.updateBinaryDocValue(new Term("dvUpdateKey", "dv"), "bdv", toBytes(17L));
-    writer.close();
+    writer.shutdown();
     
     final DirectoryReader reader = DirectoryReader.open(dir);
     AtomicReader r = reader.leaves().get(0).reader();
@@ -478,7 +479,7 @@
     
     // unset the value of 'doc0'
     writer.updateBinaryDocValue(new Term("id", "doc0"), "bdv", null);
-    writer.close();
+    writer.shutdown();
     
     final DirectoryReader reader = DirectoryReader.open(dir);
     AtomicReader r = reader.leaves().get(0).reader();
@@ -517,7 +518,7 @@
     
     // unset the value of 'doc'
     writer.updateBinaryDocValue(new Term("id", "doc"), "bdv", null);
-    writer.close();
+    writer.shutdown();
     
     final DirectoryReader reader = DirectoryReader.open(dir);
     AtomicReader r = reader.leaves().get(0).reader();
@@ -564,7 +565,7 @@
       // ok
     }
     
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
   
@@ -588,7 +589,7 @@
     writer.addDocument(doc); // in-memory document
     
     writer.updateBinaryDocValue(new Term("key", "doc"), "bdv", toBytes(17L));
-    writer.close();
+    writer.shutdown();
     
     final DirectoryReader reader = DirectoryReader.open(dir);
     
@@ -620,7 +621,7 @@
     
     writer.updateBinaryDocValue(new Term("key", "doc"), "bdv", toBytes(17L)); // update existing field
     writer.updateBinaryDocValue(new Term("key", "doc"), "bdv", toBytes(3L)); // update existing field 2nd time in this commit
-    writer.close();
+    writer.shutdown();
     
     final DirectoryReader reader = DirectoryReader.open(dir);
     final AtomicReader r = SlowCompositeReaderWrapper.wrap(reader);
@@ -663,7 +664,7 @@
       if (random.nextDouble() < 0.4) {
         writer.commit();
       } else if (random.nextDouble() < 0.1) {
-        writer.close();
+        writer.shutdown();
         writer = new IndexWriter(dir, conf.clone());
       }
 
@@ -700,7 +701,7 @@
       reader.close();
     }
     
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
   
@@ -720,7 +721,7 @@
     
     writer.updateBinaryDocValue(new Term("k1", "v1"), "bdv", toBytes(17L));
     writer.updateBinaryDocValue(new Term("k2", "v2"), "bdv", toBytes(3L));
-    writer.close();
+    writer.shutdown();
     
     final DirectoryReader reader = DirectoryReader.open(dir);
     final AtomicReader r = SlowCompositeReaderWrapper.wrap(reader);
@@ -839,15 +840,16 @@
       }
 //      System.out.println();
     }
-    
-    IOUtils.close(writer, reader, dir);
+
+    writer.shutdown();
+    IOUtils.close(reader, dir);
   }
   
   public void testUpdateSegmentWithNoDocValues() throws Exception {
     Directory dir = newDirectory();
     IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()));
     // prevent merges, otherwise by the time updates are applied
-    // (writer.close()), the segments might have merged and that update becomes
+    // (writer.shutdown()), the segments might have merged and that update becomes
     // legit.
     conf.setMergePolicy(NoMergePolicy.COMPOUND_FILES);
     IndexWriter writer = new IndexWriter(dir, conf);
@@ -878,7 +880,7 @@
     // update document in the second segment - field should be added and we should
     // be able to handle the other document correctly (e.g. no NPE)
     writer.updateBinaryDocValue(new Term("id", "doc1"), "bdv", toBytes(5L));
-    writer.close();
+    writer.shutdown();
 
     DirectoryReader reader = DirectoryReader.open(dir);
     BytesRef scratch = new BytesRef();
@@ -902,7 +904,7 @@
     Directory dir = newDirectory();
     IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()));
     // prevent merges, otherwise by the time updates are applied
-    // (writer.close()), the segments might have merged and that update becomes
+    // (writer.shutdown()), the segments might have merged and that update becomes
     // legit.
     conf.setMergePolicy(NoMergePolicy.COMPOUND_FILES);
     IndexWriter writer = new IndexWriter(dir, conf);
@@ -924,7 +926,7 @@
     
     // update document in the second segment
     writer.updateBinaryDocValue(new Term("id", "doc1"), "bdv", toBytes(5L));
-    writer.close();
+    writer.shutdown();
 
     DirectoryReader reader = DirectoryReader.open(dir);
     BytesRef scratch = new BytesRef();
@@ -953,7 +955,7 @@
     writer.addDocument(doc);
     writer.commit();
     writer.updateBinaryDocValue(new Term("f", "mock-value"), "f", toBytes(17L));
-    writer.close();
+    writer.shutdown();
     
     DirectoryReader r = DirectoryReader.open(dir);
     BinaryDocValues bdv = r.leaves().get(0).reader().getBinaryDocValues("f");
@@ -977,14 +979,14 @@
     doc.add(new StringField("id", "doc", Store.NO));
     doc.add(new BinaryDocValuesField("f", toBytes(5L)));
     writer.addDocument(doc);
-    writer.close();
+    writer.shutdown();
     
     conf = newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()));
     writer = new IndexWriter(dir, conf);
     writer.updateBinaryDocValue(new Term("id", "doc"), "f", toBytes(4L));
     OLD_FORMAT_IMPERSONATION_IS_ACTIVE = false;
     try {
-      writer.close();
+      writer.shutdown();
       fail("should not have succeeded to update a segment written with an old Codec");
     } catch (UnsupportedOperationException e) {
       writer.rollback(); 
@@ -1101,7 +1103,7 @@
     
     for (Thread t : threads) t.start();
     done.await();
-    writer.close();
+    writer.shutdown();
     
     DirectoryReader reader = DirectoryReader.open(dir);
     BytesRef scratch = new BytesRef();
@@ -1163,7 +1165,7 @@
       }
       reader.close();
     }
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
 
@@ -1183,7 +1185,7 @@
     doc.add(new BinaryDocValuesField("f1", toBytes(5L)));
     doc.add(new BinaryDocValuesField("f2", toBytes(13L)));
     writer.addDocument(doc);
-    writer.close();
+    writer.shutdown();
     
     // change format
     conf.setCodec(new Lucene46Codec() {
@@ -1199,7 +1201,7 @@
     doc.add(new BinaryDocValuesField("f2", toBytes(2L)));
     writer.addDocument(doc);
     writer.updateBinaryDocValue(new Term("id", "d0"), "f1", toBytes(12L));
-    writer.close();
+    writer.shutdown();
     
     DirectoryReader reader = DirectoryReader.open(dir);
     AtomicReader r = SlowCompositeReaderWrapper.wrap(reader);
@@ -1244,7 +1246,7 @@
     Term term = new Term("id", RandomPicks.randomFrom(random(), randomTerms));
     writer.updateBinaryDocValue(term, "bdv", toBytes(value));
     writer.updateBinaryDocValue(term, "control", toBytes(value * 2));
-    writer.close();
+    writer.shutdown();
     
     Directory dir2 = newDirectory();
     conf = newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()));
@@ -1256,7 +1258,7 @@
       writer.addIndexes(reader);
       reader.close();
     }
-    writer.close();
+    writer.shutdown();
     
     DirectoryReader reader = DirectoryReader.open(dir2);
     BytesRef scratch = new BytesRef();
@@ -1302,7 +1304,7 @@
     assertEquals(5L, getValue(r.leaves().get(0).reader().getBinaryDocValues("f"), 0, scratch));
     r.close();
 
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
 
@@ -1356,7 +1358,7 @@
       writer.updateBinaryDocValue(updateTerm, "cf" + field, toBytes(value * 2));
     }
 
-    writer.close();
+    writer.shutdown();
     
     DirectoryReader reader = DirectoryReader.open(dir);
     BytesRef scratch = new BytesRef();
@@ -1391,7 +1393,7 @@
     writer.updateBinaryDocValue(new Term("upd", "t2"), "f1", toBytes(3L)); // update f1 to 3
     writer.updateBinaryDocValue(new Term("upd", "t2"), "f2", toBytes(3L)); // update f2 to 3
     writer.updateBinaryDocValue(new Term("upd", "t1"), "f1", toBytes(4L)); // update f1 to 4 (but not f2)
-    writer.close();
+    writer.shutdown();
     
     DirectoryReader reader = DirectoryReader.open(dir);
     BytesRef scratch = new BytesRef();
@@ -1416,7 +1418,7 @@
     writer.deleteDocuments(new Term("id", "doc")); // delete all docs in the first segment
     writer.addDocument(doc);
     writer.updateBinaryDocValue(new Term("id", "doc"), "f1", toBytes(2L));
-    writer.close();
+    writer.shutdown();
     
     DirectoryReader reader = DirectoryReader.open(dir);
     assertEquals(1, reader.leaves().size());
@@ -1438,7 +1440,7 @@
     // update w/ multiple nonexisting terms in same field
     writer.updateBinaryDocValue(new Term("c", "foo"), "f1", toBytes(2L));
     writer.updateBinaryDocValue(new Term("c", "bar"), "f1", toBytes(2L));
-    writer.close();
+    writer.shutdown();
     
     DirectoryReader reader = DirectoryReader.open(dir);
     assertEquals(1, reader.leaves().size());
Index: lucene/core/src/test/org/apache/lucene/index/TestSameTokenSamePosition.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestSameTokenSamePosition.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestSameTokenSamePosition.java	(working copy)
@@ -40,7 +40,7 @@
     Document doc = new Document();
     doc.add(new TextField("eng", new BugReproTokenStream()));
     riw.addDocument(doc);
-    riw.close();
+    riw.shutdown();
     dir.close();
   }
   
@@ -55,7 +55,7 @@
       doc.add(new TextField("eng", new BugReproTokenStream()));
       riw.addDocument(doc);
     }
-    riw.close();
+    riw.shutdown();
     dir.close();
   }
 }
Index: lucene/core/src/test/org/apache/lucene/index/TestNorms.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestNorms.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestNorms.java	(working copy)
@@ -92,7 +92,7 @@
     }
     
     IndexReader reader = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     NumericDocValues fooNorms = MultiDocValues.getNormValues(reader, "foo");
     for (int i = 0; i < reader.maxDoc(); i++) {
@@ -149,7 +149,7 @@
       }
     }
     writer.commit();
-    writer.close();
+    writer.shutdown();
     docs.close();
   }
 
Index: lucene/core/src/test/org/apache/lucene/index/Test2BDocs.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/Test2BDocs.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/Test2BDocs.java	(working copy)
@@ -38,7 +38,7 @@
       iw.addDocument(doc);
     }
     iw.forceMerge(1);
-    iw.close();
+    iw.shutdown();
   }
   
   @AfterClass
@@ -67,7 +67,7 @@
     for (int i = 0; i < 262143; i++) {
       iw.addDocument(doc);
     }
-    iw.close();
+    iw.shutdown();
     DirectoryReader ir = DirectoryReader.open(dir);
     DirectoryReader ir2 = DirectoryReader.open(dir2);
     IndexReader subReaders[] = new IndexReader[8192];
Index: lucene/core/src/test/org/apache/lucene/index/TestAtomicUpdate.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestAtomicUpdate.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestAtomicUpdate.java	(working copy)
@@ -151,7 +151,7 @@
     searcherThread1.join();
     searcherThread2.join();
 
-    writer.close();
+    writer.shutdown();
 
     assertTrue("hit unexpected exception in indexer", !indexerThread.failed);
     assertTrue("hit unexpected exception in indexer2", !indexerThread2.failed);
Index: lucene/core/src/test/org/apache/lucene/index/TestCustomNorms.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestCustomNorms.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestCustomNorms.java	(working copy)
@@ -66,7 +66,7 @@
       }
     }
     writer.commit();
-    writer.close();
+    writer.shutdown();
     AtomicReader open = SlowCompositeReaderWrapper.wrap(DirectoryReader.open(dir));
     NumericDocValues norms = open.getNormValues(floatTestField);
     assertNotNull(norms);
Index: lucene/core/src/test/org/apache/lucene/index/TestDuelingCodecs.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestDuelingCodecs.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestDuelingCodecs.java	(working copy)
@@ -89,9 +89,9 @@
     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);
Index: lucene/core/src/test/org/apache/lucene/index/TestTermVectorsWriter.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestTermVectorsWriter.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestTermVectorsWriter.java	(working copy)
@@ -55,7 +55,7 @@
     doc.add(f2);
     doc.add(f);
     w.addDocument(doc);
-    w.close();
+    w.shutdown();
 
     IndexReader r = DirectoryReader.open(dir);
     Terms vector = r.getTermVectors(0).terms("field");
@@ -111,7 +111,7 @@
     doc.add(f);
     doc.add(f);
     w.addDocument(doc);
-    w.close();
+    w.shutdown();
 
     IndexReader r = DirectoryReader.open(dir);
     TermsEnum termsEnum = r.getTermVectors(0).terms("field").iterator(null);
@@ -146,7 +146,7 @@
     doc.add(f);
     doc.add(f);
     w.addDocument(doc);
-    w.close();
+    w.shutdown();
 
     IndexReader r = DirectoryReader.open(dir);
     TermsEnum termsEnum = r.getTermVectors(0).terms("field").iterator(null);
@@ -186,7 +186,7 @@
       doc.add(f);
       w.addDocument(doc);
     }
-    w.close();
+    w.shutdown();
 
     IndexReader r = DirectoryReader.open(dir);
     TermsEnum termsEnum = r.getTermVectors(0).terms("field").iterator(null);
@@ -222,7 +222,7 @@
     doc.add(f);
     doc.add(f);
     w.addDocument(doc);
-    w.close();
+    w.shutdown();
 
     IndexReader r = DirectoryReader.open(dir);
     TermsEnum termsEnum = r.getTermVectors(0).terms("field").iterator(null);
@@ -259,7 +259,7 @@
     doc.add(f);
     doc.add(f2);
     w.addDocument(doc);
-    w.close();
+    w.shutdown();
 
     IndexReader r = DirectoryReader.open(dir);
     TermsEnum termsEnum = r.getTermVectors(0).terms("field").iterator(null);
@@ -304,7 +304,7 @@
     doc.add(f);
     doc.add(f2);
     w.addDocument(doc);
-    w.close();
+    w.shutdown();
 
     IndexReader r = DirectoryReader.open(dir);
     TermsEnum termsEnum = r.getTermVectors(0).terms("field").iterator(null);
@@ -347,7 +347,7 @@
     doc.add(f2);
 
     w.addDocument(doc);
-    w.close();
+    w.shutdown();
 
     IndexReader r = DirectoryReader.open(dir);
     TermsEnum termsEnum = r.getTermVectors(0).terms("field").iterator(null);
@@ -404,7 +404,7 @@
       document.add(termVectorField);
       writer.addDocument(document);
       writer.forceMerge(1);
-      writer.close();
+      writer.shutdown();
 
       IndexReader reader = DirectoryReader.open(dir);
       for(int i=0;i<reader.numDocs();i++) {
@@ -422,7 +422,7 @@
       Directory[] indexDirs = {new MockDirectoryWrapper(random(), new RAMDirectory(dir, newIOContext(random())))};
       writer.addIndexes(indexDirs);
       writer.forceMerge(1);
-      writer.close();
+      writer.shutdown();
     }
     dir.close();
   }
@@ -458,7 +458,7 @@
       document.add(termVectorField);
       writer.addDocument(document);
       writer.forceMerge(1);
-      writer.close();
+      writer.shutdown();
 
       IndexReader reader = DirectoryReader.open(dir);
       assertNull(reader.getTermVectors(0));
@@ -492,7 +492,7 @@
     document.add(termVectorField);
     for(int i=0;i<10;i++)
       writer.addDocument(document);
-    writer.close();
+    writer.shutdown();
 
     writer = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT,
         new MockAnalyzer(random())).setMaxBufferedDocs(2)
@@ -503,7 +503,7 @@
       writer.addDocument(document);
 
     writer.forceMerge(1);
-    writer.close();
+    writer.shutdown();
 
     IndexReader reader = DirectoryReader.open(dir);
     for(int i=0;i<10;i++) {
@@ -540,7 +540,7 @@
     iw.commit();
 
     iw.forceMerge(1);
-    iw.close();
+    iw.shutdown();
     dir.close();
   }
 
@@ -572,7 +572,7 @@
     iw.commit();
     iw.forceMerge(1);
 
-    iw.close();
+    iw.shutdown();
     dir.close();
   }
 }
Index: lucene/core/src/test/org/apache/lucene/index/TestNewestSegment.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestNewestSegment.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestNewestSegment.java	(working copy)
@@ -26,7 +26,7 @@
     Directory directory = newDirectory();
     IndexWriter writer = new IndexWriter(directory, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random())));
     assertNull(writer.newestSegment());
-    writer.close();
+    writer.shutdown();
     directory.close();
   }
 }
Index: lucene/core/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java	(working copy)
@@ -152,7 +152,7 @@
     for(int i=0;i<50;i++) {
       writer.addDocument(docs.nextDoc());
     }
-    writer.close();
+    writer.shutdown();
     dir.close();
 
     // Gives you time to copy the index out!: (there is also
@@ -286,7 +286,7 @@
         // IndexFormatTooOldException, and we don't want to mask the fail()
         // above, so close without waiting for merges.
         if (writer != null) {
-          writer.close(false);
+          writer.shutdown(false);
         }
         writer = null;
       }
@@ -312,7 +312,7 @@
       IndexWriter w = new IndexWriter(dir, new IndexWriterConfig(
           TEST_VERSION_CURRENT, new MockAnalyzer(random())));
       w.forceMerge(1);
-      w.close();
+      w.shutdown();
       
       dir.close();
     }
@@ -330,7 +330,7 @@
       if (VERBOSE) {
         System.out.println("\nTEST: done adding indices; now close");
       }
-      w.close();
+      w.shutdown();
       
       targetDir.close();
     }
@@ -344,7 +344,7 @@
       IndexWriter w = new IndexWriter(targetDir, newIndexWriterConfig(
           TEST_VERSION_CURRENT, new MockAnalyzer(random())));
       w.addIndexes(reader);
-      w.close();
+      w.shutdown();
       reader.close();
             
       targetDir.close();
@@ -546,7 +546,7 @@
       expected = 45;
     }
     assertEquals("wrong doc count", expected, writer.numDocs());
-    writer.close();
+    writer.shutdown();
 
     // make sure searching sees right # hits
     IndexReader reader = DirectoryReader.open(dir);
@@ -560,7 +560,7 @@
     // fully merge
     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);
     searcher = newSearcher(reader);
@@ -585,7 +585,7 @@
     // fully merge
     IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random)).setOpenMode(OpenMode.APPEND));
     writer.forceMerge(1);
-    writer.close();
+    writer.shutdown();
 
     reader = DirectoryReader.open(dir);
     searcher = newSearcher(reader);
@@ -615,7 +615,7 @@
     if (fullyMerged) {
       writer.forceMerge(1);
     }
-    writer.close();
+    writer.shutdown();
 
     if (!fullyMerged) {
       // open fresh writer so we get no prx file in the added segment
@@ -626,14 +626,14 @@
         .setMaxBufferedDocs(10).setMergePolicy(mp);
       writer = new IndexWriter(dir, conf);
       addNoProxDoc(writer);
-      writer.close();
+      writer.shutdown();
 
       writer = new IndexWriter(dir,
         conf.setMergePolicy(doCFS ? NoMergePolicy.COMPOUND_FILES : NoMergePolicy.NO_COMPOUND_FILES)
       );
       Term searchTerm = new Term("id", "7");
       writer.deleteDocuments(searchTerm);
-      writer.close();
+      writer.shutdown();
     }
     
     dir.close();
@@ -669,7 +669,7 @@
         addDoc(writer, i);
       }
       assertEquals("wrong doc count", 35, writer.maxDoc());
-      writer.close();
+      writer.shutdown();
 
       // Delete one doc so we get a .del file:
       writer = new IndexWriter(
@@ -679,7 +679,7 @@
       );
       Term searchTerm = new Term("id", "7");
       writer.deleteDocuments(searchTerm);
-      writer.close();
+      writer.shutdown();
 
       // Now verify file names... TODO: fix this test better, we could populate from 
       // separateFiles() or something.
@@ -848,7 +848,7 @@
     Directory currentDir = newDirectory();
     RandomIndexWriter riw = new RandomIndexWriter(random(), currentDir);
     riw.addDocument(new Document());
-    riw.close();
+    riw.shutdown();
     DirectoryReader ir = DirectoryReader.open(currentDir);
     SegmentReader air = (SegmentReader)ir.leaves().get(0).reader();
     String currentVersion = air.getSegmentInfo().info.getVersion();
@@ -1021,7 +1021,7 @@
         for(int j = 0; j < RANDOM_MULTIPLIER * random().nextInt(30); j++) {
           addDoc(w, id++);
         }
-        w.close(false);
+        w.shutdown(false);
       }
       
       // add dummy segments (which are all in current
@@ -1031,7 +1031,7 @@
         .setMergePolicy(mp);
       IndexWriter w = new IndexWriter(dir, iwc);
       w.addIndexes(ramDir);
-      w.close(false);
+      w.shutdown(false);
       
       // determine count of segments in modified index
       final int origSegCount = getNumberOfSegments(dir);
Index: lucene/core/src/test/org/apache/lucene/index/TestIndexWriterUnicode.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestIndexWriterUnicode.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestIndexWriterUnicode.java	(working copy)
@@ -243,7 +243,7 @@
     IndexReader r = w.getReader();
     assertEquals(1, r.docFreq(new Term("field", "a\uffffb")));
     r.close();
-    w.close();
+    w.shutdown();
     d.close();
   }
 
@@ -257,7 +257,7 @@
     for(int i=0;i<count;i++)
       doc.add(newTextField("f" + i, utf8Data[2*i], Field.Store.YES));
     w.addDocument(doc);
-    w.close();
+    w.shutdown();
 
     IndexReader ir = DirectoryReader.open(dir);
     StoredDocument doc2 = ir.document(0);
@@ -331,7 +331,7 @@
     checkTermsOrder(r, allTerms, true);
     r.close();
 
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
 }
Index: lucene/core/src/test/org/apache/lucene/index/TestDirectoryReader.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestDirectoryReader.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestDirectoryReader.java	(working copy)
@@ -133,7 +133,7 @@
     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 @@
     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 @@
     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 @@
       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 @@
         writer.addDocument(doc);
       }
       
-      writer.close();
+      writer.shutdown();
 
       // verify fields again
       reader = DirectoryReader.open(d);
@@ -342,7 +342,7 @@
       
       writer.addDocument(doc);
   }
-  writer.close();
+  writer.shutdown();
   d.close();
 }
 
@@ -379,13 +379,13 @@
       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 @@
 
     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 @@
       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 @@
       // 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 @@
     );
     for(int i=0;i<27;i++)
       addDocumentWithFields(writer);
-    writer.close();
+    writer.shutdown();
 
     SegmentInfos sis = new SegmentInfos();
     sis.read(d);
@@ -677,7 +677,7 @@
     );
     for(int i=0;i<7;i++)
       addDocumentWithFields(writer);
-    writer.close();
+    writer.shutdown();
 
     DirectoryReader r2 = DirectoryReader.openIfChanged(r);
     assertNotNull(r2);
@@ -689,7 +689,7 @@
       new MockAnalyzer(random()))
       .setOpenMode(OpenMode.APPEND));
     writer.forceMerge(1);
-    writer.close();
+    writer.shutdown();
 
     r2 = DirectoryReader.openIfChanged(r);
     assertNotNull(r2);
@@ -738,7 +738,7 @@
     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 @@
     r2.close();
     assertTrue(ints == ints2);
   
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
   
@@ -817,7 +817,7 @@
       assertEquals(10, s.reader().terms("number").size());
     }
     r2.close();
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
   
@@ -838,7 +838,7 @@
     assertNull(r2);
     writer.commit();
     assertFalse(r.isCurrent());
-    writer.close();
+    writer.shutdown();
     r.close();
     dir.close();
   }
@@ -858,7 +858,7 @@
     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 @@
     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 @@
     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 @@
     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 @@
     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 @@
   
     // 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 @@
     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 @@
     r.decRef();
     r.close();
     assertFalse(r.tryIncRef());
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
   
@@ -1042,7 +1042,7 @@
       assertNull(threads[i].failed);
     }
     assertFalse(r.tryIncRef());
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
   
@@ -1078,7 +1078,7 @@
     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");
Index: lucene/core/src/test/org/apache/lucene/index/TestFlex.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestFlex.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestFlex.java	(working copy)
@@ -58,7 +58,7 @@
       r.close();
     }
 
-    w.close();
+    w.shutdown();
     d.close();
   }
 
@@ -79,7 +79,7 @@
       // ok -- codec is not required to support this op
     }
     r.close();
-    w.close();
+    w.shutdown();
     d.close();
   }
 }
Index: lucene/core/src/test/org/apache/lucene/index/TestBinaryTerms.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestBinaryTerms.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestBinaryTerms.java	(working copy)
@@ -53,7 +53,7 @@
     }
     
     IndexReader ir = iw.getReader();
-    iw.close();
+    iw.shutdown();
     
     IndexSearcher is = newSearcher(ir);
     
Index: lucene/core/src/test/org/apache/lucene/index/TestMaxTermFrequency.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestMaxTermFrequency.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestMaxTermFrequency.java	(working copy)
@@ -57,7 +57,7 @@
       writer.addDocument(doc);
     }
     reader = writer.getReader();
-    writer.close();
+    writer.shutdown();
   }
   
   @Override
Index: lucene/core/src/test/org/apache/lucene/index/TestMultiDocValues.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestMultiDocValues.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestMultiDocValues.java	(working copy)
@@ -57,7 +57,7 @@
     iw.forceMerge(1);
     DirectoryReader ir2 = iw.getReader();
     AtomicReader merged = getOnlySegmentReader(ir2);
-    iw.close();
+    iw.shutdown();
     
     NumericDocValues multi = MultiDocValues.getNumericValues(ir, "numbers");
     NumericDocValues single = merged.getNumericDocValues("numbers");
@@ -92,7 +92,7 @@
     iw.forceMerge(1);
     DirectoryReader ir2 = iw.getReader();
     AtomicReader merged = getOnlySegmentReader(ir2);
-    iw.close();
+    iw.shutdown();
     
     BinaryDocValues multi = MultiDocValues.getBinaryValues(ir, "bytes");
     BinaryDocValues single = merged.getBinaryDocValues("bytes");
@@ -134,7 +134,7 @@
     iw.forceMerge(1);
     DirectoryReader ir2 = iw.getReader();
     AtomicReader merged = getOnlySegmentReader(ir2);
-    iw.close();
+    iw.shutdown();
     
     SortedDocValues multi = MultiDocValues.getSortedValues(ir, "bytes");
     SortedDocValues single = merged.getSortedDocValues("bytes");
@@ -178,7 +178,7 @@
     iw.forceMerge(1);
     DirectoryReader ir2 = iw.getReader();
     AtomicReader merged = getOnlySegmentReader(ir2);
-    iw.close();
+    iw.shutdown();
     
     SortedDocValues multi = MultiDocValues.getSortedValues(ir, "bytes");
     SortedDocValues single = merged.getSortedDocValues("bytes");
@@ -222,7 +222,7 @@
     iw.forceMerge(1);
     DirectoryReader ir2 = iw.getReader();
     AtomicReader merged = getOnlySegmentReader(ir2);
-    iw.close();
+    iw.shutdown();
     
     SortedSetDocValues multi = MultiDocValues.getSortedSetValues(ir, "bytes");
     SortedSetDocValues single = merged.getSortedSetDocValues("bytes");
@@ -287,7 +287,7 @@
     iw.forceMerge(1);
     DirectoryReader ir2 = iw.getReader();
     AtomicReader merged = getOnlySegmentReader(ir2);
-    iw.close();
+    iw.shutdown();
     
     SortedSetDocValues multi = MultiDocValues.getSortedSetValues(ir, "bytes");
     SortedSetDocValues single = merged.getSortedSetDocValues("bytes");
@@ -351,7 +351,7 @@
     iw.forceMerge(1);
     DirectoryReader ir2 = iw.getReader();
     AtomicReader merged = getOnlySegmentReader(ir2);
-    iw.close();
+    iw.shutdown();
     
     Bits multi = MultiDocValues.getDocsWithField(ir, "numbers");
     Bits single = merged.getDocsWithField("numbers");
Index: lucene/core/src/test/org/apache/lucene/index/TestIndexWriterWithThreads.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestIndexWriterWithThreads.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestIndexWriterWithThreads.java	(working copy)
@@ -163,7 +163,7 @@
       // Make sure once disk space is avail again, we can
       // cleanly close:
       dir.setMaxSizeInBytes(0);
-      writer.close(false);
+      writer.shutdown(false);
       dir.close();
     }
   }
@@ -215,7 +215,7 @@
       if (VERBOSE) {
         System.out.println("\nTEST: now close");
       }
-      writer.close(false);
+      writer.shutdown(false);
 
       // Make sure threads that are adding docs are not hung:
       for(int i=0;i<NUM_THREADS;i++) {
@@ -286,11 +286,11 @@
 
       boolean success = false;
       try {
-        writer.close(false);
+        writer.shutdown(false);
         success = true;
       } catch (IOException ioe) {
         failure.clearDoFail();
-        writer.close(false);
+        writer.shutdown(false);
       }
       if (VERBOSE) {
         System.out.println("TEST: success=" + success);
@@ -340,7 +340,7 @@
     }
     failure.clearDoFail();
     writer.addDocument(doc);
-    writer.close(false);
+    writer.shutdown(false);
     dir.close();
   }
 
@@ -528,7 +528,7 @@
         iwConstructed.countDown();
         startIndexing.await();
         writer.addDocument(doc);
-        writer.close();
+        writer.shutdown();
       } catch (Throwable e) {
         failed = true;
         failure = e;
@@ -630,7 +630,7 @@
     }
 
     assertTrue(!failed.get());
-    writerRef.get().close();
+    writerRef.get().shutdown();
     d.close();
   }
 }
Index: lucene/core/src/test/org/apache/lucene/index/TestIndexWriterCommit.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestIndexWriterCommit.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestIndexWriterCommit.java	(working copy)
@@ -46,7 +46,7 @@
       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 @@
       }
 
       // 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 @@
     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 @@
       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 @@
     for(int j=0;j<30;j++) {
       TestIndexWriter.addDocWithIndex(writer, j);
     }
-    writer.close();
+    writer.shutdown();
     dir.resetMaxUsedSizeInBytes();
 
     dir.setTrackDiskUsage(true);
@@ -233,7 +233,7 @@
     long midDiskUsage = dir.getMaxUsedSizeInBytes();
     dir.resetMaxUsedSizeInBytes();
     writer.forceMerge(1);
-    writer.close();
+    writer.shutdown();
 
     DirectoryReader.open(dir).close();
 
@@ -275,7 +275,7 @@
     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 @@
     }
     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 @@
       threads[i].join();
     }
     assertFalse(failed.get());
-    w.close();
+    w.shutdown();
     dir.close();
   }
 
@@ -413,7 +413,7 @@
     reader = DirectoryReader.open(dir);
     assertEquals(40, reader.numDocs());
     reader.close();
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
   
@@ -434,7 +434,7 @@
     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 @@
     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 @@
       // 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 @@
     reader = DirectoryReader.open(dir);
     assertEquals(40, reader.numDocs());
     reader.close();
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
 
@@ -598,7 +598,7 @@
     reader = DirectoryReader.open(dir);
     assertEquals(17, reader.numDocs());
     reader.close();
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
 
@@ -609,7 +609,7 @@
     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 @@
     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 @@
     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 @@
 
     w = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random())));
     w.forceMerge(1);
-    w.close();
+    w.shutdown();
 
     dir.close();
   }
Index: lucene/core/src/test/org/apache/lucene/index/TestNoDeletionPolicy.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestNoDeletionPolicy.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestNoDeletionPolicy.java	(working copy)
@@ -80,7 +80,7 @@
       writer.commit();
       assertEquals("wrong number of commits !", i + 1, DirectoryReader.listCommits(dir).size());
     }
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
   
Index: lucene/core/src/test/org/apache/lucene/index/TestCompoundFile.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestCompoundFile.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestCompoundFile.java	(working copy)
@@ -820,7 +820,7 @@
         riw.commit();
       }
     }
-    riw.close();
+    riw.shutdown();
     checkFiles(dir);
     dir.close();
   }
Index: lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java	(working copy)
@@ -27,6 +27,7 @@
 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.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 @@
             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 @@
         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 @@
         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 @@
       // 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 @@
       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 @@
         addDoc(writer);
 
         // close
-        writer.close();
+        writer.shutdown();
         try {
           addDoc(writer);
           fail("did not hit AlreadyClosedException");
@@ -235,7 +238,7 @@
       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 @@
 
       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 @@
         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 @@
         assertTrue(numFile > lastNumFile);
         lastNumFile = numFile;
       }
-      writer.close();
+      writer.shutdown();
       dir.close();
     }
 
@@ -358,7 +361,7 @@
           assertTrue(flushCount > lastFlushCount);
         }
       }
-      writer.close();
+      writer.shutdown();
       dir.close();
     }
 
@@ -419,7 +422,7 @@
           assertTrue(flushCount > lastFlushCount);
         }
       }
-      writer.close();
+      writer.shutdown();
       dir.close();
     }
 
@@ -461,7 +464,7 @@
           writer.addDocument(doc);
         }
       }
-      writer.close();
+      writer.shutdown();
 
       IndexReader reader = DirectoryReader.open(dir);
       IndexSearcher searcher = newSearcher(reader);
@@ -490,7 +493,7 @@
         doc.add(f);
         writer.addDocument(doc);
       }
-      writer.close();
+      writer.shutdown();
 
       Term searchTerm = new Term("field", "aaa");
 
@@ -515,7 +518,7 @@
         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 @@
       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 @@
       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 @@
 
       writer = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random()))
         .setOpenMode(OpenMode.CREATE));
-      writer.close();
+      writer.shutdown();
       dir.close();
     }
 
@@ -623,7 +626,7 @@
       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 @@
         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 @@
     customType.setStoreTermVectors(true);
     document.add(newField("tvtest", "", customType));
     iw.addDocument(document);
-    iw.close();
+    iw.shutdown();
     dir.close();
   }
 
@@ -694,7 +697,7 @@
       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 @@
       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 @@
     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 @@
     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 @@
     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 @@
     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 @@
     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 @@
     } catch (IllegalArgumentException iea) {
       // expected
     }
-    w.close();
+    w.shutdown();
     dir.close();
   }
 
@@ -920,7 +923,7 @@
     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 @@
     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 @@
       }
       w.addDocument(doc);
       w.deleteDocuments(new Term("id", "500"));
-      w.close();
+      w.shutdown();
     }
 
     @Override
@@ -1027,10 +1030,10 @@
       // 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 @@
               // 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 @@
                 w.forceMerge(1);
               }
             }
-            w.close();
+            w.shutdown();
             w = null;
             DirectoryReader.open(dir).close();
 
@@ -1133,6 +1141,9 @@
         }
       }
 
+      if (VERBOSE) {
+        System.out.println("TEST: now finish failed=" + failed);
+      }
       if (!failed) {
         if (VERBOSE) {
           System.out.println("TEST: now rollback");
@@ -1299,7 +1310,7 @@
     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 @@
     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 @@
       }
       //assertTrue(files.contains("_2.cfs"));
 
-      w.close();
+      w.shutdown();
       r2.close();
 
       dir.close();
@@ -1469,7 +1480,7 @@
     writer.deleteUnusedFiles();
     assertEquals(1, DirectoryReader.listCommits(dir).size());
 
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
 
@@ -1478,7 +1489,7 @@
     // then IndexWriter ctor succeeds. Previously (LUCENE-2386) it failed
     // when listAll() was called in IndexFileDeleter.
     Directory dir = newFSDirectory(TestUtil.getTempDir("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 @@
         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 @@
       indexWriter.addDocument(doc);
     }
 
-    indexWriter.close();
+    indexWriter.shutdown();
 
     TestUtil.checkIndex(dir);
 
@@ -1685,7 +1696,7 @@
     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 @@
     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 @@
       assertTrue(d.listAll().length <= 2);
     }
 
-    w.close();
+    w.shutdown();
     d.close();
   }
 
@@ -1776,7 +1787,7 @@
 
     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 @@
     } catch (LockObtainFailedException lofe) {
       // expected
     }
-    w1.close();
+    w1.shutdown();
     d.close();
   }
 
@@ -1820,7 +1831,7 @@
     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 @@
     docs.add(new Document());
     w.updateDocuments(new Term("foo", "bar"),
                       docs);
-    w.close();
+    w.shutdown();
     dir.close();
   }
 
@@ -1845,13 +1856,13 @@
 
     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 @@
     doc.add(f2);
     doc.add(f);
     w.addDocument(doc);
-    w.close();
+    w.shutdown();
     dir.close();
   }
   
@@ -1931,14 +1942,14 @@
     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 @@
     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 @@
     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 @@
     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(TestUtil.getTempDir("TestIndexWriter.testChangingFields"));
@@ -2073,7 +2058,7 @@
         upto = 0;
       }
     }
-    w.close();
+    w.shutdown();
     dir.close();
   }
   
@@ -2115,7 +2100,7 @@
         "value2", r.getIndexCommit().getUserData().get("key"));
     r.close();
     
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
   
@@ -2127,12 +2112,12 @@
       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 @@
       }
     }
     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 @@
 
       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 @@
     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 @@
     }
     evilWriter.deleteDocuments(new MatchAllDocsQuery());
     evilWriter.forceMerge(1);
-    evilWriter.close();
+    evilWriter.shutdown();
     dir.close();
   }
 
@@ -2365,7 +2351,7 @@
     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 @@
     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 {
 
Index: lucene/core/src/test/org/apache/lucene/index/TestStressIndexing.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestStressIndexing.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestStressIndexing.java	(working copy)
@@ -149,7 +149,7 @@
     for(int i=0;i<numThread;i++)
       threads[i].join();
 
-    modifier.close();
+    modifier.shutdown();
 
     for(int i=0;i<numThread;i++)
       assertTrue(! threads[i].failed);
Index: lucene/core/src/test/org/apache/lucene/index/TestPayloads.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestPayloads.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestPayloads.java	(working copy)
@@ -76,7 +76,7 @@
         analyzer.setPayloadData("f2", "somedata".getBytes(StandardCharsets.UTF_8), 0, 1);
         writer.addDocument(d);
         // flush
-        writer.close();
+        writer.shutdown();
 
       SegmentReader reader = getOnlySegmentReader(DirectoryReader.open(ram));
         FieldInfos fi = reader.getFieldInfos();
@@ -103,7 +103,7 @@
         // force merge
         writer.forceMerge(1);
         // flush
-        writer.close();
+        writer.shutdown();
 
       reader = getOnlySegmentReader(DirectoryReader.open(ram));
         fi = reader.getFieldInfos();
@@ -173,7 +173,7 @@
         
         writer.forceMerge(1);
         // flush
-        writer.close();
+        writer.shutdown();
         
         
         /*
@@ -278,7 +278,7 @@
         
         writer.forceMerge(1);
         // flush
-        writer.close();
+        writer.shutdown();
         
         reader = DirectoryReader.open(dir);
         tp = MultiFields.getTermPositionsEnum(reader,
@@ -479,7 +479,7 @@
         for (int i = 0; i < numThreads; i++) {
           ingesters[i].join();
         }
-        writer.close();
+        writer.shutdown();
         IndexReader reader = DirectoryReader.open(dir);
         TermsEnum terms = MultiFields.getFields(reader).terms(field).iterator(null);
         Bits liveDocs = MultiFields.getLiveDocs(reader);
@@ -567,7 +567,7 @@
     Document doc = new Document();
     doc.add(new TextField("hasMaybepayload", "here we go", Field.Store.YES));
     writer.addDocument(doc);
-    writer.close();
+    writer.shutdown();
 
     writer = new RandomIndexWriter(random(), dir,
                                    new MockAnalyzer(random(), MockTokenizer.WHITESPACE, true));
@@ -576,7 +576,7 @@
     writer.addDocument(doc);
     writer.addDocument(doc);
     writer.forceMerge(1);
-    writer.close();
+    writer.shutdown();
 
     dir.close();
   }
@@ -612,7 +612,7 @@
     de.nextDoc();
     de.nextPosition();
     assertEquals(new BytesRef("test"), de.getPayload());
-    writer.close();
+    writer.shutdown();
     reader.close();
     dir.close();
   }
@@ -649,7 +649,7 @@
     de.nextDoc();
     de.nextPosition();
     assertEquals(new BytesRef("test"), de.getPayload());
-    writer.close();
+    writer.shutdown();
     reader.close();
     dir.close();
   }
Index: lucene/core/src/test/org/apache/lucene/index/TestMultiFields.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestMultiFields.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestMultiFields.java	(working copy)
@@ -106,7 +106,7 @@
       }
 
       IndexReader reader = w.getReader();
-      w.close();
+      w.shutdown();
       if (VERBOSE) {
         System.out.println("TEST: reader=" + reader);
       }
@@ -162,7 +162,7 @@
     w.commit();
     w.addDocument(d);
     IndexReader r = w.getReader();
-    w.close();
+    w.shutdown();
     DocsEnum d1 = TestUtil.docs(random(), r, "f", new BytesRef("j"), null, null, DocsEnum.FLAG_NONE);
     DocsEnum d2 = TestUtil.docs(random(), r, "f", new BytesRef("j"), null, null, DocsEnum.FLAG_NONE);
     assertEquals(0, d1.nextDoc());
@@ -180,7 +180,7 @@
     w.commit();
     w.addDocument(d);
     IndexReader r = w.getReader();
-    w.close();
+    w.shutdown();
     DocsEnum de = MultiFields.getTermDocsEnum(r, null, "f", new BytesRef("j"));
     assertEquals(0, de.nextDoc());
     assertEquals(1, de.nextDoc());
Index: lucene/core/src/test/org/apache/lucene/index/TestDeletionPolicy.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestDeletionPolicy.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestDeletionPolicy.java	(working copy)
@@ -232,7 +232,7 @@
     commitData.put("commitTime", String.valueOf(System.currentTimeMillis()));
     writer.setCommitData(commitData);
     writer.commit();
-    writer.close();
+    writer.shutdown();
 
     long lastDeleteTime = 0;
     final int targetNumDelete = TestUtil.nextInt(random(), 1, 5);
@@ -254,7 +254,7 @@
       commitData.put("commitTime", String.valueOf(System.currentTimeMillis()));
       writer.setCommitData(commitData);
       writer.commit();
-      writer.close();
+      writer.shutdown();
 
       Thread.sleep((int) (1000.0*(SECONDS/5.0)));
     }
@@ -328,7 +328,7 @@
       for(int i=0;i<107;i++) {
         addDoc(writer);
       }
-      writer.close();
+      writer.shutdown();
 
       final boolean needsMerging;
       {
@@ -348,7 +348,7 @@
         writer = new IndexWriter(dir, conf);
         policy = (KeepAllDeletionPolicy) writer.getConfig().getIndexDeletionPolicy();
         writer.forceMerge(1);
-        writer.close();
+        writer.shutdown();
       }
 
       assertEquals(needsMerging ? 2:1, policy.numOnInit);
@@ -388,7 +388,7 @@
               TEST_VERSION_CURRENT,
               new MockAnalyzer(random())).setOpenMode(
               OpenMode.APPEND).setIndexDeletionPolicy(policy));
-          writer.close();
+          writer.shutdown();
           int postCount = dir.listAll().length;
           assertTrue(postCount < preCount);
         }
@@ -417,7 +417,7 @@
       if ((1+i)%2 == 0)
         writer.commit();
     }
-    writer.close();
+    writer.shutdown();
 
     Collection<IndexCommit> commits = DirectoryReader.listCommits(dir);
     assertEquals(5, commits.size());
@@ -433,7 +433,7 @@
     addDoc(writer);
     assertEquals(11, writer.numDocs());
     writer.forceMerge(1);
-    writer.close();
+    writer.shutdown();
 
     assertEquals(6, DirectoryReader.listCommits(dir).size());
 
@@ -455,7 +455,7 @@
         .setIndexDeletionPolicy(policy).setIndexCommit(lastCommit));
     assertEquals(10, writer.numDocs());
     // Commits the rollback:
-    writer.close();
+    writer.shutdown();
 
     // Now 8 because we made another commit
     assertEquals(7, DirectoryReader.listCommits(dir).size());
@@ -470,7 +470,7 @@
     // Re-merge
     writer = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())).setIndexDeletionPolicy(policy));
     writer.forceMerge(1);
-    writer.close();
+    writer.shutdown();
 
     r = DirectoryReader.open(dir);
     assertEquals(1, r.leaves().size());
@@ -489,7 +489,7 @@
     assertEquals(10, r.numDocs());
     r.close();
 
-    writer.close();
+    writer.shutdown();
 
     // Now reader sees not-fully-merged index:
     r = DirectoryReader.open(dir);
@@ -524,7 +524,7 @@
       for(int i=0;i<107;i++) {
         addDoc(writer);
       }
-      writer.close();
+      writer.shutdown();
 
       conf = newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()))
           .setOpenMode(OpenMode.APPEND).setIndexDeletionPolicy(policy);
@@ -533,7 +533,7 @@
       writer = new IndexWriter(dir, conf);
       policy = (KeepNoneOnInitDeletionPolicy) writer.getConfig().getIndexDeletionPolicy();
       writer.forceMerge(1);
-      writer.close();
+      writer.shutdown();
 
       assertEquals(2, policy.numOnInit);
       // If we are not auto committing then there should
@@ -576,7 +576,7 @@
           addDoc(writer);
         }
         writer.forceMerge(1);
-        writer.close();
+        writer.shutdown();
       }
 
       assertTrue(policy.numDelete > 0);
@@ -631,7 +631,7 @@
       mp.setNoCFSRatio(useCompoundFile ? 1.0 : 0.0);
       IndexWriter writer = new IndexWriter(dir, conf);
       KeepLastNDeletionPolicy policy = (KeepLastNDeletionPolicy) writer.getConfig().getIndexDeletionPolicy();
-      writer.close();
+      writer.shutdown();
       Term searchTerm = new Term("content", "aaa");        
       Query query = new TermQuery(searchTerm);
 
@@ -649,7 +649,7 @@
           addDocWithID(writer, i*(N+1)+j);
         }
         // this is a commit
-        writer.close();
+        writer.shutdown();
         conf = new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()))
           .setIndexDeletionPolicy(policy)
           .setMergePolicy(NoMergePolicy.COMPOUND_FILES);
@@ -657,7 +657,7 @@
         policy = (KeepLastNDeletionPolicy) writer.getConfig().getIndexDeletionPolicy();
         writer.deleteDocuments(new Term("id", "" + (i*(N+1)+3)));
         // this is a commit
-        writer.close();
+        writer.shutdown();
         IndexReader reader = DirectoryReader.open(dir);
         IndexSearcher searcher = newSearcher(reader);
         ScoreDoc[] hits = searcher.search(query, null, 1000).scoreDocs;
@@ -670,7 +670,7 @@
         policy = (KeepLastNDeletionPolicy) writer.getConfig().getIndexDeletionPolicy();
         // This will not commit: there are no changes
         // pending because we opened for "create":
-        writer.close();
+        writer.shutdown();
       }
 
       assertEquals(3*(N+1)+1, policy.numOnInit);
Index: lucene/core/src/test/org/apache/lucene/index/TestFlushByRamOrCountsPolicy.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestFlushByRamOrCountsPolicy.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestFlushByRamOrCountsPolicy.java	(working copy)
@@ -111,7 +111,7 @@
     if (ensureNotStalled) {
       assertFalse(docsWriter.flushControl.stallControl.wasStalled());
     }
-    writer.close();
+    writer.shutdown();
     assertEquals(0, flushControl.activeBytes());
     dir.close();
   }
@@ -162,7 +162,7 @@
       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 @@
       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 @@
         assertTrue(docsWriter.flushControl.stallControl.wasStalled());
       }
       assertActiveBytesAfter(flushControl);
-      writer.close(true);
+      writer.shutdown();
       dir.close();
     }
   }
Index: lucene/core/src/test/org/apache/lucene/index/Test2BSortedDocValues.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/Test2BSortedDocValues.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/Test2BSortedDocValues.java	(working copy)
@@ -68,7 +68,7 @@
     }
     
     w.forceMerge(1);
-    w.close();
+    w.shutdown();
     
     System.out.println("verifying...");
     System.out.flush();
@@ -127,7 +127,7 @@
     }
     
     w.forceMerge(1);
-    w.close();
+    w.shutdown();
     
     System.out.println("verifying...");
     System.out.flush();
Index: lucene/core/src/test/org/apache/lucene/index/TestSnapshotDeletionPolicy.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestSnapshotDeletionPolicy.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestSnapshotDeletionPolicy.java	(working copy)
@@ -177,7 +177,7 @@
 
     // Make sure we don't have any leftover files in the
     // directory:
-    writer.close();
+    writer.shutdown();
     TestIndexWriter.assertNoUnreferencedFiles(dir, "some files were not deleted but should have been");
   }
 
@@ -254,7 +254,7 @@
     IndexWriter writer = new IndexWriter(dir, getConfig(random(), getDeletionPolicy()));
     SnapshotDeletionPolicy sdp = (SnapshotDeletionPolicy) writer.getConfig().getIndexDeletionPolicy();
     prepareIndexAndSnapshots(sdp, writer, numSnapshots);
-    writer.close();
+    writer.shutdown();
     
     assertEquals(numSnapshots, sdp.getSnapshots().size());
     assertEquals(numSnapshots, sdp.getSnapshotCount());
@@ -267,7 +267,7 @@
     sdp = getDeletionPolicy();
     writer = new IndexWriter(dir, getConfig(random(), sdp));
     writer.deleteUnusedFiles();
-    writer.close();
+    writer.shutdown();
     assertEquals("no snapshots should exist", 1, DirectoryReader.listCommits(dir).size());
     dir.close();
   }
@@ -314,7 +314,7 @@
       writer.deleteUnusedFiles();
     }
     assertEquals(1, DirectoryReader.listCommits(dir).size());
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
 
@@ -326,7 +326,7 @@
     SnapshotDeletionPolicy sdp = getDeletionPolicy();
     IndexWriter writer = new IndexWriter(dir, getConfig(random(), sdp));
     prepareIndexAndSnapshots(sdp, writer, numSnapshots);
-    writer.close();
+    writer.shutdown();
 
     // now open the writer on "snapshot0" - make sure it succeeds
     writer = new IndexWriter(dir, getConfig(random(), sdp).setIndexCommit(snapshots.get(0)));
@@ -334,7 +334,7 @@
     writer.commit();
     writer.deleteUnusedFiles();
     assertSnapshotExists(dir, sdp, numSnapshots - 1, false);
-    writer.close();
+    writer.shutdown();
 
     // but 'snapshot1' files will still exist (need to release snapshot before they can be deleted).
     String segFileName = snapshots.get(1).getSegmentsFileName();
@@ -359,7 +359,7 @@
     String segFileName = snapshots.get(0).getSegmentsFileName();
     sdp.release(snapshots.get(0));
     writer.deleteUnusedFiles();
-    writer.close();
+    writer.shutdown();
     assertFalse("segments file should not be found in dirctory: " + segFileName, slowFileExists(dir, segFileName));
     dir.close();
   }
@@ -386,7 +386,7 @@
     writer.deleteUnusedFiles();
     checkSnapshotExists(dir, s2);
     
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
   
@@ -403,11 +403,11 @@
 
     // create another commit, not snapshotted.
     writer.addDocument(new Document());
-    writer.close();
+    writer.shutdown();
 
     // open a new writer w/ KeepOnlyLastCommit policy, so it will delete "s1"
     // commit.
-    new IndexWriter(dir, getConfig(random(), null)).close();
+    new IndexWriter(dir, getConfig(random(), null)).shutdown();
     
     assertFalse("snapshotted commit should not exist", slowFileExists(dir, s1.getSegmentsFileName()));
     dir.close();
Index: lucene/core/src/test/org/apache/lucene/index/TestStressNRT.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestStressNRT.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestStressNRT.java	(working copy)
@@ -390,7 +390,7 @@
       thread.join();
     }
 
-    writer.close();
+    writer.shutdown();
     if (VERBOSE) {
       System.out.println("TEST: close reader=" + reader);
     }
Index: lucene/core/src/test/org/apache/lucene/index/TestMixedCodecs.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestMixedCodecs.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestMixedCodecs.java	(working copy)
@@ -53,7 +53,7 @@
           iwc.setCodec(Codec.forName("SimpleText"));
         }
         if (w != null) {
-          w.close();
+          w.shutdown();
         }
         w = new RandomIndexWriter(random(), dir, iwc);
         docsLeftInThisSegment = TestUtil.nextInt(random(), 10, 100);
@@ -84,7 +84,7 @@
       }
     }
 
-    w.close();
+    w.shutdown();
     dir.close();
   }
 }
Index: lucene/core/src/test/org/apache/lucene/index/Test2BPostings.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/Test2BPostings.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/Test2BPostings.java	(working copy)
@@ -80,7 +80,7 @@
       }
     }
     w.forceMerge(1);
-    w.close();
+    w.shutdown();
     dir.close();
   }
   
Index: lucene/core/src/test/org/apache/lucene/index/TestCheckIndex.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestCheckIndex.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestCheckIndex.java	(working copy)
@@ -52,7 +52,7 @@
     writer.forceMerge(1);
     writer.commit();
     writer.deleteDocuments(new Term("field","aaa5"));
-    writer.close();
+    writer.shutdown();
 
     ByteArrayOutputStream bos = new ByteArrayOutputStream(1024);
     CheckIndex checker = new CheckIndex(dir);
@@ -112,7 +112,7 @@
     ));
     doc.add(field);
     iw.addDocument(doc);
-    iw.close();
+    iw.shutdown();
     dir.close(); // checkindex
   }
 }
Index: lucene/core/src/test/org/apache/lucene/index/TestIndexFileDeleter.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestIndexFileDeleter.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestIndexFileDeleter.java	(working copy)
@@ -66,7 +66,7 @@
     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 @@
     );
     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 @@
     // 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();
Index: lucene/core/src/test/org/apache/lucene/index/Test2BTerms.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/Test2BTerms.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/Test2BTerms.java	(working copy)
@@ -195,7 +195,7 @@
       System.out.println("TEST: full merge");
       w.forceMerge(1);
       System.out.println("TEST: close writer");
-      w.close();
+      w.shutdown();
     }
 
     System.out.println("TEST: open reader");
Index: lucene/core/src/test/org/apache/lucene/index/TestPayloadsOnVectors.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestPayloadsOnVectors.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestPayloadsOnVectors.java	(working copy)
@@ -78,7 +78,7 @@
     assertEquals(0, de.nextDoc());
     assertEquals(0, de.nextPosition());
     assertEquals(new BytesRef("test"), de.getPayload());
-    writer.close();
+    writer.shutdown();
     reader.close();
     dir.close();
   }
@@ -122,7 +122,7 @@
     assertEquals(0, de.nextDoc());
     assertEquals(3, de.nextPosition());
     assertEquals(new BytesRef("test"), de.getPayload());
-    writer.close();
+    writer.shutdown();
     reader.close();
     dir.close();
   }
@@ -143,7 +143,7 @@
     } catch (IllegalArgumentException expected) {
       // expected
     }
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
 
Index: lucene/core/src/test/org/apache/lucene/index/TestPostingsOffsets.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestPostingsOffsets.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestPostingsOffsets.java	(working copy)
@@ -80,7 +80,7 @@
 
     w.addDocument(doc);
     IndexReader r = w.getReader();
-    w.close();
+    w.shutdown();
 
     DocsAndPositionsEnum dp = MultiFields.getTermPositionsEnum(r, null, "content", new BytesRef("a"));
     assertNotNull(dp);
@@ -149,7 +149,7 @@
     }
     
     IndexReader reader = w.getReader();
-    w.close();
+    w.shutdown();
     
     String terms[] = { "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "hundred" };
     
@@ -285,7 +285,7 @@
       w.addDocument(doc);
     }
     final DirectoryReader r = w.getReader();
-    w.close();
+    w.shutdown();
 
     final String[] terms = new String[] {"a", "b", "c", "d"};
     for(AtomicReaderContext ctx : r.leaves()) {
@@ -382,7 +382,7 @@
     assertEquals(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS, fis.fieldInfo("foo").getIndexOptions());
     slow.close();
     ir.close();
-    riw.close();
+    riw.shutdown();
     dir.close();
   }
   
@@ -398,7 +398,7 @@
     doc.add(new Field("content3", "here is more content with aaa aaa aaa", customType3));
     doc.add(new Field("content3", "here is more content with aaa aaa aaa", customType3));
     iw.addDocument(doc);
-    iw.close();
+    iw.shutdown();
     dir.close(); // checkindex
   }
   
@@ -467,7 +467,7 @@
     Field field = new Field("foo", tokenStream, ft);
     doc.add(field);
     iw.addDocument(doc);
-    iw.close();
+    iw.shutdown();
     dir.close();
   }
   // TODO: more tests with other possibilities
@@ -487,10 +487,11 @@
       Document doc = new Document();
       doc.add(new Field("body", new CannedTokenStream(tokens), ft));
       riw.addDocument(doc);
+      riw.shutdown();
       success = true;
     } finally {
       if (success) {
-        IOUtils.close(riw, dir);
+        IOUtils.close(dir);
       } else {
         IOUtils.closeWhileHandlingException(riw, dir);
       }
Index: lucene/core/src/test/org/apache/lucene/index/TestOmitTf.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestOmitTf.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestOmitTf.java	(working copy)
@@ -104,7 +104,7 @@
     // force merge
     writer.forceMerge(1);
     // flush
-    writer.close();
+    writer.shutdown();
 
     SegmentReader reader = getOnlySegmentReader(DirectoryReader.open(ram));
     FieldInfos fi = reader.getFieldInfos();
@@ -156,7 +156,7 @@
     // force merge
     writer.forceMerge(1);
     // flush
-    writer.close();
+    writer.shutdown();
 
     SegmentReader reader = getOnlySegmentReader(DirectoryReader.open(ram));
     FieldInfos fi = reader.getFieldInfos();
@@ -199,7 +199,7 @@
     writer.forceMerge(1);
 
     // flush
-    writer.close();
+    writer.shutdown();
 
     SegmentReader reader = getOnlySegmentReader(DirectoryReader.open(ram));
     FieldInfos fi = reader.getFieldInfos();
@@ -251,7 +251,7 @@
     // force merge
     writer.forceMerge(1);
     // flush
-    writer.close();
+    writer.shutdown();
 
     assertNoPrx(ram);
     ram.close();
@@ -287,7 +287,7 @@
         
     writer.forceMerge(1);
     // flush
-    writer.close();
+    writer.shutdown();
 
     /*
      * Verify the index
@@ -453,7 +453,7 @@
     doc.add(f);
     iw.addDocument(doc);
     IndexReader ir = iw.getReader();
-    iw.close();
+    iw.shutdown();
     assertEquals(-1, ir.totalTermFreq(new Term("foo", new BytesRef("bar"))));
     assertEquals(-1, ir.getSumTotalTermFreq("foo"));
     ir.close();
Index: lucene/core/src/test/org/apache/lucene/index/TestIndexWriterOutOfFileDescriptors.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestIndexWriterOutOfFileDescriptors.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestIndexWriterOutOfFileDescriptors.java	(working copy)
@@ -84,7 +84,7 @@
           w.addDocument(docs.nextDoc());
         }
         dir.setRandomIOExceptionRateOnOpen(0.0);
-        w.close();
+        w.shutdown();
         w = null;
 
         // NOTE: This is O(N^2)!  Only enable for temporary debugging:
@@ -143,7 +143,7 @@
         // files ... we can easily have leftover files at
         // the time we take a copy because we are holding
         // open a reader:
-        new IndexWriter(dirCopy, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()))).close();
+        new IndexWriter(dirCopy, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()))).shutdown();
         dirCopy.setRandomIOExceptionRate(rate);
         dir.setRandomIOExceptionRateOnOpen(rate);
       }
Index: lucene/core/src/test/org/apache/lucene/index/TestIndexWriterMergePolicy.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestIndexWriterMergePolicy.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestIndexWriterMergePolicy.java	(working copy)
@@ -42,7 +42,7 @@
       checkInvariants(writer);
     }
 
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
 
@@ -64,7 +64,7 @@
     }
     assertTrue(noOverMerge);
 
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
 
@@ -81,7 +81,7 @@
 
     for (int i = 0; i < 100; i++) {
       addDoc(writer);
-      writer.close();
+      writer.shutdown();
 
       mp = new LogDocMergePolicy();
       mp.setMergeFactor(10);
@@ -92,7 +92,7 @@
       checkInvariants(writer);
     }
 
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
 
@@ -122,7 +122,7 @@
     }
     checkInvariants(writer);
 
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
 
@@ -142,7 +142,7 @@
         addDoc(writer);
         checkInvariants(writer);
       }
-      writer.close();
+      writer.shutdown();
 
       writer = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT,
           new MockAnalyzer(random())).setOpenMode(
@@ -150,7 +150,7 @@
                           .setMergeScheduler(new SerialMergeScheduler()));
     }
 
-    writer.close();
+    writer.shutdown();
     LogDocMergePolicy ldmp = new LogDocMergePolicy();
     ldmp.setMergeFactor(10);
     writer = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT,
@@ -172,7 +172,7 @@
     writer.commit();
     checkInvariants(writer);
 
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
 
@@ -190,7 +190,7 @@
       addDoc(writer);
       checkInvariants(writer);
     }
-    writer.close();
+    writer.shutdown();
 
     // delete some docs without merging
     writer = new IndexWriter(
@@ -199,7 +199,7 @@
             setMergePolicy(NoMergePolicy.NO_COMPOUND_FILES)
     );
     writer.deleteDocuments(new Term("content", "aaa"));
-    writer.close();
+    writer.shutdown();
 
     ldmp = new LogDocMergePolicy();
     ldmp.setMergeFactor(5);
@@ -217,7 +217,7 @@
     checkInvariants(writer);
     assertEquals(10, writer.maxDoc());
 
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
 
Index: lucene/core/src/test/org/apache/lucene/index/TestDoc.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestDoc.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestDoc.java	(working copy)
@@ -135,7 +135,7 @@
 
       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 @@
 
       si2 = indexDoc(writer, "test2.txt");
       printSegment(out, si2);
-      writer.close();
+      writer.shutdown();
 
       siMerge = merge(directory, si1, si2, "_merge", true);
       printSegment(out, siMerge);
Index: lucene/core/src/test/org/apache/lucene/index/TestStressAdvance.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestStressAdvance.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestStressAdvance.java	(working copy)
@@ -90,7 +90,7 @@
         testOne(de, bDocIDs);
       }
 
-      w.close();
+      w.shutdown();
       r.close();
       dir.close();
     }
Index: lucene/core/src/test/org/apache/lucene/index/TestSizeBoundedForceMerge.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestSizeBoundedForceMerge.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestSizeBoundedForceMerge.java	(working copy)
@@ -64,7 +64,7 @@
       int numDocs = i == 7 ? 30 : 1;
       addDocs(writer, numDocs);
     }
-    writer.close();
+    writer.shutdown();
 
     SegmentInfos sis = new SegmentInfos();
     sis.read(dir);
@@ -77,7 +77,7 @@
     
     writer = new IndexWriter(dir, conf);
     writer.forceMerge(1);
-    writer.close();
+    writer.shutdown();
 
     // Should only be 3 segments in the index, because one of them exceeds the size limit
     sis = new SegmentInfos();
@@ -101,7 +101,7 @@
     addDocs(writer, 3);
     addDocs(writer, 3);
     
-    writer.close();
+    writer.shutdown();
 
     conf = newWriterConfig();
     LogMergePolicy lmp = new LogDocMergePolicy();
@@ -110,7 +110,7 @@
     
     writer = new IndexWriter(dir, conf);
     writer.forceMerge(1);
-    writer.close();
+    writer.shutdown();
 
     // Should only be 3 segments in the index, because one of them exceeds the size limit
     SegmentInfos sis = new SegmentInfos();
@@ -129,7 +129,7 @@
     addDocs(writer, 3);
     addDocs(writer, 5);
     
-    writer.close();
+    writer.shutdown();
 
     conf = newWriterConfig();
     LogMergePolicy lmp = new LogDocMergePolicy();
@@ -138,7 +138,7 @@
     
     writer = new IndexWriter(dir, conf);
     writer.forceMerge(1);
-    writer.close();
+    writer.shutdown();
 
     SegmentInfos sis = new SegmentInfos();
     sis.read(dir);
@@ -156,7 +156,7 @@
     addDocs(writer, 3);
     addDocs(writer, 3);
     
-    writer.close();
+    writer.shutdown();
     
     conf = newWriterConfig();
     LogMergePolicy lmp = new LogDocMergePolicy();
@@ -165,7 +165,7 @@
     
     writer = new IndexWriter(dir, conf);
     writer.forceMerge(1);
-    writer.close();
+    writer.shutdown();
     
     SegmentInfos sis = new SegmentInfos();
     sis.read(dir);
@@ -183,7 +183,7 @@
     addDocs(writer, 3);
     addDocs(writer, 3);
     
-    writer.close();
+    writer.shutdown();
     
     conf = newWriterConfig();
     LogMergePolicy lmp = new LogDocMergePolicy();
@@ -192,7 +192,7 @@
     
     writer = new IndexWriter(dir, conf);
     writer.forceMerge(1);
-    writer.close();
+    writer.shutdown();
     
     SegmentInfos sis = new SegmentInfos();
     sis.read(dir);
@@ -209,7 +209,7 @@
     addDocs(writer, 3);
     addDocs(writer, 3);
     
-    writer.close();
+    writer.shutdown();
     
     conf = newWriterConfig();
     LogMergePolicy lmp = new LogDocMergePolicy();
@@ -218,7 +218,7 @@
     
     writer = new IndexWriter(dir, conf);
     writer.forceMerge(1);
-    writer.close();
+    writer.shutdown();
     
     SegmentInfos sis = new SegmentInfos();
     sis.read(dir);
@@ -236,7 +236,7 @@
     addDocs(writer, 3);
     addDocs(writer, 5);
     
-    writer.close();
+    writer.shutdown();
     
     conf = newWriterConfig();
     LogMergePolicy lmp = new LogDocMergePolicy();
@@ -245,7 +245,7 @@
     
     writer = new IndexWriter(dir, conf);
     writer.forceMerge(1);
-    writer.close();
+    writer.shutdown();
     
     SegmentInfos sis = new SegmentInfos();
     sis.read(dir);
@@ -266,7 +266,7 @@
     addDocs(writer, 3);
     addDocs(writer, 3);
     
-    writer.close();
+    writer.shutdown();
     
     conf = newWriterConfig();
     LogMergePolicy lmp = new LogDocMergePolicy();
@@ -276,7 +276,7 @@
     
     writer = new IndexWriter(dir, conf);
     writer.forceMerge(1);
-    writer.close();
+    writer.shutdown();
     
     // Should only be 4 segments in the index, because of the merge factor and
     // max merge docs settings.
@@ -297,7 +297,7 @@
     
     // delete the last document, so that the last segment is merged.
     writer.deleteDocuments(new Term("id", "10"));
-    writer.close();
+    writer.shutdown();
     
     conf = newWriterConfig();
     LogMergePolicy lmp = new LogDocMergePolicy();
@@ -306,7 +306,7 @@
     
     writer = new IndexWriter(dir, conf);
     writer.forceMerge(1);
-    writer.close();
+    writer.shutdown();
     
     // Verify that the last segment does not have deletions.
     SegmentInfos sis = new SegmentInfos();
@@ -323,7 +323,7 @@
     
     addDocs(writer, 3, true);
     
-    writer.close();
+    writer.shutdown();
     
     conf = newWriterConfig();
     LogMergePolicy lmp = new LogDocMergePolicy();
@@ -332,7 +332,7 @@
     
     writer = new IndexWriter(dir, conf);
     writer.forceMerge(1);
-    writer.close();
+    writer.shutdown();
     
     // Verify that the last segment does not have deletions.
     SegmentInfos sis = new SegmentInfos();
@@ -351,7 +351,7 @@
     // delete the last document
     
     writer.deleteDocuments(new Term("id", "4"));
-    writer.close();
+    writer.shutdown();
     
     conf = newWriterConfig();
     LogMergePolicy lmp = new LogDocMergePolicy();
@@ -360,7 +360,7 @@
     
     writer = new IndexWriter(dir, conf);
     writer.forceMerge(1);
-    writer.close();
+    writer.shutdown();
     
     // Verify that the last segment does not have deletions.
     SegmentInfos sis = new SegmentInfos();
Index: lucene/core/src/test/org/apache/lucene/index/TestSegmentTermEnum.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestSegmentTermEnum.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestSegmentTermEnum.java	(working copy)
@@ -59,7 +59,7 @@
       addDoc(writer, "aaa bbb");
     }
 
-    writer.close();
+    writer.shutdown();
 
     // verify document frequency of terms in an multi segment index
     verifyDocFreq();
@@ -67,7 +67,7 @@
     // merge segments
     writer = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random())).setOpenMode(OpenMode.APPEND));
     writer.forceMerge(1);
-    writer.close();
+    writer.shutdown();
 
     // verify document frequency of terms in a single segment index
     verifyDocFreq();
@@ -77,7 +77,7 @@
   {
     IndexWriter writer  = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())).setCodec(TestUtil.alwaysPostingsFormat(new Lucene41PostingsFormat())));
     addDoc(writer, "aaa bbb");
-    writer.close();
+    writer.shutdown();
     SegmentReader reader = getOnlySegmentReader(DirectoryReader.open(dir));
     TermsEnum terms = reader.fields().terms("content").iterator(null);
     assertNotNull(terms.next());
Index: lucene/core/src/test/org/apache/lucene/index/TestFieldsReader.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestFieldsReader.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestFieldsReader.java	(working copy)
@@ -56,7 +56,7 @@
     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 @@
       for(int i=0;i<2;i++)
         writer.addDocument(testDoc);
       writer.forceMerge(1);
-      writer.close();
+      writer.shutdown();
 
       IndexReader reader = DirectoryReader.open(dir);
 
Index: lucene/core/src/test/org/apache/lucene/index/TestRollingUpdates.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestRollingUpdates.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestRollingUpdates.java	(working copy)
@@ -131,7 +131,7 @@
     w.commit();
     assertEquals(SIZE, w.numDocs());
 
-    w.close();
+    w.shutdown();
 
     TestIndexWriter.assertNoUnreferencedFiles(dir, "leftover files after rolling updates");
 
@@ -174,7 +174,7 @@
         threads[i].join();
       }
 
-      w.close();
+      w.shutdown();
     }
 
     IndexReader open = DirectoryReader.open(dir);
Index: lucene/core/src/test/org/apache/lucene/index/TestForTooMuchCloning.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestForTooMuchCloning.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestForTooMuchCloning.java	(working copy)
@@ -55,7 +55,7 @@
       w.addDocument(doc);
     }
     final IndexReader r = w.getReader();
-    w.close();
+    w.shutdown();
 
     final int cloneCount = dir.getInputCloneCount();
     //System.out.println("merge clone count=" + cloneCount);
Index: lucene/core/src/test/org/apache/lucene/index/TestTermVectorsReader.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestTermVectorsReader.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestTermVectorsReader.java	(working copy)
@@ -124,7 +124,7 @@
     }
     writer.commit();
     seg = writer.newestSegment();
-    writer.close();
+    writer.shutdown();
 
     fieldInfos = SegmentReader.readFieldInfos(seg);
   }
@@ -386,7 +386,7 @@
       assertEquals("cannot index term vector payloads when term vectors are not indexed (field=\"field\")", iae.getMessage());
     }
 
-    w.close();
+    w.shutdown();
     
     dir.close();
   }
Index: lucene/core/src/test/org/apache/lucene/index/TestSegmentTermDocs.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestSegmentTermDocs.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestSegmentTermDocs.java	(working copy)
@@ -116,7 +116,7 @@
       
     // assure that we deal with a single segment  
     writer.forceMerge(1);
-    writer.close();
+    writer.shutdown();
     
     IndexReader reader = DirectoryReader.open(dir);
 
Index: lucene/core/src/test/org/apache/lucene/index/TestForceMergeForever.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestForceMergeForever.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestForceMergeForever.java	(working copy)
@@ -74,7 +74,7 @@
       ((LogMergePolicy) mp).setMergeFactor(mergeAtOnce);
     } else {
       // skip test
-      w.close();
+      w.shutdown();
       d.close();
       return;
     }
@@ -101,7 +101,7 @@
     doStop.set(true);
     t.join();
     assertTrue("merge count is " + w.mergeCount.get(), w.mergeCount.get() <= 1);
-    w.close();
+    w.shutdown();
     d.close();
     docs.close();
   }
Index: lucene/core/src/test/org/apache/lucene/index/TestAddIndexes.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestAddIndexes.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestAddIndexes.java	(working copy)
@@ -65,7 +65,7 @@
     // add 100 documents
     addDocs(writer, 100);
     assertEquals(100, writer.maxDoc());
-    writer.close();
+    writer.shutdown();
     TestUtil.checkIndex(dir);
 
     writer = newWriter(
@@ -77,20 +77,20 @@
     // add 40 documents in separate files
     addDocs(writer, 40);
     assertEquals(40, writer.maxDoc());
-    writer.close();
+    writer.shutdown();
 
     writer = newWriter(aux2, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())).setOpenMode(OpenMode.CREATE));
     // add 50 documents in compound files
     addDocs2(writer, 50);
     assertEquals(50, writer.maxDoc());
-    writer.close();
+    writer.shutdown();
 
     // test doc count before segments are merged
     writer = newWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())).setOpenMode(OpenMode.APPEND));
     assertEquals(100, writer.maxDoc());
     writer.addIndexes(aux, aux2);
     assertEquals(190, writer.maxDoc());
-    writer.close();
+    writer.shutdown();
     TestUtil.checkIndex(dir);
 
     // make sure the old index is correct
@@ -105,14 +105,14 @@
     // add 40 documents
     addDocs(writer, 40);
     assertEquals(40, writer.maxDoc());
-    writer.close();
+    writer.shutdown();
 
     // test doc count before segments are merged
     writer = newWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())).setOpenMode(OpenMode.APPEND));
     assertEquals(190, writer.maxDoc());
     writer.addIndexes(aux3);
     assertEquals(230, writer.maxDoc());
-    writer.close();
+    writer.shutdown();
 
     // make sure the new index is correct
     verifyNumDocs(dir, 230);
@@ -124,7 +124,7 @@
     // now fully merge it.
     writer = newWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())).setOpenMode(OpenMode.APPEND));
     writer.forceMerge(1);
-    writer.close();
+    writer.shutdown();
 
     // make sure the new index is correct
     verifyNumDocs(dir, 230);
@@ -137,13 +137,13 @@
     Directory aux4 = newDirectory();
     writer = newWriter(aux4, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())));
     addDocs2(writer, 1);
-    writer.close();
+    writer.shutdown();
 
     writer = newWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())).setOpenMode(OpenMode.APPEND));
     assertEquals(230, writer.maxDoc());
     writer.addIndexes(aux4);
     assertEquals(231, writer.maxDoc());
-    writer.close();
+    writer.shutdown();
 
     verifyNumDocs(dir, 231);
 
@@ -186,7 +186,7 @@
     verifyTermDocs(dir, new Term("content", "aaa"), 1030);
     verifyTermDocs(dir, new Term("content", "bbb"), 9);
 
-    writer.close();
+    writer.shutdown();
     dir.close();
     aux.close();
   }
@@ -224,7 +224,7 @@
     verifyTermDocs(dir, new Term("content", "aaa"), 1030);
     verifyTermDocs(dir, new Term("content", "bbb"), 9);
 
-    writer.close();
+    writer.shutdown();
     dir.close();
     aux.close();
   }
@@ -262,7 +262,7 @@
     verifyTermDocs(dir, new Term("content", "aaa"), 1030);
     verifyTermDocs(dir, new Term("content", "bbb"), 9);
 
-    writer.close();
+    writer.shutdown();
     dir.close();
     aux.close();
   }
@@ -280,7 +280,7 @@
     // add 100 documents
     addDocs(writer, 100);
     assertEquals(100, writer.maxDoc());
-    writer.close();
+    writer.shutdown();
 
     writer = newWriter(
         aux,
@@ -291,7 +291,7 @@
     );
     // add 140 documents in separate files
     addDocs(writer, 40);
-    writer.close();
+    writer.shutdown();
     writer = newWriter(
         aux,
         newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())).
@@ -300,7 +300,7 @@
             setMergePolicy(newLogMergePolicy(false))
     );
     addDocs(writer, 100);
-    writer.close();
+    writer.shutdown();
 
     writer = newWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())).setOpenMode(OpenMode.APPEND));
     try {
@@ -311,7 +311,7 @@
     catch (IllegalArgumentException e) {
       assertEquals(100, writer.maxDoc());
     }
-    writer.close();
+    writer.shutdown();
 
     // make sure the index is correct
     verifyNumDocs(dir, 100);
@@ -342,7 +342,7 @@
     writer.addIndexes(aux);
     assertEquals(1040, writer.maxDoc());
     assertEquals(1000, writer.getDocCount(0));
-    writer.close();
+    writer.shutdown();
 
     // make sure the index is correct
     verifyNumDocs(dir, 1040);
@@ -371,7 +371,7 @@
     writer.addIndexes(aux);
     assertEquals(1032, writer.maxDoc());
     assertEquals(1000, writer.getDocCount(0));
-    writer.close();
+    writer.shutdown();
 
     // make sure the index is correct
     verifyNumDocs(dir, 1032);
@@ -399,7 +399,7 @@
     writer.addIndexes(aux, new MockDirectoryWrapper(random(), new RAMDirectory(aux, newIOContext(random()))));
     assertEquals(1060, writer.maxDoc());
     assertEquals(1000, writer.getDocCount(0));
-    writer.close();
+    writer.shutdown();
 
     // make sure the index is correct
     verifyNumDocs(dir, 1060);
@@ -422,7 +422,7 @@
     for (int i = 0; i < 20; i++) {
       writer.deleteDocuments(new Term("id", "" + i));
     }
-    writer.close();
+    writer.shutdown();
     IndexReader reader = DirectoryReader.open(aux);
     assertEquals(10, reader.numDocs());
     reader.close();
@@ -441,7 +441,7 @@
     writer.addIndexes(aux, new MockDirectoryWrapper(random(), new RAMDirectory(aux, newIOContext(random()))));
     assertEquals(1020, writer.maxDoc());
     assertEquals(1000, writer.getDocCount(0));
-    writer.close();
+    writer.shutdown();
     dir.close();
     aux.close();
   }
@@ -466,7 +466,7 @@
     writer.addIndexes(aux);
     assertEquals(30, writer.maxDoc());
     assertEquals(3, writer.getSegmentCount());
-    writer.close();
+    writer.shutdown();
 
     IndexWriterConfig dontMergeConfig = new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()))
       .setMergePolicy(NoMergePolicy.COMPOUND_FILES);
@@ -474,7 +474,7 @@
     for (int i = 0; i < 27; i++) {
       writer.deleteDocuments(new Term("id", "" + i));
     }
-    writer.close();
+    writer.shutdown();
     IndexReader reader = DirectoryReader.open(aux);
     assertEquals(3, reader.numDocs());
     reader.close();
@@ -485,7 +485,7 @@
     for (int i = 0; i < 8; i++) {
       writer.deleteDocuments(new Term("id", "" + i));
     }
-    writer.close();
+    writer.shutdown();
     reader = DirectoryReader.open(aux2);
     assertEquals(22, reader.numDocs());
     reader.close();
@@ -501,7 +501,7 @@
     writer.addIndexes(aux, aux2);
     assertEquals(1040, writer.maxDoc());
     assertEquals(1000, writer.getDocCount(0));
-    writer.close();
+    writer.shutdown();
     dir.close();
     aux.close();
     aux2.close();
@@ -564,7 +564,7 @@
     }
     assertEquals(1000, writer.maxDoc());
     assertEquals(1, writer.getSegmentCount());
-    writer.close();
+    writer.shutdown();
 
     writer = newWriter(
         aux,
@@ -580,7 +580,7 @@
       } else {
         addDocs(writer, 10);
       }
-      writer.close();
+      writer.shutdown();
       writer = newWriter(
           aux,
           newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())).
@@ -591,7 +591,7 @@
     }
     assertEquals(30, writer.maxDoc());
     assertEquals(3, writer.getSegmentCount());
-    writer.close();
+    writer.shutdown();
   }
 
   // LUCENE-1270
@@ -623,7 +623,7 @@
     doc2.add(newField("content", "aaa bbb ccc ddd eee fff ggg hhh iii", customType2));
     for(int i=0;i<10;i++)
       writer.addDocument(doc2);
-    writer.close();
+    writer.shutdown();
 
     Directory dir2 = newDirectory();
     lmp = new LogByteSizeMergePolicy();
@@ -634,7 +634,7 @@
         new MockAnalyzer(random()))
         .setMergeScheduler(new SerialMergeScheduler()).setMergePolicy(lmp));
     writer.addIndexes(dir);
-    writer.close();
+    writer.shutdown();
     dir.close();
     dir2.close();
   }
@@ -668,7 +668,7 @@
           .setMaxBufferedDocs(2));
       for (int i = 0; i < NUM_INIT_DOCS; i++)
         addDoc(writer);
-      writer.close();
+      writer.shutdown();
 
       dir2 = newDirectory();
       writer2 = new IndexWriter(dir2, new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())));
@@ -718,7 +718,11 @@
 
     void close(boolean doWait) throws Throwable {
       didClose = true;
-      writer2.close(doWait);
+      if (doWait == false) {
+        writer2.abortMerges();
+      }
+      //writer2.shutdown();
+      writer2.rollback();
     }
 
     void closeDir() throws Throwable {
@@ -966,7 +970,7 @@
       Document doc = new Document();
       doc.add(new StringField("id", "myid", Field.Store.NO));
       writer.addDocument(doc);
-      writer.close();
+      writer.shutdown();
     }
 
     IndexWriterConfig conf = new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()));
@@ -982,7 +986,7 @@
     }
     writer.commit();
     assertEquals("Documents from the incoming index should not have been deleted", 1, writer.numDocs());
-    writer.close();
+    writer.shutdown();
 
     for (Directory dir : dirs) {
       dir.close();
@@ -1015,7 +1019,7 @@
     addDocsWithID(writer, 100, 0);
     assertEquals(100, writer.maxDoc());
     writer.commit();
-    writer.close();
+    writer.shutdown();
     TestUtil.checkIndex(dir);
 
     writer = newWriter(
@@ -1030,7 +1034,7 @@
     addDocs(writer, 40);
     assertEquals(40, writer.maxDoc());
     writer.commit();
-    writer.close();
+    writer.shutdown();
 
     writer = newWriter(
         aux2,
@@ -1042,7 +1046,7 @@
     addDocs2(writer, 50);
     assertEquals(50, writer.maxDoc());
     writer.commit();
-    writer.close();
+    writer.shutdown();
 
     // test doc count before segments are merged
     writer = newWriter(
@@ -1054,7 +1058,7 @@
     assertEquals(100, writer.maxDoc());
     writer.addIndexes(aux, aux2);
     assertEquals(190, writer.maxDoc());
-    writer.close();
+    writer.shutdown();
 
     dir.close();
     aux.close();
@@ -1090,7 +1094,7 @@
       customType.setStoreTermVectors(true);
       d.add(new Field("c", "v", customType));
       w.addDocument(d);
-      w.close();
+      w.shutdown();
     }
     
     IndexReader[] readers = new IndexReader[] { DirectoryReader.open(dirs[0]), DirectoryReader.open(dirs[1]) };
@@ -1103,7 +1107,7 @@
     lmp.setMaxCFSSegmentSizeMB(Double.POSITIVE_INFINITY);
     IndexWriter w3 = new IndexWriter(dir, conf);
     w3.addIndexes(readers);
-    w3.close();
+    w3.shutdown();
     // we should now see segments_X,
     // segments.gen,_Y.cfs,_Y.cfe, _Z.si
     assertEquals("Only one compound segment should exist, but got: " + Arrays.toString(dir.listAll()), 5, dir.listAll().length);
@@ -1134,7 +1138,7 @@
       customType.setIndexed(true); 
       doc.add(newField("foo", "bar", customType));
       w.addDocument(doc);
-      w.close();
+      w.shutdown();
     }
 
     {
@@ -1149,7 +1153,7 @@
       } catch (IllegalArgumentException ex) {
         // expected
       }
-      w.close();
+      w.shutdown();
       IndexReader open = DirectoryReader.open(dir);
       assertEquals(0, open.numDocs());
       open.close();
@@ -1174,7 +1178,7 @@
     doc.add(newStringField("id", "1", Field.Store.YES));
     w.addDocument(doc);
     IndexReader r1 = w.getReader();
-    w.close();
+    w.shutdown();
 
     Directory d2 = newDirectory();
     w = new RandomIndexWriter(random(), d2);
@@ -1183,7 +1187,7 @@
     doc.add(newStringField("id", "2", Field.Store.YES));
     w.addDocument(doc);
     IndexReader r2 = w.getReader();
-    w.close();
+    w.shutdown();
 
     Directory d3 = newDirectory();
     w = new RandomIndexWriter(random(), d3);
@@ -1194,7 +1198,7 @@
     d2.close();
 
     IndexReader r3 = w.getReader();
-    w.close();
+    w.shutdown();
     assertEquals(2, r3.numDocs());
     for(int docID=0;docID<2;docID++) {
       StoredDocument d = r3.document(docID);
@@ -1213,7 +1217,7 @@
     RandomIndexWriter w = new RandomIndexWriter(random(), d1);
     MultiReader empty = new MultiReader();
     w.addIndexes(empty);
-    w.close();
+    w.shutdown();
     DirectoryReader dr = DirectoryReader.open(d1);
     for (AtomicReaderContext ctx : dr.leaves()) {
       assertTrue("empty segments should be dropped by addIndexes", ctx.reader().maxDoc() > 0);
@@ -1231,11 +1235,11 @@
     RandomIndexWriter w = new RandomIndexWriter(random(), src);
     w.addDocument(new Document());
     IndexReader allDeletedReader = new AllDeletedFilterReader(w.getReader().leaves().get(0).reader());
-    w.close();
+    w.shutdown();
     
     w = new RandomIndexWriter(random(), dest);
     w.addIndexes(allDeletedReader);
-    w.close();
+    w.shutdown();
     DirectoryReader dr = DirectoryReader.open(src);
     for (AtomicReaderContext ctx : dr.leaves()) {
       assertTrue("empty segments should be dropped by addIndexes", ctx.reader().maxDoc() > 0);
@@ -1267,6 +1271,8 @@
       // expected
     }
 
-    IOUtils.close(w1, w2, src, dest);
+    w1.shutdown();
+    w2.shutdown();
+    IOUtils.close(src, dest);
   }
 }
Index: lucene/core/src/test/org/apache/lucene/index/TestCrashCausesCorruptIndex.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestCrashCausesCorruptIndex.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestCrashCausesCorruptIndex.java	(working copy)
@@ -81,7 +81,7 @@
       // expected
     }
     // writes segments_3
-    indexWriter.close();
+    indexWriter.shutdown();
     assertFalse(slowFileExists(realDirectory, "segments_2"));
     crashAfterCreateOutput.close();
   }
@@ -101,7 +101,7 @@
     // currently the test fails above.
     // however, to test the fix, the following lines should pass as well.
     indexWriter.addDocument(getDocument());
-    indexWriter.close();
+    indexWriter.shutdown();
     assertFalse(slowFileExists(realDirectory, "segments_2"));
     realDirectory.close();
   }
Index: lucene/core/src/test/org/apache/lucene/index/TestThreadedForceMerge.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestThreadedForceMerge.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestThreadedForceMerge.java	(working copy)
@@ -124,7 +124,7 @@
       assertEquals("index=" + writer.segString() + " numDocs=" + writer.numDocs() + " maxDoc=" + writer.maxDoc() + " config=" + writer.getConfig(), expectedDocCount, writer.numDocs());
       assertEquals("index=" + writer.segString() + " numDocs=" + writer.numDocs() + " maxDoc=" + writer.maxDoc() + " config=" + writer.getConfig(), expectedDocCount, writer.maxDoc());
 
-      writer.close();
+      writer.shutdown();
       writer = new IndexWriter(directory, newIndexWriterConfig(
           TEST_VERSION_CURRENT, ANALYZER).setOpenMode(
           OpenMode.APPEND).setMaxBufferedDocs(2));
@@ -134,7 +134,7 @@
       assertEquals(expectedDocCount, reader.numDocs());
       reader.close();
     }
-    writer.close();
+    writer.shutdown();
   }
 
   /*
Index: lucene/core/src/test/org/apache/lucene/index/TestParallelReaderEmptyIndex.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestParallelReaderEmptyIndex.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestParallelReaderEmptyIndex.java	(working copy)
@@ -40,7 +40,7 @@
   public void testEmptyIndex() throws IOException {
     Directory rd1 = newDirectory();
     IndexWriter iw = new IndexWriter(rd1, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random())));
-    iw.close();
+    iw.shutdown();
     // create a copy:
     Directory rd2 = newDirectory(rd1);
 
@@ -72,7 +72,7 @@
     iwOut.addIndexes(new ParallelCompositeReader());
     iwOut.forceMerge(1);
     
-    iwOut.close();
+    iwOut.shutdown();
     rdOut.close();
     rd1.close();
     rd2.close();
@@ -101,7 +101,7 @@
       doc.add(newTextField("test", "", Field.Store.NO));
       idField.setStringValue("2");
       iw.addDocument(doc);
-      iw.close();
+      iw.shutdown();
 
       IndexWriterConfig dontMergeConfig = new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()))
         .setMergePolicy(NoMergePolicy.COMPOUND_FILES);
@@ -111,7 +111,7 @@
       IndexWriter writer = new IndexWriter(rd1, dontMergeConfig);
       
       writer.deleteDocuments(new Term("id", "1"));
-      writer.close();
+      writer.shutdown();
       IndexReader ir = DirectoryReader.open(rd1);
       assertEquals(2, ir.maxDoc());
       assertEquals(1, ir.numDocs());
@@ -119,7 +119,7 @@
 
       iw = new IndexWriter(rd1, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random())).setOpenMode(OpenMode.APPEND));
       iw.forceMerge(1);
-      iw.close();
+      iw.shutdown();
     }
 
     Directory rd2 = newDirectory();
@@ -127,7 +127,7 @@
       IndexWriter iw = new IndexWriter(rd2, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random())));
       Document doc = new Document();
       iw.addDocument(doc);
-      iw.close();
+      iw.shutdown();
     }
 
     Directory rdOut = newDirectory();
@@ -152,7 +152,7 @@
     rd2.close();
 
     iwOut.forceMerge(1);
-    iwOut.close();
+    iwOut.shutdown();
     
     rdOut.close();
   }
Index: lucene/core/src/test/org/apache/lucene/index/TestIndexWriterConfig.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestIndexWriterConfig.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestIndexWriterConfig.java	(working copy)
@@ -144,7 +144,7 @@
     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 @@
     
     // 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 @@
     w.forceMerge(1);
     w.commit();
     assertTrue("Expected CFS after merge", w.newestSegment().info.getUseCompoundFile());
-    w.close();
+    w.shutdown();
     dir.close();
   }
 
Index: lucene/core/src/test/org/apache/lucene/index/Test2BNumericDocValues.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/Test2BNumericDocValues.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/Test2BNumericDocValues.java	(working copy)
@@ -62,7 +62,7 @@
     }
     
     w.forceMerge(1);
-    w.close();
+    w.shutdown();
     
     System.out.println("verifying...");
     System.out.flush();
Index: lucene/core/src/test/org/apache/lucene/index/TestReaderClosed.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestReaderClosed.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestReaderClosed.java	(working copy)
@@ -52,7 +52,7 @@
       writer.addDocument(doc);
     }
     reader = writer.getReader();
-    writer.close();
+    writer.shutdown();
   }
   
   public void test() throws Exception {
Index: lucene/core/src/test/org/apache/lucene/index/TestCrash.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestCrash.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestCrash.java	(working copy)
@@ -85,7 +85,7 @@
     Directory dir2 = newDirectory(dir);
     dir.close();
 
-    new RandomIndexWriter(random(), dir2).close();
+    new RandomIndexWriter(random(), dir2).shutdown();
     dir2.close();
   }
 
@@ -106,7 +106,7 @@
     System.out.println("TEST: now crash");
     crash(writer);
     writer = initIndex(random(), dir, false);
-    writer.close();
+    writer.shutdown();
 
     IndexReader reader = DirectoryReader.open(dir);
     assertTrue(reader.numDocs() < 314);
@@ -118,7 +118,7 @@
     Directory dir2 = newDirectory(dir);
     dir.close();
 
-    new RandomIndexWriter(random(), dir2).close();
+    new RandomIndexWriter(random(), dir2).shutdown();
     dir2.close();
   }
 
@@ -130,7 +130,7 @@
     // running when we crash:
     dir.setAssertNoUnrefencedFilesOnClose(false);
 
-    writer.close();
+    writer.shutdown();
     writer = initIndex(random(), dir, false);
     assertEquals(314, writer.maxDoc());
     crash(writer);
@@ -154,7 +154,7 @@
     Directory dir2 = newDirectory(dir);
     dir.close();
 
-    new RandomIndexWriter(random(), dir2).close();
+    new RandomIndexWriter(random(), dir2).shutdown();
     dir2.close();
   }
 
@@ -163,7 +163,7 @@
     IndexWriter writer = initIndex(random(), false);
     MockDirectoryWrapper dir = (MockDirectoryWrapper) writer.getDirectory();
 
-    writer.close();
+    writer.shutdown();
     dir.crash();
 
     /*
@@ -184,7 +184,7 @@
     IndexWriter writer = initIndex(random(), false);
     MockDirectoryWrapper dir = (MockDirectoryWrapper) writer.getDirectory();
 
-    writer.close(false);
+    writer.shutdown(false);
 
     dir.crash();
 
Index: lucene/core/src/test/org/apache/lucene/index/TestIndexWriterForceMerge.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestIndexWriterForceMerge.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestIndexWriterForceMerge.java	(working copy)
@@ -46,7 +46,7 @@
             ldmp));
       for(int j=0;j<numDocs;j++)
         writer.addDocument(doc);
-      writer.close();
+      writer.shutdown();
 
       SegmentInfos sis = new SegmentInfos();
       sis.read(dir);
@@ -57,7 +57,7 @@
       writer = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT,
         new MockAnalyzer(random())).setMergePolicy(ldmp));
       writer.forceMerge(3);
-      writer.close();
+      writer.shutdown();
 
       sis = new SegmentInfos();
       sis.read(dir);
@@ -109,7 +109,7 @@
       else
         assertEquals("seg: " + segCount, 7, optSegCount);
     }
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
 
@@ -133,7 +133,7 @@
     // we see the doc stores get merged
     writer.commit();
     TestIndexWriter.addDocWithIndex(writer, 500);
-    writer.close();
+    writer.shutdown();
 
     if (VERBOSE) {
       System.out.println("TEST: start disk usage");
@@ -152,7 +152,7 @@
 
     writer = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random())).setOpenMode(OpenMode.APPEND).setMergePolicy(newLogMergePolicy()));
     writer.forceMerge(1);
-    writer.close();
+    writer.shutdown();
     long maxDiskUsage = dir.getMaxUsedSizeInBytes();
     assertTrue("forceMerge used too much temporary space: starting usage was " + startDiskUsage + " bytes; max temp usage was " + maxDiskUsage + " but should have been " + (4*startDiskUsage) + " (= 4X starting usage)",
                maxDiskUsage <= 4*startDiskUsage);
@@ -161,7 +161,7 @@
   
   // Test calling forceMerge(1, false) whereby forceMerge is kicked
   // off but we don't wait for it to finish (but
-  // writer.close()) does wait
+  // writer.shutdown()) does wait
   public void testBackgroundForceMerge() throws IOException {
 
     Directory dir = newDirectory();
@@ -180,7 +180,7 @@
       writer.forceMerge(1, false);
 
       if (0 == pass) {
-        writer.close();
+        writer.shutdown();
         DirectoryReader reader = DirectoryReader.open(dir);
         assertEquals(1, reader.leaves().size());
         reader.close();
@@ -189,7 +189,7 @@
         // NOT included in the merging
         writer.addDocument(doc);
         writer.addDocument(doc);
-        writer.close();
+        writer.shutdown();
 
         DirectoryReader reader = DirectoryReader.open(dir);
         assertTrue(reader.leaves().size() > 1);
Index: lucene/core/src/test/org/apache/lucene/index/Test4GBStoredFields.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/Test4GBStoredFields.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/Test4GBStoredFields.java	(working copy)
@@ -81,7 +81,7 @@
       }
     }
     w.forceMerge(1);
-    w.close();
+    w.shutdown();
     if (VERBOSE) {
       boolean found = false;
       for (String file : dir.listAll()) {
Index: lucene/core/src/test/org/apache/lucene/index/TestIndexWriterDelete.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestIndexWriterDelete.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestIndexWriterDelete.java	(working copy)
@@ -90,7 +90,7 @@
     hitCount = getHitCount(dir, term);
     assertEquals(0, hitCount);
 
-    modifier.close();
+    modifier.shutdown();
     dir.close();
   }
 
@@ -125,7 +125,7 @@
     reader = DirectoryReader.open(dir);
     assertEquals(0, reader.numDocs());
     reader.close();
-    modifier.close();
+    modifier.shutdown();
     dir.close();
   }
 
@@ -139,7 +139,7 @@
     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 @@
       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 @@
 
     IndexReader reader = DirectoryReader.open(dir);
     assertEquals(5, reader.numDocs());
-    modifier.close();
+    modifier.shutdown();
     reader.close();
     dir.close();
   }
@@ -258,7 +258,7 @@
     assertEquals(2, reader.numDocs());
     reader.close();
 
-    modifier.close();
+    modifier.shutdown();
     dir.close();
   }
 
@@ -304,7 +304,7 @@
     assertEquals(2, reader.numDocs());
     reader.close();
 
-    modifier.close();
+    modifier.shutdown();
     dir.close();
   }
   
@@ -361,7 +361,7 @@
       thread.join();
     }
     
-    modifier.close();
+    modifier.shutdown();
     DirectoryReader reader = DirectoryReader.open(dir);
     assertEquals(reader.maxDoc(), 0);
     assertEquals(reader.numDocs(), 0);
@@ -397,7 +397,6 @@
 
     // Roll it back
     modifier.rollback();
-    modifier.close();
 
     // Validate that the docs are still there
     reader = DirectoryReader.open(dir);
@@ -440,7 +439,6 @@
 
     // Roll it back
     modifier.rollback();
-    modifier.close();
 
     // Validate that the docs are still there
     reader = DirectoryReader.open(dir);
@@ -510,7 +508,7 @@
       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 @@
               }
               docId += 12;
             }
+            modifier.shutdown();
           }
-          modifier.close();
           success = true;
           if (0 == x) {
             done = true;
@@ -696,7 +694,6 @@
         }
       }
       dir.close();
-      modifier.close();
 
       // Try again with 10 more bytes of free space:
       diskFree += 10;
@@ -861,7 +858,7 @@
     // Make sure the delete was successfully flushed:
     assertEquals(0, hitCount);
 
-    modifier.close();
+    modifier.shutdown();
     dir.close();
   }
 
@@ -918,7 +915,7 @@
       }
     }
 
-    modifier.close();
+    modifier.shutdown();
     TestIndexWriter.assertNoUnreferencedFiles(dir, "docsWriter.abort() failed to delete unreferenced files");
     dir.close();
   }
@@ -934,7 +931,7 @@
     modifier.deleteDocuments(new TermQuery(new Term("nada", "nada")));
     modifier.commit();
     assertEquals(5, modifier.numDocs());
-    modifier.close();
+    modifier.shutdown();
     dir.close();
   }
   
@@ -966,7 +963,7 @@
       r.close();
     }
 
-    w.close();
+    w.shutdown();
     dir.close();
   }
   
@@ -1014,7 +1011,7 @@
       }
       assertTrue("flush happened too quickly during " + (doIndexing ? "indexing" : "deleting") + " count=" + count, count > 2500);
     }
-    w.close();
+    w.shutdown();
     dir.close();
   }
 
@@ -1060,7 +1057,7 @@
         fail("delete's were not applied");
       }
     }
-    w.close();
+    w.shutdown();
     dir.close();
   }
 
@@ -1099,7 +1096,7 @@
         fail("delete's were not applied at count=" + flushAtDelCount);
       }
     }
-    w.close();
+    w.shutdown();
     dir.close();
   }
 
@@ -1148,7 +1145,7 @@
     }
     closing.set(true);
     assertTrue(sawAfterFlush.get());
-    w.close();
+    w.shutdown();
     dir.close();
   }
 
@@ -1171,7 +1168,7 @@
     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 @@
     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 @@
     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 @@
     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());
Index: lucene/core/src/test/org/apache/lucene/index/TestDocValuesWithThreads.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestDocValuesWithThreads.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestDocValuesWithThreads.java	(working copy)
@@ -63,7 +63,7 @@
 
     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 @@
 
     writer.forceMerge(1);
     final DirectoryReader r = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     final AtomicReader sr = getOnlySegmentReader(r);
 
Index: lucene/core/src/test/org/apache/lucene/index/TestTransactionRollback.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestTransactionRollback.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestTransactionRollback.java	(working copy)
@@ -72,7 +72,7 @@
     Map<String,String> data = new HashMap<>();
     data.put("index", "Rolled back to 1-"+id);
     w.setCommitData(data);
-    w.close();
+    w.shutdown();
   }
 
   public void testRepeatedRollBacks() throws Exception {
@@ -146,7 +146,7 @@
       }
     }
 
-    w.close();
+    w.shutdown();
   }
   
   @Override
@@ -213,7 +213,7 @@
       // Unless you specify a prior commit point, rollback
       // should not work:
       new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random()))
-          .setIndexDeletionPolicy(new DeleteLastCommitPolicy())).close();
+          .setIndexDeletionPolicy(new DeleteLastCommitPolicy())).shutdown();
       IndexReader r = DirectoryReader.open(dir);
       assertEquals(100, r.numDocs());
       r.close();
Index: lucene/core/src/test/org/apache/lucene/index/Test2BPostingsBytes.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/Test2BPostingsBytes.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/Test2BPostingsBytes.java	(working copy)
@@ -87,7 +87,7 @@
       w.addDocument(doc);
     }
     w.forceMerge(1);
-    w.close();
+    w.shutdown();
     
     DirectoryReader oneThousand = DirectoryReader.open(dir);
     IndexReader subReaders[] = new IndexReader[1000];
@@ -101,7 +101,7 @@
         new IndexWriterConfig(TEST_VERSION_CURRENT, null));
     w2.addIndexes(mr);
     w2.forceMerge(1);
-    w2.close();
+    w2.shutdown();
     oneThousand.close();
     
     DirectoryReader oneMillion = DirectoryReader.open(dir2);
@@ -116,7 +116,7 @@
         new IndexWriterConfig(TEST_VERSION_CURRENT, null));
     w3.addIndexes(mr);
     w3.forceMerge(1);
-    w3.close();
+    w3.shutdown();
     oneMillion.close();
     
     dir.close();
Index: lucene/core/src/test/org/apache/lucene/index/TestAllFilesHaveChecksumFooter.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestAllFilesHaveChecksumFooter.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestAllFilesHaveChecksumFooter.java	(working copy)
@@ -60,7 +60,7 @@
         riw.deleteDocuments(new Term("id", Integer.toString(i)));
       }
     }
-    riw.close();
+    riw.shutdown();
     checkHeaders(dir);
     dir.close();
   }
Index: lucene/core/src/test/org/apache/lucene/index/TestTryDelete.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestTryDelete.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestTryDelete.java	(working copy)
@@ -65,7 +65,7 @@
     }
 
     writer.commit();
-    writer.close();
+    writer.shutdown();
 
     return directory;
   }
@@ -153,7 +153,7 @@
 
     assertEquals(0, topDocs.totalHits);
 
-    writer.close();
+    writer.shutdown();
 
     searcher = new IndexSearcher(DirectoryReader.open(directory));
 
Index: lucene/core/src/test/org/apache/lucene/index/TestMultiLevelSkipList.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestMultiLevelSkipList.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestMultiLevelSkipList.java	(working copy)
@@ -77,7 +77,7 @@
     }
     writer.commit();
     writer.forceMerge(1);
-    writer.close();
+    writer.shutdown();
 
     AtomicReader reader = getOnlySegmentReader(DirectoryReader.open(dir));
     
Index: lucene/core/src/test/org/apache/lucene/index/TestFilterAtomicReader.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestFilterAtomicReader.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestFilterAtomicReader.java	(working copy)
@@ -130,7 +130,7 @@
     d3.add(newTextField("default", "two four", Field.Store.YES));
     writer.addDocument(d3);
 
-    writer.close();
+    writer.shutdown();
 
     Directory target = newDirectory();
 
@@ -140,7 +140,7 @@
     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);
     
Index: lucene/core/src/test/org/apache/lucene/index/TestTransactions.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestTransactions.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestTransactions.java	(working copy)
@@ -146,8 +146,8 @@
         TestTransactions.doFail = false;
       }  
 
-      writer1.close();
-      writer2.close();
+      writer1.shutdown();
+      writer2.shutdown();
     }
 
     public void update(IndexWriter writer) throws IOException {
@@ -219,7 +219,7 @@
       d.add(newTextField("contents", English.intToEnglish(n), Field.Store.NO));
       writer.addDocument(d);
     }
-    writer.close();
+    writer.shutdown();
   }
 
   public void testTransactions() throws Throwable {
Index: lucene/core/src/test/org/apache/lucene/index/TestDocValuesIndexing.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestDocValuesIndexing.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestDocValuesIndexing.java	(working copy)
@@ -57,7 +57,7 @@
     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 @@
     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 @@
 
     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 @@
     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 @@
     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 @@
     DirectoryReader r = w.getReader();
     assertEquals(17, getOnlySegmentReader(r).getNumericDocValues("field").get(0));
     r.close();
-    w.close();
+    w.shutdown();
     d.close();
   }
 
@@ -195,7 +195,7 @@
     bytes[0] = 1;
     assertEquals(b, bytes1);
     r.close();
-    w.close();
+    w.shutdown();
     d.close();
   }
 
@@ -224,7 +224,7 @@
       assertEquals(Integer.toString(i), d.get("docId"));
     }
     slow.close();
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
 
@@ -240,7 +240,7 @@
     } catch (IllegalArgumentException iae) {
       // expected
     }
-    w.close();
+    w.shutdown();
     dir.close();
   }
 
@@ -259,7 +259,7 @@
     } catch (IllegalArgumentException iae) {
       // expected
     }
-    w.close();
+    w.shutdown();
     dir.close();
   }
   
@@ -279,9 +279,11 @@
       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 @@
       // expected
     }
     
-    iwriter.close();
+    iwriter.shutdown();
     directory.close();
   }
   
@@ -325,7 +327,7 @@
       // expected
     }
     
-    iwriter.close();
+    iwriter.shutdown();
     directory.close();
   }
 
@@ -348,7 +350,7 @@
     } catch (IllegalArgumentException expected) {
       // expected
     }
-    iwriter.close();
+    iwriter.shutdown();
     directory.close();
   }
   
@@ -372,7 +374,7 @@
     } catch (IllegalArgumentException expected) {
       // expected
     }
-    iwriter.close();
+    iwriter.shutdown();
     directory.close();
   }
 
@@ -392,7 +394,7 @@
     } catch (IllegalArgumentException iae) {
       // expected
     }
-    w.close();
+    w.shutdown();
     dir.close();
   }
 
@@ -408,7 +410,7 @@
     doc = new Document();
     doc.add(new SortedDocValuesField("foo", new BytesRef("hello")));
     w.addDocument(doc);
-    w.close();
+    w.shutdown();
     dir.close();
   }
 
@@ -419,7 +421,7 @@
     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 @@
     doc = new Document();
     doc.add(new SortedDocValuesField("foo", new BytesRef("hello")));
     w.addDocument(doc);
-    w.close();
+    w.shutdown();
     dir.close();
   }
 
@@ -475,7 +477,7 @@
       t.join();
     }
     assertTrue(hitExc.get());
-    w.close();
+    w.shutdown();
     dir.close();
   }
 
@@ -493,7 +495,7 @@
     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 @@
 
     r.close();
     dir2.close();
-    w.close();
+    w.shutdown();
     dir.close();
   }
 
@@ -529,7 +531,7 @@
     } catch (IllegalArgumentException iae) {
       // expected
     }
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
 
@@ -540,7 +542,7 @@
     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 @@
     } catch (IllegalArgumentException iae) {
       // expected
     }
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
 
@@ -562,14 +564,14 @@
     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 @@
     doc = new Document();
     doc.add(new SortedDocValuesField("dv", new BytesRef("foo")));
     writer.addDocument(doc);
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
 
@@ -600,7 +602,7 @@
     doc = new Document();
     doc.add(new SortedDocValuesField("dv", new BytesRef("foo")));
     writer.addDocument(doc);
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
 
@@ -611,13 +613,13 @@
     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 @@
     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 @@
     } catch (IllegalArgumentException iae) {
       // expected
     }
-    writer.close();
+    writer.shutdown();
 
     dir.close();
     dir2.close();
@@ -654,7 +656,7 @@
     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 @@
       // expected
     }
     readers[0].close();
-    writer.close();
+    writer.shutdown();
 
     dir.close();
     dir2.close();
@@ -682,7 +684,7 @@
     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 @@
     } catch (IllegalArgumentException iae) {
       // expected
     }
-    writer.close();
+    writer.shutdown();
     dir2.close();
     dir.close();
   }
@@ -707,7 +709,7 @@
     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 @@
     } catch (IllegalArgumentException iae) {
       // expected
     }
-    writer.close();
+    writer.shutdown();
     dir2.close();
     dir.close();
   }
@@ -741,7 +743,7 @@
     writer.addDocument(doc);
     
     DirectoryReader r = writer.getReader();
-    writer.close();
+    writer.shutdown();
 
     AtomicReader subR = r.leaves().get(0).reader();
     assertEquals(2, subR.numDocs());
Index: lucene/core/src/test/org/apache/lucene/index/Test2BBinaryDocValues.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/Test2BBinaryDocValues.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/Test2BBinaryDocValues.java	(working copy)
@@ -70,7 +70,7 @@
     }
     
     w.forceMerge(1);
-    w.close();
+    w.shutdown();
     
     System.out.println("verifying...");
     System.out.flush();
@@ -130,7 +130,7 @@
     }
     
     w.forceMerge(1);
-    w.close();
+    w.shutdown();
     
     System.out.println("verifying...");
     System.out.flush();
Index: lucene/core/src/test/org/apache/lucene/index/TestPerSegmentDeletes.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestPerSegmentDeletes.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestPerSegmentDeletes.java	(working copy)
@@ -160,7 +160,7 @@
     **/
     // System.out.println("segdels2:"+writer.docWriter.segmentDeletes.toString());
     //System.out.println("close");
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
 
Index: lucene/core/src/test/org/apache/lucene/index/TestPersistentSnapshotDeletionPolicy.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestPersistentSnapshotDeletionPolicy.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestPersistentSnapshotDeletionPolicy.java	(working copy)
@@ -55,7 +55,7 @@
     assertNull(psdp.getLastSaveFile());
     prepareIndexAndSnapshots(psdp, writer, numSnapshots);
     assertNotNull(psdp.getLastSaveFile());
-    writer.close();
+    writer.shutdown();
 
     // Make sure only 1 save file exists:
     int count = 0;
@@ -88,7 +88,7 @@
     assertEquals(numSnapshots+1, psdp.getSnapshotCount());
     assertSnapshotExists(dir, psdp, numSnapshots+1, false);
 
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
 
@@ -142,7 +142,7 @@
       }
     }
     assertEquals(0, psdp.getSnapshotCount());
-    writer.close();
+    writer.shutdown();
     assertEquals(1, DirectoryReader.listCommits(dir).size());
     dir.close();
   }
@@ -153,7 +153,7 @@
     IndexWriter writer = new IndexWriter(dir, getConfig(random(), getDeletionPolicy(dir)));
     PersistentSnapshotDeletionPolicy psdp = (PersistentSnapshotDeletionPolicy) writer.getConfig().getIndexDeletionPolicy();
     prepareIndexAndSnapshots(psdp, writer, 1);
-    writer.close();
+    writer.shutdown();
 
     psdp.release(snapshots.get(0));
 
@@ -169,7 +169,7 @@
     IndexWriter writer = new IndexWriter(dir, getConfig(random(), getDeletionPolicy(dir)));
     PersistentSnapshotDeletionPolicy psdp = (PersistentSnapshotDeletionPolicy) writer.getConfig().getIndexDeletionPolicy();
     prepareIndexAndSnapshots(psdp, writer, 1);
-    writer.close();
+    writer.shutdown();
 
     psdp.release(snapshots.get(0).getGeneration());
 
Index: lucene/core/src/test/org/apache/lucene/index/TestNumericDocValuesUpdates.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestNumericDocValuesUpdates.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestNumericDocValuesUpdates.java	(working copy)
@@ -84,7 +84,7 @@
     writer.getConfig().setRAMBufferSizeMB(1000d);
     writer.updateNumericDocValue(new Term("id", "doc-2"), "val", 7L);
     assertEquals(4, writer.getFlushDeletesCount());
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
   
@@ -105,11 +105,11 @@
     
     final DirectoryReader reader;
     if (random().nextBoolean()) { // not NRT
-      writer.close();
+      writer.shutdown();
       reader = DirectoryReader.open(dir);
     } else { // NRT
       reader = DirectoryReader.open(writer, true);
-      writer.close();
+      writer.shutdown();
     }
     
     assertEquals(1, reader.leaves().size());
@@ -148,11 +148,11 @@
     
     final DirectoryReader reader;
     if (random().nextBoolean()) { // not NRT
-      writer.close();
+      writer.shutdown();
       reader = DirectoryReader.open(dir);
     } else { // NRT
       reader = DirectoryReader.open(writer, true);
-      writer.close();
+      writer.shutdown();
     }
     
     for (AtomicReaderContext context : reader.leaves()) {
@@ -200,8 +200,9 @@
 
     assertEquals(1, reader1.leaves().get(0).reader().getNumericDocValues("val").get(0));
     assertEquals(10, reader2.leaves().get(0).reader().getNumericDocValues("val").get(0));
-    
-    IOUtils.close(writer, reader1, reader2, dir);
+
+    writer.shutdown();
+    IOUtils.close(reader1, reader2, dir);
   }
   
   @Test
@@ -230,11 +231,11 @@
     
     final DirectoryReader reader;
     if (random().nextBoolean()) { // not NRT
-      writer.close();
+      writer.shutdown();
       reader = DirectoryReader.open(dir);
     } else { // NRT
       reader = DirectoryReader.open(writer, true);
-      writer.close();
+      writer.shutdown();
     }
     
     AtomicReader slow = SlowCompositeReaderWrapper.wrap(reader);
@@ -275,11 +276,11 @@
     
     final DirectoryReader reader;
     if (random().nextBoolean()) { // not NRT
-      writer.close();
+      writer.shutdown();
       reader = DirectoryReader.open(dir);
     } else { // NRT
       reader = DirectoryReader.open(writer, true);
-      writer.close();
+      writer.shutdown();
     }
     
     AtomicReader r = reader.leaves().get(0).reader();
@@ -310,11 +311,11 @@
     
     final DirectoryReader reader;
     if (random().nextBoolean()) { // not NRT
-      writer.close();
+      writer.shutdown();
       reader = DirectoryReader.open(dir);
     } else { // NRT
       reader = DirectoryReader.open(writer, true);
-      writer.close();
+      writer.shutdown();
     }
     
     AtomicReader r = reader.leaves().get(0).reader();
@@ -346,7 +347,7 @@
     
     // update all docs' ndv field
     writer.updateNumericDocValue(new Term("dvUpdateKey", "dv"), "ndv", 17L);
-    writer.close();
+    writer.shutdown();
     
     final DirectoryReader reader = DirectoryReader.open(dir);
     AtomicReader r = reader.leaves().get(0).reader();
@@ -395,7 +396,7 @@
     
     // update all docs' ndv1 field
     writer.updateNumericDocValue(new Term("dvUpdateKey", "dv"), "ndv1", 17L);
-    writer.close();
+    writer.shutdown();
     
     final DirectoryReader reader = DirectoryReader.open(dir);
     AtomicReader r = reader.leaves().get(0).reader();
@@ -428,7 +429,7 @@
     
     // update all docs' ndv field
     writer.updateNumericDocValue(new Term("dvUpdateKey", "dv"), "ndv", 17L);
-    writer.close();
+    writer.shutdown();
     
     final DirectoryReader reader = DirectoryReader.open(dir);
     AtomicReader r = reader.leaves().get(0).reader();
@@ -458,7 +459,7 @@
     
     // unset the value of 'doc0'
     writer.updateNumericDocValue(new Term("id", "doc0"), "ndv", null);
-    writer.close();
+    writer.shutdown();
     
     final DirectoryReader reader = DirectoryReader.open(dir);
     AtomicReader r = reader.leaves().get(0).reader();
@@ -495,7 +496,7 @@
     
     // unset the value of 'doc'
     writer.updateNumericDocValue(new Term("id", "doc"), "ndv", null);
-    writer.close();
+    writer.shutdown();
     
     final DirectoryReader reader = DirectoryReader.open(dir);
     AtomicReader r = reader.leaves().get(0).reader();
@@ -541,7 +542,7 @@
       // ok
     }
     
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
   
@@ -566,7 +567,7 @@
     writer.addDocument(doc); // in-memory document
     
     writer.updateNumericDocValue(new Term("key", "doc"), "ndv", 17L);
-    writer.close();
+    writer.shutdown();
     
     final DirectoryReader reader = DirectoryReader.open(dir);
     
@@ -599,7 +600,7 @@
     
     writer.updateNumericDocValue(new Term("key", "doc"), "ndv", 17L); // update existing field
     writer.updateNumericDocValue(new Term("key", "doc"), "ndv", 3L); // update existing field 2nd time in this commit
-    writer.close();
+    writer.shutdown();
     
     final DirectoryReader reader = DirectoryReader.open(dir);
     final AtomicReader r = SlowCompositeReaderWrapper.wrap(reader);
@@ -642,7 +643,7 @@
       if (random.nextDouble() < 0.4) {
         writer.commit();
       } else if (random.nextDouble() < 0.1) {
-        writer.close();
+        writer.shutdown();
         writer = new IndexWriter(dir, conf.clone());
       }
 
@@ -678,7 +679,7 @@
       reader.close();
     }
     
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
   
@@ -699,7 +700,7 @@
     
     writer.updateNumericDocValue(new Term("k1", "v1"), "ndv", 17L);
     writer.updateNumericDocValue(new Term("k2", "v2"), "ndv", 3L);
-    writer.close();
+    writer.shutdown();
     
     final DirectoryReader reader = DirectoryReader.open(dir);
     final AtomicReader r = SlowCompositeReaderWrapper.wrap(reader);
@@ -817,8 +818,9 @@
       }
 //      System.out.println();
     }
-    
-    IOUtils.close(writer, reader, dir);
+
+    writer.shutdown();
+    IOUtils.close(reader, dir);
   }
   
   @Test
@@ -826,7 +828,7 @@
     Directory dir = newDirectory();
     IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()));
     // prevent merges, otherwise by the time updates are applied
-    // (writer.close()), the segments might have merged and that update becomes
+    // (writer.shutdown()), the segments might have merged and that update becomes
     // legit.
     conf.setMergePolicy(NoMergePolicy.COMPOUND_FILES);
     IndexWriter writer = new IndexWriter(dir, conf);
@@ -857,7 +859,7 @@
     // update document in the second segment - field should be added and we should
     // be able to handle the other document correctly (e.g. no NPE)
     writer.updateNumericDocValue(new Term("id", "doc1"), "ndv", 5L);
-    writer.close();
+    writer.shutdown();
 
     DirectoryReader reader = DirectoryReader.open(dir);
     for (AtomicReaderContext context : reader.leaves()) {
@@ -880,7 +882,7 @@
     Directory dir = newDirectory();
     IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()));
     // prevent merges, otherwise by the time updates are applied
-    // (writer.close()), the segments might have merged and that update becomes
+    // (writer.shutdown()), the segments might have merged and that update becomes
     // legit.
     conf.setMergePolicy(NoMergePolicy.COMPOUND_FILES);
     IndexWriter writer = new IndexWriter(dir, conf);
@@ -902,7 +904,7 @@
     
     // update document in the second segment
     writer.updateNumericDocValue(new Term("id", "doc1"), "ndv", 5L);
-    writer.close();
+    writer.shutdown();
 
     DirectoryReader reader = DirectoryReader.open(dir);
     for (AtomicReaderContext context : reader.leaves()) {
@@ -931,7 +933,7 @@
     writer.addDocument(doc);
     writer.commit();
     writer.updateNumericDocValue(new Term("f", "mock-value"), "f", 17L);
-    writer.close();
+    writer.shutdown();
     
     DirectoryReader r = DirectoryReader.open(dir);
     NumericDocValues ndv = r.leaves().get(0).reader().getNumericDocValues("f");
@@ -956,14 +958,14 @@
     doc.add(new StringField("id", "doc", Store.NO));
     doc.add(new NumericDocValuesField("f", 5));
     writer.addDocument(doc);
-    writer.close();
+    writer.shutdown();
     
     conf = newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()));
     writer = new IndexWriter(dir, conf);
     writer.updateNumericDocValue(new Term("id", "doc"), "f", 4L);
     OLD_FORMAT_IMPERSONATION_IS_ACTIVE = false;
     try {
-      writer.close();
+      writer.shutdown();
       fail("should not have succeeded to update a segment written with an old Codec");
     } catch (UnsupportedOperationException e) {
       writer.rollback(); 
@@ -1081,7 +1083,7 @@
     
     for (Thread t : threads) t.start();
     done.await();
-    writer.close();
+    writer.shutdown();
     
     DirectoryReader reader = DirectoryReader.open(dir);
     for (AtomicReaderContext context : reader.leaves()) {
@@ -1142,7 +1144,7 @@
       }
       reader.close();
     }
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
 
@@ -1163,7 +1165,7 @@
     doc.add(new NumericDocValuesField("f1", 5L));
     doc.add(new NumericDocValuesField("f2", 13L));
     writer.addDocument(doc);
-    writer.close();
+    writer.shutdown();
     
     // change format
     conf.setCodec(new Lucene46Codec() {
@@ -1179,7 +1181,7 @@
     doc.add(new NumericDocValuesField("f2", 2L));
     writer.addDocument(doc);
     writer.updateNumericDocValue(new Term("id", "d0"), "f1", 12L);
-    writer.close();
+    writer.shutdown();
     
     DirectoryReader reader = DirectoryReader.open(dir);
     AtomicReader r = SlowCompositeReaderWrapper.wrap(reader);
@@ -1224,7 +1226,7 @@
     Term term = new Term("id", RandomPicks.randomFrom(random(), randomTerms));
     writer.updateNumericDocValue(term, "ndv", value);
     writer.updateNumericDocValue(term, "control", value * 2);
-    writer.close();
+    writer.shutdown();
     
     Directory dir2 = newDirectory();
     conf = newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()));
@@ -1236,7 +1238,7 @@
       writer.addIndexes(reader);
       reader.close();
     }
-    writer.close();
+    writer.shutdown();
     
     DirectoryReader reader = DirectoryReader.open(dir2);
     for (AtomicReaderContext context : reader.leaves()) {
@@ -1281,7 +1283,7 @@
     assertEquals(5L, r.leaves().get(0).reader().getNumericDocValues("f").get(0));
     r.close();
 
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
 
@@ -1336,7 +1338,7 @@
       writer.updateNumericDocValue(updateTerm, "cf" + field, value * 2);
     }
 
-    writer.close();
+    writer.shutdown();
     
     DirectoryReader reader = DirectoryReader.open(dir);
     for (AtomicReaderContext context : reader.leaves()) {
@@ -1371,7 +1373,7 @@
     writer.updateNumericDocValue(new Term("upd", "t2"), "f1", 3L); // update f1 to 3
     writer.updateNumericDocValue(new Term("upd", "t2"), "f2", 3L); // update f2 to 3
     writer.updateNumericDocValue(new Term("upd", "t1"), "f1", 4L); // update f1 to 4 (but not f2)
-    writer.close();
+    writer.shutdown();
     
     DirectoryReader reader = DirectoryReader.open(dir);
     assertEquals(4, reader.leaves().get(0).reader().getNumericDocValues("f1").get(0));
@@ -1396,7 +1398,7 @@
     writer.deleteDocuments(new Term("id", "doc")); // delete all docs in the first segment
     writer.addDocument(doc);
     writer.updateNumericDocValue(new Term("id", "doc"), "f1", 2L);
-    writer.close();
+    writer.shutdown();
     
     DirectoryReader reader = DirectoryReader.open(dir);
     assertEquals(1, reader.leaves().size());
@@ -1419,7 +1421,7 @@
     // update w/ multiple nonexisting terms in same field
     writer.updateNumericDocValue(new Term("c", "foo"), "f1", 2L);
     writer.updateNumericDocValue(new Term("c", "bar"), "f1", 2L);
-    writer.close();
+    writer.shutdown();
     
     DirectoryReader reader = DirectoryReader.open(dir);
     assertEquals(1, reader.leaves().size());
Index: lucene/core/src/test/org/apache/lucene/index/TestCodecs.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestCodecs.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestCodecs.java	(working copy)
@@ -826,7 +826,7 @@
       doc.add(new StringField("f", "doc", Store.NO));
       writer.addDocument(doc);
     }
-    writer.close();
+    writer.shutdown();
     
     Term term = new Term("f", new BytesRef("doc"));
     DirectoryReader reader = DirectoryReader.open(dir);
@@ -855,7 +855,7 @@
     
     OLD_FORMAT_IMPERSONATION_IS_ACTIVE = false;
     try {
-      writer.close();
+      writer.shutdown();
       fail("should not have succeeded to impersonate an old format!");
     } catch (UnsupportedOperationException e) {
       writer.rollback();
Index: lucene/core/src/test/org/apache/lucene/index/TestConcurrentMergeScheduler.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestConcurrentMergeScheduler.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestConcurrentMergeScheduler.java	(working copy)
@@ -122,7 +122,7 @@
       assertEquals(20*(i+1)+extraCount, writer.numDocs());
     }
 
-    writer.close();
+    writer.shutdown();
     IndexReader reader = DirectoryReader.open(directory);
     assertEquals(200+extraCount, reader.numDocs());
     reader.close();
@@ -167,7 +167,7 @@
       writer.commit();
     }
 
-    writer.close();
+    writer.shutdown();
     IndexReader reader = DirectoryReader.open(directory);
     // Verify that we did not lose any deletes...
     assertEquals(450, reader.numDocs());
@@ -192,7 +192,7 @@
         writer.addDocument(doc);
       }
         
-      writer.close();
+      writer.shutdown();
       TestIndexWriter.assertNoUnreferencedFiles(directory, "testNoExtraFiles");
 
       // Reopen
@@ -201,7 +201,7 @@
           .setOpenMode(OpenMode.APPEND).setMaxBufferedDocs(2));
     }
 
-    writer.close();
+    writer.shutdown();
 
     directory.close();
   }
@@ -239,7 +239,7 @@
       writer.addDocument(doc);
       writer.commit();
 
-      writer.close(false);
+      writer.shutdown(false);
 
       IndexReader reader = DirectoryReader.open(directory);
       assertEquals((1+iter)*182, reader.numDocs());
@@ -255,7 +255,7 @@
               setMaxBufferedDocs(2)
       );
     }
-    writer.close();
+    writer.shutdown();
 
     directory.close();
   }
@@ -325,7 +325,7 @@
         w.addDocument(doc);
       }
     }
-    w.close(false);
+    w.shutdown(false);
     dir.close();
   }
 
@@ -367,7 +367,7 @@
       }
     }
     assertTrue(((TrackingCMS) w.w.getConfig().getMergeScheduler()).totMergedBytes != 0);
-    w.close();
+    w.shutdown();
     d.close();
   }
 }
Index: lucene/core/src/test/org/apache/lucene/index/TestMixedDocValuesUpdates.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestMixedDocValuesUpdates.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestMixedDocValuesUpdates.java	(working copy)
@@ -179,7 +179,8 @@
 //      System.out.println();
     }
     
-    IOUtils.close(writer, reader, dir);
+    writer.shutdown();
+    IOUtils.close(reader, dir);
   }
   
   public void testStressMultiThreading() throws Exception {
@@ -290,7 +291,7 @@
     
     for (Thread t : threads) t.start();
     done.await();
-    writer.close();
+    writer.shutdown();
     
     DirectoryReader reader = DirectoryReader.open(dir);
     BytesRef scratch = new BytesRef();
@@ -357,7 +358,7 @@
       }
       reader.close();
     }
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
 
@@ -411,7 +412,7 @@
       writer.updateNumericDocValue(updateTerm, "cf" + field, value * 2);
     }
 
-    writer.close();
+    writer.shutdown();
     
     DirectoryReader reader = DirectoryReader.open(dir);
     BytesRef scratch = new BytesRef();
Index: lucene/core/src/test/org/apache/lucene/index/TestBagOfPostings.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestBagOfPostings.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestBagOfPostings.java	(working copy)
@@ -140,7 +140,7 @@
       // from a docsAndPositionsEnum.
     }
     ir.close();
-    iw.close();
+    iw.shutdown();
     dir.close();
   }
 }
Index: lucene/core/src/test/org/apache/lucene/index/TestAllFilesHaveCodecHeader.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestAllFilesHaveCodecHeader.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestAllFilesHaveCodecHeader.java	(working copy)
@@ -61,7 +61,7 @@
       //  riw.deleteDocuments(new Term("id", Integer.toString(i)));
       // }
     }
-    riw.close();
+    riw.shutdown();
     checkHeaders(dir);
     dir.close();
   }
Index: lucene/core/src/test/org/apache/lucene/index/TestSumDocFreq.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestSumDocFreq.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestSumDocFreq.java	(working copy)
@@ -63,7 +63,7 @@
       writer.deleteDocuments(new Term("id", "" + random().nextInt(numDocs)));
     }
     writer.forceMerge(1);
-    writer.close();
+    writer.shutdown();
     
     ir = DirectoryReader.open(dir);
     assertSumDocFreq(ir);
Index: lucene/core/src/test/org/apache/lucene/index/TestIsCurrent.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestIsCurrent.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestIsCurrent.java	(working copy)
@@ -50,7 +50,7 @@
   @Override
   public void tearDown() throws Exception {
     super.tearDown();
-    writer.close();
+    writer.shutdown();
     directory.close();
   }
 
Index: lucene/core/src/test/org/apache/lucene/index/TestIndexReaderClose.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestIndexReaderClose.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestIndexReaderClose.java	(working copy)
@@ -37,7 +37,7 @@
       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);
Index: lucene/core/src/test/org/apache/lucene/index/TestDocInverterPerFieldErrorInfo.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestDocInverterPerFieldErrorInfo.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestDocInverterPerFieldErrorInfo.java	(working copy)
@@ -86,7 +86,7 @@
       assertTrue(infoStream.contains("distinctiveFieldName"));
     }
 
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
 
@@ -111,7 +111,7 @@
     String infoStream = new String(infoBytes.toByteArray(), IOUtils.UTF_8);
     assertFalse(infoStream.contains("boringFieldName"));
 
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
 
Index: lucene/core/src/test/org/apache/lucene/index/TestIndexWriterNRTIsCurrent.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestIndexWriterNRTIsCurrent.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestIndexWriterNRTIsCurrent.java	(working copy)
@@ -64,7 +64,7 @@
       }
     }
     assertFalse(failed);
-    writer.close();
+    writer.shutdown();
     dir.close();
 
   }
Index: lucene/core/src/test/org/apache/lucene/index/TestStressIndexing2.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestStressIndexing2.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestStressIndexing2.java	(working copy)
@@ -66,7 +66,7 @@
     dw.writer.commit();
     verifyEquals(random(), reader, dir, "id");
     reader.close();
-    dw.writer.close();
+    dw.writer.shutdown();
     dir.close();
   }
   
@@ -178,7 +178,7 @@
     }
 
     // w.forceMerge(1);
-    //w.close();    
+    //w.shutdown();    
 
     for (int i=0; i<threads.length; i++) {
       IndexingThread th = threads[i];
@@ -223,7 +223,7 @@
     }
 
     //w.forceMerge(1);
-    w.close();    
+    w.shutdown();    
 
     for (int i=0; i<threads.length; i++) {
       IndexingThread th = threads[i];
@@ -259,7 +259,7 @@
       // System.out.println("indexing "+d1);
     }
     
-    w.close();
+    w.shutdown();
   }
   
   public void verifyEquals(Random r, DirectoryReader r1, Directory dir2, String idField) throws Throwable {
Index: lucene/core/src/test/org/apache/lucene/index/TestNRTReaderWithThreads.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestNRTReaderWithThreads.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestNRTReaderWithThreads.java	(working copy)
@@ -69,7 +69,7 @@
     }
     //System.out.println("addCount:"+addCount);
     //System.out.println("delCount:"+delCount);
-    writer.close();
+    writer.shutdown();
     mainDir.close();
   }
 
Index: lucene/core/src/test/org/apache/lucene/index/TestIndexWriterOnDiskFull.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestIndexWriterOnDiskFull.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestIndexWriterOnDiskFull.java	(working copy)
@@ -99,14 +99,14 @@
               if (VERBOSE) {
                 System.out.println("TEST: now close");
               }
-              writer.close();
+              writer.shutdown();
             } catch (IOException e) {
               if (VERBOSE) {
                 System.out.println("TEST: exception on close; retry w/ no disk space limit");
                 e.printStackTrace(System.out);
               }
               dir.setMaxSizeInBytes(0);
-              writer.close();
+              writer.shutdown();
             }
           }
 
@@ -126,7 +126,7 @@
         } else {
           //_TestUtil.syncConcurrentMerges(writer);
           dir.setMaxSizeInBytes(0);
-          writer.close();
+          writer.shutdown();
           dir.close();
           break;
         }
@@ -174,7 +174,7 @@
       for(int j=0;j<25;j++) {
         addDocWithIndex(writer, 25*i+j);
       }
-      writer.close();
+      writer.shutdown();
       String[] files = dirs[i].listAll();
       for(int j=0;j<files.length;j++) {
         inputDiskUsage += dirs[i].fileLength(files[j]);
@@ -188,7 +188,7 @@
     for(int j=0;j<START_COUNT;j++) {
       addDocWithIndex(writer, j);
     }
-    writer.close();
+    writer.shutdown();
     
     // Make sure starting index seems to be working properly:
     Term searchTerm = new Term("content", "aaa");        
@@ -437,7 +437,7 @@
         dir.setRandomIOExceptionRate(0.0);
         dir.setRandomIOExceptionRateOnOpen(0.0);
         
-        writer.close();
+        writer.shutdown();
         
         // Wait for all BG threads to finish else
         // dir.close() will throw IOException because
@@ -517,7 +517,7 @@
     TestUtil.checkIndex(dir);
     ftdm.clearDoFail();
     w.addDocument(doc);
-    w.close();
+    w.shutdown();
 
     dir.close();
   }
@@ -545,7 +545,7 @@
     } catch (IOException ioe) {
     }
     try {
-      writer.close(false);
+      writer.shutdown(false);
       fail("did not hit disk full");
     } catch (IOException ioe) {
     }
@@ -553,7 +553,7 @@
     // Make sure once disk space is avail again, we can
     // cleanly close:
     dir.setMaxSizeInBytes(0);
-    writer.close(false);
+    writer.close();
     dir.close();
   }
   
Index: lucene/core/src/test/org/apache/lucene/index/TestTermsEnum2.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestTermsEnum2.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestTermsEnum2.java	(working copy)
@@ -72,7 +72,7 @@
     
     reader = writer.getReader();
     searcher = newSearcher(reader);
-    writer.close();
+    writer.shutdown();
   }
   
   @Override
Index: lucene/core/src/test/org/apache/lucene/index/TestParallelCompositeReader.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestParallelCompositeReader.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestParallelCompositeReader.java	(working copy)
@@ -225,7 +225,7 @@
 
     d3.add(newTextField("f3", "v1", Field.Store.YES));
     w2.addDocument(d3);
-    w2.close();
+    w2.shutdown();
     
     DirectoryReader ir1 = DirectoryReader.open(dir1),
         ir2 = DirectoryReader.open(dir2);
@@ -444,7 +444,7 @@
     d4.add(newTextField("f3", "v4", Field.Store.YES));
     d4.add(newTextField("f4", "v4", Field.Store.YES));
     w.addDocument(d4);
-    w.close();
+    w.shutdown();
 
     final CompositeReader ir;
     if (compositeComposite) {
@@ -498,7 +498,7 @@
     d4.add(newTextField("f1", "v4", Field.Store.YES));
     d4.add(newTextField("f2", "v4", Field.Store.YES));
     w1.addDocument(d4);
-    w1.close();
+    w1.shutdown();
     return dir1;
   }
 
@@ -525,7 +525,7 @@
     d4.add(newTextField("f3", "v4", Field.Store.YES));
     d4.add(newTextField("f4", "v4", Field.Store.YES));
     w2.addDocument(d4);
-    w2.close();
+    w2.shutdown();
     return dir2;
   }
 
@@ -552,7 +552,7 @@
     d4.add(newTextField("f3", "v4", Field.Store.YES));
     d4.add(newTextField("f4", "v4", Field.Store.YES));
     w2.addDocument(d4);
-    w2.close();
+    w2.shutdown();
     return dir2;
   }
 
Index: lucene/core/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java	(working copy)
@@ -262,7 +262,7 @@
     writer.commit();
 
     try {
-      writer.close();
+      writer.shutdown();
     } catch (Throwable t) {
       System.out.println("exception during close:");
       t.printStackTrace(System.out);
@@ -308,7 +308,7 @@
     writer.commit();
 
     try {
-      writer.close();
+      writer.shutdown();
     } catch (Throwable t) {
       System.out.println("exception during close:");
       t.printStackTrace(System.out);
@@ -375,7 +375,7 @@
     } catch (RuntimeException re) {
       // expected
     }
-    w.close();
+    w.shutdown();
     dir.close();
   }
 
@@ -405,7 +405,7 @@
       // expected
     }
     w.addDocument(doc);
-    w.close();
+    w.shutdown();
     dir.close();
   }
 
@@ -445,7 +445,7 @@
 
     ((ConcurrentMergeScheduler) w.getConfig().getMergeScheduler()).sync();
     assertTrue(testPoint.failed);
-    w.close();
+    w.shutdown();
     dir.close();
   }
 
@@ -501,7 +501,7 @@
     doc.add(newTextField("content", "aa bb cc dd", Field.Store.NO));
     writer.addDocument(doc);
 
-    writer.close();
+    writer.shutdown();
     IndexReader reader = DirectoryReader.open(dir);
     final Term t = new Term("content", "aa");
     assertEquals(3, reader.docFreq(t));
@@ -582,7 +582,7 @@
       }
     }
     assertTrue(hitError);
-    writer.close();
+    writer.shutdown();
     IndexReader reader = DirectoryReader.open(dir);
     assertEquals(198, reader.docFreq(new Term("content", "aa")));
     reader.close();
@@ -633,7 +633,7 @@
         writer.addDocument(doc);
         writer.addDocument(doc);
       }
-      writer.close();
+      writer.shutdown();
 
       if (VERBOSE) {
         System.out.println("TEST: open reader");
@@ -665,7 +665,7 @@
       for(int j=0;j<17;j++)
         writer.addDocument(doc);
       writer.forceMerge(1);
-      writer.close();
+      writer.shutdown();
 
       reader = DirectoryReader.open(dir);
       int expected = 19+(1-i)*2;
@@ -750,7 +750,7 @@
         for(int t=0;t<NUM_THREAD;t++)
           threads[t].join();
 
-        writer.close();
+        writer.shutdown();
       }
 
       IndexReader reader = DirectoryReader.open(dir);
@@ -779,7 +779,7 @@
       for(int j=0;j<17;j++)
         writer.addDocument(doc);
       writer.forceMerge(1);
-      writer.close();
+      writer.shutdown();
 
       reader = DirectoryReader.open(dir);
       expected += 17-NUM_THREAD*NUM_ITER;
@@ -854,7 +854,7 @@
     ((ConcurrentMergeScheduler) writer.getConfig().getMergeScheduler()).sync();
     assertTrue(failure.didFail);
     failure.clearDoFail();
-    writer.close();
+    writer.shutdown();
 
     IndexReader reader = DirectoryReader.open(dir);
     assertEquals(23, reader.numDocs());
@@ -929,7 +929,7 @@
       w.addDocument(doc);
       dir.failOn(failure);
       try {
-        w.close();
+        w.shutdown();
         fail();
       } catch (IOException ioe) {
         fail("expected only RuntimeException");
@@ -950,7 +950,7 @@
     IndexWriter w = new IndexWriter(startDir, conf);
     for(int i=0;i<27;i++)
       addDoc(w);
-    w.close();
+    w.shutdown();
 
     int iter = TEST_NIGHTLY ? 200 : 10;
     for(int i=0;i<iter;i++) {
@@ -969,7 +969,7 @@
           fail("forceMerge threw IOException without root cause");
       }
       dir.setRandomIOExceptionRate(0);
-      w.close();
+      w.shutdown();
       dir.close();
     }
     startDir.close();
@@ -984,7 +984,7 @@
         newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random())).setInfoStream(new InfoStream() {
         @Override
         public void message(String component, final String message) {
-          if (message.startsWith("now flush at close") && thrown.compareAndSet(false, true)) {
+          if (message.startsWith("now flush at shutdown") && thrown.compareAndSet(false, true)) {
             throw new OutOfMemoryError("fake OOME at " + message);
           }
         }
@@ -999,13 +999,13 @@
       }));
 
     try {
-      writer.close();
+      writer.shutdown();
       fail("OutOfMemoryError expected");
     }
     catch (final OutOfMemoryError expected) {}
 
     // throws IllegalStateEx w/o bug fix
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
 
@@ -1056,7 +1056,7 @@
     }
 
     // close
-    writer.close();
+    writer.shutdown();
 
     long gen = SegmentInfos.getLastCommitGeneration(dir);
     assertTrue("segment generation should be > 0 but got " + gen, gen > 0);
@@ -1080,7 +1080,7 @@
     reader.close();
     
     // should remove the corrumpted segments_N
-    new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, null)).close();
+    new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, null)).shutdown();
     dir.close();
   }
 
@@ -1101,7 +1101,7 @@
       }
 
       // close
-      writer.close();
+      writer.shutdown();
 
       long gen = SegmentInfos.getLastCommitGeneration(dir);
       assertTrue("segment generation should be > 0 but got " + gen, gen > 0);
@@ -1156,7 +1156,7 @@
     }
 
     // close
-    writer.close();
+    writer.shutdown();
 
     long gen = SegmentInfos.getLastCommitGeneration(dir);
     assertTrue("segment generation should be > 0 but got " + gen, gen > 0);
@@ -1204,7 +1204,7 @@
       }
 
       // close
-      writer.close();
+      writer.shutdown();
 
       long gen = SegmentInfos.getLastCommitGeneration(dir);
       assertTrue("segment generation should be > 0 but got " + gen, gen > 0);
@@ -1246,7 +1246,7 @@
       }
 
       // close
-      writer.close();
+      writer.shutdown();
       dir.close();
   }
 
@@ -1302,7 +1302,7 @@
         document = new Document();
         document.add(new TextField("field", "a field", Field.Store.YES));
         w.addDocument(document);
-        w.close();
+        w.shutdown();
         IndexReader reader = DirectoryReader.open(dir);
         assertTrue(reader.numDocs() > 0);
         SegmentInfos sis = new SegmentInfos();
@@ -1387,7 +1387,7 @@
     }
 
     final IndexReader r = w.getReader();
-    w.close();
+    w.shutdown();
 
     final IndexSearcher s = newSearcher(r);
     PhraseQuery pq = new PhraseQuery();
@@ -1468,7 +1468,7 @@
     }
 
     final IndexReader r = w.getReader();
-    w.close();
+    w.shutdown();
 
     final IndexSearcher s = newSearcher(r);
     PhraseQuery pq = new PhraseQuery();
@@ -1506,7 +1506,7 @@
     Directory d = new MockDirectoryWrapper(random(), uoe);
     IndexWriter iw = new IndexWriter(d, newIndexWriterConfig(TEST_VERSION_CURRENT, null));
     iw.addDocument(new Document());
-    iw.close();
+    iw.shutdown();
     uoe.doFail = true;
     try {
       new IndexWriter(d, newIndexWriterConfig(TEST_VERSION_CURRENT, null));
@@ -1537,7 +1537,7 @@
     } catch (IllegalArgumentException expected) {
       // expected exception
     }
-    iw.close();
+    iw.shutdown();
     dir.close();
   }
   
@@ -1556,7 +1556,7 @@
     Field field = new TextField("foo", overflowingTokenStream);
     doc.add(field);
     iw.addDocument(doc);
-    iw.close();
+    iw.shutdown();
     dir.close();
   }
   
@@ -1621,7 +1621,7 @@
     assertEquals(1, ir.numDocs());
     assertEquals("sometext", ir.document(0).get("field1"));
     ir.close();
-    iw.close();
+    iw.shutdown();
     dir.close();
   }
   
@@ -1663,7 +1663,7 @@
     DirectoryReader ir = DirectoryReader.open(dir);
     assertEquals(1, ir.numDocs());
     ir.close();
-    iw.close();
+    iw.shutdown();
 
     // Open and close the index a few times
     for (int i = 0; i < 10; i++) {
@@ -1678,7 +1678,7 @@
         continue;
       }
       failure.clearDoFail();
-      iw.close();
+      iw.shutdown();
       ir = DirectoryReader.open(dir);
       assertEquals("lost document after iteration: " + i, 1, ir.numDocs());
       ir.close();
@@ -1843,7 +1843,7 @@
             System.out.println("  now close writer");
           }
           doClose = true;
-          w.close();
+          w.shutdown();
           w = null;
         }
 
@@ -1854,7 +1854,7 @@
         if (ioe instanceof FakeIOException || (ioe.getCause() != null && ioe.getCause() instanceof FakeIOException)) {
           // expected
           if (VERBOSE) {
-            System.out.println("TEST: w.close() hit expected IOE");
+            System.out.println("TEST: w.shutdown() hit expected IOE");
           }
         } else {
           throw ioe;
@@ -1868,7 +1868,7 @@
         if (VERBOSE) {
           System.out.println("  now 2nd close writer");
         }
-        w.close();
+        w.shutdown();
         w = null;
       }
 
@@ -1912,7 +1912,7 @@
         if (VERBOSE) {
           System.out.println("TEST: close writer");
         }
-        w.close();
+        w.shutdown();
         w = null;
       }
 
@@ -1920,7 +1920,7 @@
     }
 
     if (w != null) {
-      w.close();
+      w.shutdown();
     }
 
     // Final verify:
Index: lucene/core/src/test/org/apache/lucene/index/Test2BPositions.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/Test2BPositions.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/Test2BPositions.java	(working copy)
@@ -80,7 +80,7 @@
       }
     }
     w.forceMerge(1);
-    w.close();
+    w.shutdown();
     dir.close();
   }
   
Index: lucene/core/src/test/org/apache/lucene/index/TestIndexWriterMerging.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestIndexWriterMerging.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestIndexWriterMerging.java	(working copy)
@@ -15,21 +15,22 @@
  * limitations under the License.
  */
 
-import org.apache.lucene.store.AlreadyClosedException;
-import org.apache.lucene.store.Directory;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Random;
+
 import org.apache.lucene.analysis.MockAnalyzer;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
 import org.apache.lucene.document.FieldType;
 import org.apache.lucene.document.TextField;
 import org.apache.lucene.index.IndexWriterConfig.OpenMode;
+import org.apache.lucene.store.AlreadyClosedException;
+import org.apache.lucene.store.Directory;
+import org.apache.lucene.store.MockDirectoryWrapper;
 import org.apache.lucene.util.LuceneTestCase;
 
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Random;
 
-
 public class TestIndexWriterMerging extends LuceneTestCase
 {
 
@@ -66,7 +67,7 @@
     );
     writer.addIndexes(indexA, indexB);
     writer.forceMerge(1);
-    writer.close();
+    writer.shutdown();
 
     fail = verifyIndex(merged, 0);
 
@@ -114,7 +115,7 @@
 
       writer.addDocument(temp);
     }
-    writer.close();
+    writer.shutdown();
   }
   
   // LUCENE-325: test forceMergeDeletes, when 2 singular merges
@@ -146,7 +147,7 @@
       idField.setStringValue("" + i);
       writer.addDocument(document);
     }
-    writer.close();
+    writer.shutdown();
 
     IndexReader ir = DirectoryReader.open(dir);
     assertEquals(10, ir.maxDoc());
@@ -158,7 +159,7 @@
     writer = new IndexWriter(dir, dontMergeConfig);
     writer.deleteDocuments(new Term("id", "0"));
     writer.deleteDocuments(new Term("id", "7"));
-    writer.close();
+    writer.shutdown();
     
     ir = DirectoryReader.open(dir);
     assertEquals(8, ir.numDocs());
@@ -169,7 +170,7 @@
     assertEquals(10, writer.maxDoc());
     writer.forceMergeDeletes();
     assertEquals(8, writer.numDocs());
-    writer.close();
+    writer.shutdown();
     ir = DirectoryReader.open(dir);
     assertEquals(8, ir.maxDoc());
     assertEquals(8, ir.numDocs());
@@ -209,7 +210,7 @@
       idField.setStringValue("" + i);
       writer.addDocument(document);
     }
-    writer.close();
+    writer.shutdown();
 
     IndexReader ir = DirectoryReader.open(dir);
     assertEquals(98, ir.maxDoc());
@@ -222,7 +223,7 @@
     for(int i=0;i<98;i+=2) {
       writer.deleteDocuments(new Term("id", "" + i));
     }
-    writer.close();
+    writer.shutdown();
     
     ir = DirectoryReader.open(dir);
     assertEquals(49, ir.numDocs());
@@ -235,7 +236,7 @@
     );
     assertEquals(49, writer.numDocs());
     writer.forceMergeDeletes();
-    writer.close();
+    writer.shutdown();
     ir = DirectoryReader.open(dir);
     assertEquals(49, ir.maxDoc());
     assertEquals(49, ir.numDocs());
@@ -275,7 +276,7 @@
       idField.setStringValue("" + i);
       writer.addDocument(document);
     }
-    writer.close();
+    writer.shutdown();
 
     IndexReader ir = DirectoryReader.open(dir);
     assertEquals(98, ir.maxDoc());
@@ -288,7 +289,7 @@
     for(int i=0;i<98;i+=2) {
       writer.deleteDocuments(new Term("id", "" + i));
     }
-    writer.close();
+    writer.shutdown();
     ir = DirectoryReader.open(dir);
     assertEquals(49, ir.numDocs());
     ir.close();
@@ -299,7 +300,7 @@
             setMergePolicy(newLogMergePolicy(3))
     );
     writer.forceMergeDeletes(false);
-    writer.close();
+    writer.shutdown();
     ir = DirectoryReader.open(dir);
     assertEquals(49, ir.maxDoc());
     assertEquals(49, ir.numDocs());
@@ -347,13 +348,17 @@
     document.add(newField("tvtest", "a b c", customType));
     for(int i=0;i<177;i++)
       iw.addDocument(document);
-    iw.close();
+    iw.shutdown();
     dir.close();
   }
   
   public void testNoWaitClose() throws Throwable {
     Directory directory = newDirectory();
 
+    if (directory instanceof MockDirectoryWrapper) {
+      ((MockDirectoryWrapper) directory).setPreventDoubleWrite(false);
+    }
+
     final Document doc = new Document();
     FieldType customType = new FieldType(TextField.TYPE_STORED);
     customType.setTokenized(false);
@@ -432,7 +437,7 @@
 
         t1.start();
 
-        writer.close(false);
+        writer.shutdown(false);
         t1.join();
 
         // Make sure reader can read
@@ -442,7 +447,7 @@
         // Reopen
         writer = new IndexWriter(directory, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random())).setOpenMode(OpenMode.APPEND).setMergePolicy(newLogMergePolicy()));
       }
-      writer.close();
+      writer.shutdown();
     }
 
     directory.close();
Index: lucene/core/src/test/org/apache/lucene/index/TestBagOfPositions.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestBagOfPositions.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestBagOfPositions.java	(working copy)
@@ -148,7 +148,7 @@
       // from a docsAndPositionsEnum.
     }
     ir.close();
-    iw.close();
+    iw.shutdown();
     dir.close();
   }
 }
Index: lucene/core/src/test/org/apache/lucene/index/TestLongPostings.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestLongPostings.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestLongPostings.java	(working copy)
@@ -128,7 +128,7 @@
     }
 
     r = riw.getReader();
-    riw.close();
+    riw.shutdown();
 
     /*
     if (VERBOSE) {
@@ -328,7 +328,7 @@
       }
 
       r = riw.getReader();
-      riw.close();
+      riw.shutdown();
     } else {
       r = DirectoryReader.open(dir);
     }
Index: lucene/core/src/test/org/apache/lucene/index/TestConsistentFieldNumbers.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestConsistentFieldNumbers.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestConsistentFieldNumbers.java	(working copy)
@@ -45,7 +45,7 @@
       writer.addDocument(d1);
 
       if (i == 1) {
-        writer.close();
+        writer.shutdown();
         writer = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random())).setMergePolicy(NoMergePolicy.COMPOUND_FILES));
       } else {
         writer.commit();
@@ -60,7 +60,7 @@
       d2.add(new TextField("f4", "fourth field", Field.Store.NO));
       writer.addDocument(d2);
 
-      writer.close();
+      writer.shutdown();
 
       SegmentInfos sis = new SegmentInfos();
       sis.read(dir);
@@ -78,7 +78,7 @@
 
       writer = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random())));
       writer.forceMerge(1);
-      writer.close();
+      writer.shutdown();
 
       sis = new SegmentInfos();
       sis.read(dir);
@@ -107,7 +107,7 @@
     d1.add(new TextField("f2", "second field", Field.Store.YES));
     writer.addDocument(d1);
 
-    writer.close();
+    writer.shutdown();
     writer = new IndexWriter(dir2, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random())).setMergePolicy(NoMergePolicy.COMPOUND_FILES));
 
     Document d2 = new Document();
@@ -119,11 +119,11 @@
     d2.add(new TextField("f4", "fourth field", Field.Store.YES));
     writer.addDocument(d2);
 
-    writer.close();
+    writer.shutdown();
 
     writer = new IndexWriter(dir1, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random())).setMergePolicy(NoMergePolicy.COMPOUND_FILES));
     writer.addIndexes(dir2);
-    writer.close();
+    writer.shutdown();
 
     SegmentInfos sis = new SegmentInfos();
     sis.read(dir1);
@@ -156,7 +156,7 @@
         d.add(new TextField("f1", "d1 first field", Field.Store.YES));
         d.add(new TextField("f2", "d1 second field", Field.Store.YES));
         writer.addDocument(d);
-        writer.close();
+        writer.shutdown();
         SegmentInfos sis = new SegmentInfos();
         sis.read(dir);
         assertEquals(1, sis.size());
@@ -175,7 +175,7 @@
         d.add(new TextField("f1", "d2 first field", Field.Store.YES));
         d.add(new StoredField("f3", new byte[] { 1, 2, 3 }));
         writer.addDocument(d);
-        writer.close();
+        writer.shutdown();
         SegmentInfos sis = new SegmentInfos();
         sis.read(dir);
         assertEquals(2, sis.size());
@@ -198,7 +198,7 @@
         d.add(new TextField("f2", "d3 second field", Field.Store.YES));
         d.add(new StoredField("f3", new byte[] { 1, 2, 3, 4, 5 }));
         writer.addDocument(d);
-        writer.close();
+        writer.shutdown();
         SegmentInfos sis = new SegmentInfos();
         sis.read(dir);
         assertEquals(3, sis.size());
@@ -224,14 +224,14 @@
         // nuke the first segment entirely so that the segment with gaps is
         // loaded first!
         writer.forceMergeDeletes();
-        writer.close();
+        writer.shutdown();
       }
 
       IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(
           TEST_VERSION_CURRENT, new MockAnalyzer(random())).setMergePolicy(
           new LogByteSizeMergePolicy()).setInfoStream(new FailOnNonBulkMergesInfoStream()));
       writer.forceMerge(1);
-      writer.close();
+      writer.shutdown();
 
       SegmentInfos sis = new SegmentInfos();
       sis.read(dir);
@@ -269,7 +269,7 @@
     }
 
     writer.forceMerge(1);
-    writer.close();
+    writer.shutdown();
 
     SegmentInfos sis = new SegmentInfos();
     sis.read(dir);
Index: lucene/core/src/test/org/apache/lucene/index/TestExceedMaxTermLength.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestExceedMaxTermLength.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestExceedMaxTermLength.java	(working copy)
@@ -99,7 +99,7 @@
                    msg.contains(name));
       }
     } finally {
-      w.close();
+      w.shutdown();
     }
   }
 }
Index: lucene/core/src/test/org/apache/lucene/index/TestLazyProxSkipping.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestLazyProxSkipping.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestLazyProxSkipping.java	(working copy)
@@ -102,7 +102,7 @@
         
         // make sure the index has only a single segment
         writer.forceMerge(1);
-        writer.close();
+        writer.shutdown();
 
       SegmentReader reader = getOnlySegmentReader(DirectoryReader.open(directory));
 
@@ -151,7 +151,7 @@
             writer.addDocument(doc);
         }
         
-        writer.close();
+        writer.shutdown();
         IndexReader reader = DirectoryReader.open(directory);
 
         DocsAndPositionsEnum tp = MultiFields.getTermPositionsEnum(reader,
Index: lucene/core/src/test/org/apache/lucene/index/TestNeverDelete.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestNeverDelete.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestNeverDelete.java	(working copy)
@@ -105,7 +105,7 @@
     for(Thread t : indexThreads) {
       t.join();
     }
-    w.close();
+    w.shutdown();
     d.close();
 
     TestUtil.rmDir(tmpDir);
Index: lucene/core/src/test/org/apache/lucene/index/TestUniqueTermCount.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestUniqueTermCount.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestUniqueTermCount.java	(working copy)
@@ -58,7 +58,7 @@
       writer.addDocument(doc);
     }
     reader = writer.getReader();
-    writer.close();
+    writer.shutdown();
   }
   
   @Override
Index: lucene/core/src/test/org/apache/lucene/index/TestParallelTermEnum.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestParallelTermEnum.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestParallelTermEnum.java	(working copy)
@@ -49,7 +49,7 @@
     doc.add(newTextField("field2", "the quick brown fox jumps", Field.Store.YES));
     iw1.addDocument(doc);
 
-    iw1.close();
+    iw1.shutdown();
     rd2 = newDirectory();
     IndexWriter iw2 = new IndexWriter(rd2, newIndexWriterConfig(
         TEST_VERSION_CURRENT, new MockAnalyzer(random())));
@@ -59,7 +59,7 @@
     doc.add(newTextField("field3", "the fox jumps over the lazy dog", Field.Store.YES));
     iw2.addDocument(doc);
 
-    iw2.close();
+    iw2.shutdown();
 
     this.ir1 = SlowCompositeReaderWrapper.wrap(DirectoryReader.open(rd1));
     this.ir2 = SlowCompositeReaderWrapper.wrap(DirectoryReader.open(rd2));
Index: lucene/core/src/test/org/apache/lucene/index/TestParallelAtomicReader.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestParallelAtomicReader.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestParallelAtomicReader.java	(working copy)
@@ -149,7 +149,7 @@
 
     d3.add(newTextField("f3", "v1", Field.Store.YES));
     w2.addDocument(d3);
-    w2.close();
+    w2.shutdown();
     
     AtomicReader ir1 = SlowCompositeReaderWrapper.wrap(DirectoryReader.open(dir1));
     AtomicReader ir2 = SlowCompositeReaderWrapper.wrap(DirectoryReader.open(dir2));
@@ -274,7 +274,7 @@
     d2.add(newTextField("f3", "v2", Field.Store.YES));
     d2.add(newTextField("f4", "v2", Field.Store.YES));
     w.addDocument(d2);
-    w.close();
+    w.shutdown();
 
     DirectoryReader ir = DirectoryReader.open(dir);
     return newSearcher(ir);
@@ -302,7 +302,7 @@
     d2.add(newTextField("f1", "v2", Field.Store.YES));
     d2.add(newTextField("f2", "v2", Field.Store.YES));
     w1.addDocument(d2);
-    w1.close();
+    w1.shutdown();
     return dir1;
   }
 
@@ -317,7 +317,7 @@
     d4.add(newTextField("f3", "v2", Field.Store.YES));
     d4.add(newTextField("f4", "v2", Field.Store.YES));
     w2.addDocument(d4);
-    w2.close();
+    w2.shutdown();
     return dir2;
   }
 
Index: lucene/core/src/test/org/apache/lucene/index/TestDocCount.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestDocCount.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestDocCount.java	(working copy)
@@ -43,7 +43,7 @@
     ir = iw.getReader();
     verifyCount(ir);
     ir.close();
-    iw.close();
+    iw.shutdown();
     dir.close();
   }
   
Index: lucene/core/src/test/org/apache/lucene/index/TestOmitPositions.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestOmitPositions.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestOmitPositions.java	(working copy)
@@ -49,7 +49,7 @@
     }
     
     IndexReader reader = w.getReader();
-    w.close();
+    w.shutdown();
     
     assertNull(MultiFields.getTermPositionsEnum(reader, null, "foo", new BytesRef("test")));
     
@@ -151,7 +151,7 @@
     // force merge
     writer.forceMerge(1);
     // flush
-    writer.close();
+    writer.shutdown();
 
     SegmentReader reader = getOnlySegmentReader(DirectoryReader.open(ram));
     FieldInfos fi = reader.getFieldInfos();
@@ -220,7 +220,7 @@
     // force merge
     writer.forceMerge(1);
     // flush
-    writer.close();
+    writer.shutdown();
 
     assertNoPrx(ram);
     ram.close();
@@ -258,7 +258,7 @@
     FieldInfos fis = MultiFields.getMergedFieldInfos(ir);
     assertEquals(IndexOptions.DOCS_AND_FREQS, fis.fieldInfo("foo").getIndexOptions());
     assertFalse(fis.fieldInfo("foo").hasPayloads());
-    iw.close();
+    iw.shutdown();
     ir.close();
     dir.close(); // checkindex
   }
Index: lucene/core/src/test/org/apache/lucene/index/TestDocsAndPositions.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestDocsAndPositions.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestDocsAndPositions.java	(working copy)
@@ -58,7 +58,7 @@
       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 @@
     }
 
     IndexReader reader = writer.getReader();
-    writer.close();
+    writer.shutdown();
 
     int num = atLeast(13);
     for (int i = 0; i < num; i++) {
@@ -216,7 +216,7 @@
     }
 
     IndexReader reader = writer.getReader();
-    writer.close();
+    writer.shutdown();
 
     int num = atLeast(13);
     for (int i = 0; i < num; i++) {
@@ -293,7 +293,7 @@
 
     // 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 @@
     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 @@
     docid = disi.docID();
     assertEquals(-1, docid);
     assertTrue(disi.nextDoc() != DocIdSetIterator.NO_MORE_DOCS);
-    writer.close();
+    writer.shutdown();
     r.close();
     dir.close();
   }
Index: lucene/core/src/test/org/apache/lucene/index/TestDocTermOrds.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestDocTermOrds.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestDocTermOrds.java	(working copy)
@@ -64,7 +64,7 @@
     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 @@
     }
     
     final DirectoryReader r = w.getReader();
-    w.close();
+    w.shutdown();
 
     if (VERBOSE) {
       System.out.println("TEST: reader=" + r);
@@ -248,7 +248,7 @@
     }
     
     final DirectoryReader r = w.getReader();
-    w.close();
+    w.shutdown();
 
     if (VERBOSE) {
       System.out.println("TEST: reader=" + r);
@@ -401,7 +401,7 @@
     v.setDocument(1);
     assertEquals(1, v.nextOrd());
     
-    iw.close();
+    iw.shutdown();
     r1.close();
     r2.close();
     dir.close();
@@ -428,7 +428,7 @@
     iwriter.forceMerge(1);
     
     DirectoryReader ireader = iwriter.getReader();
-    iwriter.close();
+    iwriter.shutdown();
 
     AtomicReader ar = getOnlySegmentReader(ireader);
     SortedSetDocValues dv = FieldCache.DEFAULT.getDocTermOrds(ar, "field");
Index: lucene/core/src/test/org/apache/lucene/index/TestOmitNorms.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestOmitNorms.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestOmitNorms.java	(working copy)
@@ -64,7 +64,7 @@
     // force merge
     writer.forceMerge(1);
     // flush
-    writer.close();
+    writer.shutdown();
 
     SegmentReader reader = getOnlySegmentReader(DirectoryReader.open(ram));
     FieldInfos fi = reader.getFieldInfos();
@@ -118,7 +118,7 @@
     // force merge
     writer.forceMerge(1);
     // flush
-    writer.close();
+    writer.shutdown();
 
     SegmentReader reader = getOnlySegmentReader(DirectoryReader.open(ram));
     FieldInfos fi = reader.getFieldInfos();
@@ -166,7 +166,7 @@
     writer.forceMerge(1);
 
     // flush
-    writer.close();
+    writer.shutdown();
 
     SegmentReader reader = getOnlySegmentReader(DirectoryReader.open(ram));
     FieldInfos fi = reader.getFieldInfos();
@@ -212,7 +212,7 @@
     // force merge
     writer.forceMerge(1);
     // flush
-    writer.close();
+    writer.shutdown();
 
     assertNoNrm(ram);
     ram.close();
@@ -306,7 +306,7 @@
     }
     ir1.close();
     ir2.close();
-    riw.close();
+    riw.shutdown();
     dir.close();
     return norms1;
   }
Index: lucene/core/src/test/org/apache/lucene/index/TestIndexWriterReader.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestIndexWriterReader.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestIndexWriterReader.java	(working copy)
@@ -102,14 +102,14 @@
     DirectoryReader reader = writer.getReader();
     writer.commit(); // no changes that are not visible to the reader
     assertTrue(reader.isCurrent());
-    writer.close();
+    writer.shutdown();
     assertTrue(reader.isCurrent()); // all changes are visible to the reader
     iwc = newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()));
     writer = new IndexWriter(dir1, iwc);
     assertTrue(reader.isCurrent());
     writer.addDocument(DocHelper.createDocument(1, "x", 1+random().nextInt(5)));
     assertTrue(reader.isCurrent()); // segments in ram but IW is different to the readers one
-    writer.close();
+    writer.shutdown();
     assertFalse(reader.isCurrent()); // segments written
     reader.close();
     dir1.close();
@@ -161,7 +161,7 @@
     
     r1.close();
     assertTrue(r2.isCurrent());
-    writer.close();
+    writer.shutdown();
     assertTrue(r2.isCurrent());
     
     DirectoryReader r3 = DirectoryReader.open(dir1);
@@ -177,7 +177,7 @@
     assertTrue(r2.isCurrent());
     assertTrue(r3.isCurrent());
 
-    writer.close();
+    writer.shutdown();
 
     assertFalse(r2.isCurrent());
     assertTrue(!r3.isCurrent());
@@ -196,7 +196,7 @@
     Document doc = new Document();
     doc.add(newTextField("field", "a b c", Field.Store.NO));
     writer.addDocument(doc);
-    writer.close();
+    writer.shutdown();
     
     iwc = newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()));
     writer = new IndexWriter(dir, iwc);
@@ -217,7 +217,7 @@
     assertTrue(nrtReader.isCurrent()); // nothing was committed yet so we are still current
     assertEquals(2, nrtReader.maxDoc()); // sees the actual document added
     assertEquals(1, dirReader.maxDoc());
-    writer.close(); // close is actually a commit both should see the changes
+    writer.shutdown(); // close is actually a commit both should see the changes
     assertTrue(nrtReader.isCurrent()); 
     assertFalse(dirReader.isCurrent()); // this reader has been opened before the writer was closed / committed
     
@@ -253,7 +253,7 @@
     Directory dir2 = newDirectory();
     IndexWriter writer2 = new IndexWriter(dir2, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random())));
     createIndexNoClose(!doFullMerge, "index2", writer2);
-    writer2.close();
+    writer2.shutdown();
 
     DirectoryReader r0 = writer.getReader();
     assertTrue(r0.isCurrent());
@@ -279,7 +279,7 @@
     StoredDocument doc150 = r1.document(150);
     assertEquals("index2", doc150.get("indexname"));
     r1.close();
-    writer.close();
+    writer.shutdown();
     dir1.close();
     dir2.close();
   }
@@ -294,7 +294,7 @@
     Directory dir2 = newDirectory();
     IndexWriter writer2 = new IndexWriter(dir2, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random())));
     createIndexNoClose(!doFullMerge, "index2", writer2);
-    writer2.close();
+    writer2.shutdown();
 
     writer.addIndexes(dir2);
     writer.addIndexes(dir2);
@@ -306,7 +306,7 @@
     assertEquals(500, r1.maxDoc());
     
     r1.close();
-    writer.close();
+    writer.shutdown();
     dir1.close();
     dir2.close();
   }
@@ -352,14 +352,14 @@
     r2.close();
     r3.close();
     r4.close();
-    writer.close();
+    writer.shutdown();
         
     // reopen the writer to verify the delete made it to the directory
     writer = new IndexWriter(dir1, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random())));
     IndexReader w2r1 = writer.getReader();
     assertEquals(0, count(new Term("id", id10), w2r1));
     w2r1.close();
-    writer.close();
+    writer.shutdown();
     dir1.close();
   }
 
@@ -419,7 +419,7 @@
         writer.addDocument(doc);
       }
         
-      writer.close();
+      writer.shutdown();
       
       readers = new IndexReader[numDirs];
       for (int i = 0; i < numDirs; i++)
@@ -439,8 +439,10 @@
       didClose = true;
       if (doWait) {
         mainWriter.waitForMerges();
+      } else {
+        mainWriter.abortMerges();
       }
-      mainWriter.close(doWait);
+      mainWriter.shutdown();
     }
 
     void closeDir() throws Throwable {
@@ -555,7 +557,7 @@
     r2.close();
     r3.close();
     iwr2.close();
-    writer.close();
+    writer.shutdown();
 
     // test whether the changes made it to the directory
     writer = new IndexWriter(dir1, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random())));
@@ -563,7 +565,7 @@
     // insure the deletes were actually flushed to the directory
     assertEquals(200, w2r1.maxDoc());
     w2r1.close();
-    writer.close();
+    writer.shutdown();
 
     dir1.close();
   }
@@ -588,7 +590,7 @@
     if (!multiSegment) {
       w.forceMerge(1);
     }
-    w.close();
+    w.shutdown();
   }
 
   public static void createIndexNoClose(boolean multiSegment, String indexName,
@@ -644,7 +646,7 @@
     writer.forceMerge(1);
     assertTrue(warmer.warmCount > count);
     
-    writer.close();
+    writer.shutdown();
     r1.close();
     dir1.close();
   }
@@ -675,7 +677,7 @@
       r1 = r2;
     }
     assertEquals(110, r1.numDocs());
-    writer.close();
+    writer.shutdown();
     r1.close();
     dir1.close();
   }
@@ -689,7 +691,7 @@
     createIndexNoClose(false, "test", writer);
 
     DirectoryReader r = writer.getReader();
-    writer.close();
+    writer.shutdown();
 
     TestUtil.checkIndex(dir1);
 
@@ -790,7 +792,7 @@
       assertEquals("openDeleted=" + openDeletedFiles, 0, openDeletedFiles.size());
     }
 
-    writer.close();
+    writer.shutdown();
 
     dir1.close();
   }
@@ -879,7 +881,7 @@
     assertTrue("no documents found at all", sum > 0);
 
     assertEquals(0, excs.size());
-    writer.close();
+    writer.shutdown();
 
     r.close();
     dir1.close();
@@ -900,7 +902,7 @@
 
     IndexReader r = w.getReader();
     w.forceMergeDeletes();
-    w.close();
+    w.shutdown();
     r.close();
     r = DirectoryReader.open(dir);
     assertEquals(1, r.numDocs());
@@ -934,7 +936,7 @@
     assertEquals(0, r.numDocs());
     r.close();
 
-    w.close();
+    w.shutdown();
     dir.close();
   }
   
@@ -945,7 +947,7 @@
     IndexReader r = w.getReader();
     assertEquals(0, r.numDocs());
     r.close();
-    w.close();
+    w.shutdown();
     dir.close();
   }
 
@@ -975,7 +977,7 @@
       w.addDocument(doc);
     }
     w.waitForMerges();
-    w.close();
+    w.shutdown();
     dir.close();
     assertTrue(didWarm.get());
   }
@@ -1015,7 +1017,7 @@
       w.addDocument(doc);
     }
     w.waitForMerges();
-    w.close();
+    w.shutdown();
     dir.close();
     assertTrue(didWarm.get());
   }
@@ -1052,7 +1054,7 @@
 
     r3.close();
 
-    w.close();
+    w.shutdown();
     d.close();
   }
   
@@ -1107,7 +1109,7 @@
       }
     }
     
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
 
@@ -1129,7 +1131,7 @@
       assertTrue(r.leaves().size() < 100);
       r.close();
     }
-    w.close();
+    w.shutdown();
     dir.close();
   }
 }
Index: lucene/core/src/test/org/apache/lucene/index/TestRollback.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestRollback.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/index/TestRollback.java	(working copy)
@@ -34,7 +34,7 @@
       doc.add(newStringField("pk", Integer.toString(i), Field.Store.YES));
       rw.addDocument(doc);
     }
-    rw.close();
+    rw.shutdown();
 
     // If buffer size is small enough to cause a flush, errors ensue...
     IndexWriter w = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random())).setMaxBufferedDocs(2).setOpenMode(IndexWriterConfig.OpenMode.APPEND));
Index: lucene/core/src/test/org/apache/lucene/TestSearchForDuplicates.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/TestSearchForDuplicates.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/TestSearchForDuplicates.java	(working copy)
@@ -84,7 +84,7 @@
         d.add(new IntField(ID_FIELD, j, Field.Store.YES));
         writer.addDocument(d);
       }
-      writer.close();
+      writer.shutdown();
 
       // try a search without OR
       IndexReader reader = DirectoryReader.open(directory);
Index: lucene/core/src/test/org/apache/lucene/util/junitcompat/TestFailOnFieldCacheInsanity.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/util/junitcompat/TestFailOnFieldCacheInsanity.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/util/junitcompat/TestFailOnFieldCacheInsanity.java	(working copy)
@@ -48,7 +48,7 @@
       w.addDocument(doc);
       w.forceMerge(1);
       r = w.getReader();
-      w.close();
+      w.shutdown();
 
       subR = r.leaves().get(0).reader();
     }
Index: lucene/core/src/test/org/apache/lucene/util/junitcompat/TestFailIfUnreferencedFiles.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/util/junitcompat/TestFailIfUnreferencedFiles.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/util/junitcompat/TestFailIfUnreferencedFiles.java	(working copy)
@@ -44,7 +44,7 @@
       dir.setAssertNoUnrefencedFilesOnClose(true);
       IndexWriter iw = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, null));
       iw.addDocument(new Document());
-      iw.close();
+      iw.shutdown();
       IndexOutput output = dir.createOutput("_hello.world", IOContext.DEFAULT);
       output.writeString("i am unreferenced!");
       output.close();
Index: lucene/core/src/test/org/apache/lucene/util/TestFieldCacheSanityChecker.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/util/TestFieldCacheSanityChecker.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/util/TestFieldCacheSanityChecker.java	(working copy)
@@ -69,8 +69,8 @@
         wB.addDocument(doc);
       }
     }
-    wA.close();
-    wB.close();
+    wA.shutdown();
+    wB.shutdown();
     DirectoryReader rA = DirectoryReader.open(dirA);
     readerA = SlowCompositeReaderWrapper.wrap(rA);
     readerAclone = SlowCompositeReaderWrapper.wrap(rA);
Index: lucene/core/src/test/org/apache/lucene/util/fst/TestFSTs.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/util/fst/TestFSTs.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/util/fst/TestFSTs.java	(working copy)
@@ -321,7 +321,7 @@
       docCount++;
     }
     IndexReader r = DirectoryReader.open(writer, true);
-    writer.close();
+    writer.shutdown();
     final PositiveIntOutputs outputs = PositiveIntOutputs.getSingleton();
 
     final boolean doRewrite = random().nextBoolean();
@@ -779,14 +779,14 @@
     System.out.println("DOT before rewrite");
     Writer w = new OutputStreamWriter(new FileOutputStream("/mnt/scratch/before.dot"));
     Util.toDot(fst, w, false, false);
-    w.close();
+    w.shutdown();
 
     final FST<Object> rewrite = new FST<Object>(fst, 1, 100);
 
     System.out.println("DOT after rewrite");
     w = new OutputStreamWriter(new FileOutputStream("/mnt/scratch/after.dot"));
     Util.toDot(rewrite, w, false, false);
-    w.close();
+    w.shutdown();
   }
   */
 
@@ -885,7 +885,7 @@
       // turn writer into reader:
       final IndexReader r = w.getReader();
       final IndexSearcher s = newSearcher(r);
-      w.close();
+      w.shutdown();
 
       final List<String> allIDsList = new ArrayList<>(allIDs);
       final List<String> sortedAllIDsList = new ArrayList<>(allIDsList);
@@ -1009,7 +1009,7 @@
       System.out.println("TEST: got reader=" + r);
     }
     IndexSearcher s = newSearcher(r);
-    w.close();
+    w.shutdown();
 
     final List<String> allTermsList = new ArrayList<>(allTerms);
     Collections.shuffle(allTermsList, random());
@@ -1237,7 +1237,7 @@
     final FST<Long> fst = builder.finish();
     //Writer w = new OutputStreamWriter(new FileOutputStream("out.dot"));
     //Util.toDot(fst, w, false, false);
-    //w.close();
+    //w.shutdown();
 
     Util.TopResults<Long> res = Util.shortestPaths(fst,
                                                   fst.getFirstArc(new FST.Arc<Long>()),
@@ -1332,7 +1332,7 @@
     final FST<Pair<Long,Long>> fst = builder.finish();
     //Writer w = new OutputStreamWriter(new FileOutputStream("out.dot"));
     //Util.toDot(fst, w, false, false);
-    //w.close();
+    //w.shutdown();
 
     Util.TopResults<Pair<Long,Long>> res = Util.shortestPaths(fst,
                                                              fst.getFirstArc(new FST.Arc<Pair<Long,Long>>()),
@@ -1392,7 +1392,7 @@
     //System.out.println("SAVE out.dot");
     //Writer w = new OutputStreamWriter(new FileOutputStream("out.dot"));
     //Util.toDot(fst, w, false, false);
-    //w.close();
+    //w.shutdown();
 
     BytesReader reader = fst.getBytesReader();
 
@@ -1514,7 +1514,7 @@
     //System.out.println("SAVE out.dot");
     //Writer w = new OutputStreamWriter(new FileOutputStream("out.dot"));
     //Util.toDot(fst, w, false, false);
-    //w.close();
+    //w.shutdown();
 
     BytesReader reader = fst.getBytesReader();
 
Index: lucene/core/src/test/org/apache/lucene/document/TestDocument.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/document/TestDocument.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/document/TestDocument.java	(working copy)
@@ -214,7 +214,7 @@
     assertEquals(1, hits.length);
     
     doAssert(searcher.doc(hits[0].doc));
-    writer.close();
+    writer.shutdown();
     reader.close();
     dir.close();
   }
@@ -246,7 +246,7 @@
     assertEquals(1, hits.length);
     
     doAssert(searcher.doc(hits[0].doc));
-    writer.close();
+    writer.shutdown();
     reader.close();
     dir.close();    
   }
@@ -337,7 +337,7 @@
       else if (f.stringValue().equals("id3")) result |= 4;
       else fail("unexpected id field");
     }
-    writer.close();
+    writer.shutdown();
     reader.close();
     dir.close();
     assertEquals("did not see all IDs", 7, result);
@@ -374,7 +374,7 @@
     assertNull(sdoc.get("somethingElse"));
     assertArrayEquals(new String[] { "5", "4" }, sdoc.getValues("int"));
     ir.close();
-    iw.close();
+    iw.shutdown();
     dir.close();
   }
 }
Index: lucene/core/src/test/org/apache/lucene/document/TestBinaryDocument.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/document/TestBinaryDocument.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/document/TestBinaryDocument.java	(working copy)
@@ -72,7 +72,7 @@
     String stringFldStoredTest = docFromReader.get("stringStored");
     assertTrue(stringFldStoredTest.equals(binaryValStored));
     
-    writer.close();    
+    writer.shutdown();    
     reader.close();
     dir.close();
   }
@@ -101,7 +101,7 @@
     assertTrue(binaryFldCompressedTest.equals(binaryValCompressed));
     assertTrue(CompressionTools.decompressString(docFromReader.getBinaryValue("stringCompressed")).equals(binaryValCompressed));
 
-    writer.close();
+    writer.shutdown();
     reader.close();
     dir.close();
   }
Index: lucene/core/src/test/org/apache/lucene/TestMergeSchedulerExternal.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/TestMergeSchedulerExternal.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/TestMergeSchedulerExternal.java	(working copy)
@@ -103,7 +103,7 @@
       writer.addDocument(doc);
 
     ((MyMergeScheduler) writer.getConfig().getMergeScheduler()).sync();
-    writer.close();
+    writer.shutdown();
     
     assertTrue(mergeThreadCreated);
     assertTrue(mergeCalled);
@@ -142,7 +142,7 @@
     writer.addDocument(new Document());
     writer.commit(); // trigger flush
     writer.forceMerge(1);
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
   
Index: lucene/core/src/test/org/apache/lucene/analysis/TestMockAnalyzer.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/analysis/TestMockAnalyzer.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/analysis/TestMockAnalyzer.java	(working copy)
@@ -335,7 +335,7 @@
     assertEquals(1 + endOffset + offsetGap, dpe.endOffset());
     assertEquals(null, te.next());
     reader.close();
-    writer.close();
+    writer.shutdown();
     writer.w.getDirectory().close();
   }
 
Index: lucene/core/src/test/org/apache/lucene/analysis/TestCachingTokenFilter.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/analysis/TestCachingTokenFilter.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/analysis/TestCachingTokenFilter.java	(working copy)
@@ -97,7 +97,7 @@
     assertEquals(1, termPositions.freq());
     assertEquals(2, termPositions.nextPosition());
     reader.close();
-    writer.close();
+    writer.shutdown();
     // 3) reset stream and consume tokens again
     stream.reset();
     checkTokens(stream);
Index: lucene/core/src/test/org/apache/lucene/analysis/TestGraphTokenizers.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/analysis/TestGraphTokenizers.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/analysis/TestGraphTokenizers.java	(working copy)
@@ -445,7 +445,7 @@
     final String s = a.toDot();
     Writer w = new OutputStreamWriter(new FileOutputStream("/x/tmp/out.dot"));
     w.write(s);
-    w.close();
+    w.shutdown();
     System.out.println("TEST: saved to /x/tmp/out.dot");
   }
   */
Index: lucene/core/src/test/org/apache/lucene/TestExternalCodecs.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/TestExternalCodecs.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/TestExternalCodecs.java	(working copy)
@@ -130,7 +130,7 @@
     }
     r.close();
 
-    w.close();
+    w.shutdown();
 
     dir.close();
   }
Index: lucene/core/src/test/org/apache/lucene/TestSearch.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/TestSearch.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/TestSearch.java	(working copy)
@@ -50,7 +50,7 @@
         d.add(newTextField("foo", "bar", Field.Store.YES));
         writer.addDocument(d);
       } finally {
-        writer.close();
+        writer.shutdown();
       }
       
       IndexReader reader = DirectoryReader.open(directory);
@@ -130,7 +130,7 @@
         d.add(new IntField("id", j, Field.Store.NO));
         writer.addDocument(d);
       }
-      writer.close();
+      writer.shutdown();
 
       IndexReader reader = DirectoryReader.open(directory);
       IndexSearcher searcher = newSearcher(reader);
Index: lucene/core/src/test/org/apache/lucene/store/TestNRTCachingDirectory.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/store/TestNRTCachingDirectory.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/store/TestNRTCachingDirectory.java	(working copy)
@@ -85,7 +85,7 @@
     }
 
     // Close should force cache to clear since all files are sync'd
-    w.close();
+    w.shutdown();
 
     final String[] cachedFiles = cachedDir.listCachedFiles();
     for(String file : cachedFiles) {
Index: lucene/core/src/test/org/apache/lucene/store/TestWindowsMMap.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/store/TestWindowsMMap.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/store/TestWindowsMMap.java	(working copy)
@@ -89,7 +89,7 @@
     }
     
     reader.close();
-    writer.close();
+    writer.shutdown();
     rmDir(dirPath);
   }
 
Index: lucene/core/src/test/org/apache/lucene/store/TestMultiMMap.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/store/TestMultiMMap.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/store/TestMultiMMap.java	(working copy)
@@ -323,7 +323,7 @@
       writer.addDocument(doc);
     }
     IndexReader reader = writer.getReader();
-    writer.close();
+    writer.shutdown();
     
     int numAsserts = atLeast(100);
     for (int i = 0; i < numAsserts; i++) {
Index: lucene/core/src/test/org/apache/lucene/store/TestLockFactory.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/store/TestLockFactory.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/store/TestLockFactory.java	(working copy)
@@ -71,7 +71,7 @@
                        lock.lockAttempts > 0);
         }
         
-        writer.close();
+        writer.shutdown();
     }
 
     // Verify: we can use the NoLockFactory with RAMDirectory w/ no
@@ -96,9 +96,9 @@
             fail("Should not have hit an IOException with no locking");
         }
 
-        writer.close();
+        writer.shutdown();
         if (writer2 != null) {
-            writer2.close();
+            writer2.shutdown();
         }
     }
 
@@ -120,9 +120,9 @@
         } catch (IOException e) {
         }
 
-        writer.close();
+        writer.shutdown();
         if (writer2 != null) {
-            writer2.close();
+            writer2.shutdown();
         }
     }
     
@@ -155,7 +155,7 @@
         // First create a 1 doc index:
         IndexWriter w = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())).setOpenMode(OpenMode.CREATE));
         addDoc(w);
-        w.close();
+        w.shutdown();
 
         WriterThread writer = new WriterThread(100, dir);
         SearcherThread searcher = new SearcherThread(100, dir);
@@ -321,7 +321,7 @@
                         break;
                     }
                     try {
-                        writer.close();
+                        writer.shutdown();
                     } catch (IOException e) {
                         hitException = true;
                         System.out.println("Stress Test Index Writer: close hit unexpected exception: " + e.toString());
Index: lucene/core/src/test/org/apache/lucene/store/TestFileSwitchDirectory.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/store/TestFileSwitchDirectory.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/store/TestFileSwitchDirectory.java	(working copy)
@@ -77,7 +77,7 @@
       assertFalse(fileExtensions.contains(ext));
     }
     reader.close();
-    writer.close();
+    writer.shutdown();
 
     files = fsd.listAll();
     for(int i=0;i<files.length;i++) {
Index: lucene/core/src/test/org/apache/lucene/store/TestBufferedIndexInput.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/store/TestBufferedIndexInput.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/store/TestBufferedIndexInput.java	(working copy)
@@ -271,7 +271,7 @@
         hits = searcher.search(new TermQuery(aaa), null, 1000).scoreDocs;
         dir.tweakBufferSizes();
         assertEquals(35, hits.length);
-        writer.close();
+        writer.shutdown();
         reader.close();
       } finally {
         TestUtil.rmDir(indexDir);
Index: lucene/core/src/test/org/apache/lucene/store/TestRAMDirectory.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/store/TestRAMDirectory.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/store/TestRAMDirectory.java	(working copy)
@@ -63,7 +63,7 @@
       writer.addDocument(doc);
     }
     assertEquals(docsToAdd, writer.maxDoc());
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
   
@@ -136,7 +136,7 @@
     writer.forceMerge(1);
     assertEquals(ramDir.sizeInBytes(), ramDir.getRecomputedSizeInBytes());
     
-    writer.close();
+    writer.shutdown();
   }
 
   @Override
Index: lucene/core/src/test/org/apache/lucene/store/TestMockDirectoryWrapper.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/store/TestMockDirectoryWrapper.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/store/TestMockDirectoryWrapper.java	(working copy)
@@ -34,7 +34,7 @@
     } catch (Exception expected) {
       assertTrue(expected.getMessage().contains("there are still open locks"));
     }
-    iw.close();
+    iw.shutdown();
     dir.close();
   }
   
@@ -48,7 +48,7 @@
     } catch (Exception expected) {
       assertTrue(expected.getMessage().contains("there are still open locks"));
     }
-    iw.close();
+    iw.shutdown();
     dir.close();
   }
   
Index: lucene/core/src/test/org/apache/lucene/codecs/compressing/TestCompressingTermVectorsFormat.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/codecs/compressing/TestCompressingTermVectorsFormat.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/codecs/compressing/TestCompressingTermVectorsFormat.java	(working copy)
@@ -69,7 +69,7 @@
       // expected exception
     }
     ir.close();
-    iw.close();
+    iw.shutdown();
     dir.close();
   }
 }
Index: lucene/core/src/test/org/apache/lucene/codecs/compressing/TestCompressingStoredFieldsFormat.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/codecs/compressing/TestCompressingStoredFieldsFormat.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/codecs/compressing/TestCompressingStoredFieldsFormat.java	(working copy)
@@ -85,7 +85,7 @@
       }
       // Only one .fdt and one .fdx files must have been found
       assertEquals(2, counter);
-      iw.close();
+      iw.shutdown();
       dir.close();
     }
   }
Index: lucene/core/src/test/org/apache/lucene/codecs/perfield/TestPerFieldDocValuesFormat.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/codecs/perfield/TestPerFieldDocValuesFormat.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/codecs/perfield/TestPerFieldDocValuesFormat.java	(working copy)
@@ -100,7 +100,7 @@
     doc.add(new NumericDocValuesField("dv1", 5));
     doc.add(new BinaryDocValuesField("dv2", new BytesRef("hello world")));
     iwriter.addDocument(doc);
-    iwriter.close();
+    iwriter.shutdown();
     
     // Now search the index:
     IndexReader ireader = DirectoryReader.open(directory); // read-only=true
Index: lucene/core/src/test/org/apache/lucene/codecs/perfield/TestPerFieldPostingsFormat2.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/codecs/perfield/TestPerFieldPostingsFormat2.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/codecs/perfield/TestPerFieldPostingsFormat2.java	(working copy)
@@ -110,7 +110,7 @@
     TestUtil.checkIndex(dir);
     writer.forceMerge(1);
     assertEquals(30, writer.maxDoc());
-    writer.close();
+    writer.shutdown();
     dir.close();
   }
 
@@ -138,7 +138,7 @@
     }
     addDocs3(writer, 10);
     writer.commit();
-    writer.close();
+    writer.shutdown();
 
     assertQuery(new Term("content", "ccc"), dir, 10);
     assertQuery(new Term("content", "aaa"), dir, 10);
@@ -179,7 +179,7 @@
     }
     writer.forceMerge(1);
     assertEquals(40, writer.maxDoc());
-    writer.close();
+    writer.shutdown();
     assertQuery(new Term("content", "ccc"), dir, 10);
     assertQuery(new Term("content", "bbb"), dir, 20);
     assertQuery(new Term("content", "aaa"), dir, 10);
@@ -262,7 +262,7 @@
       }
       writer.commit();
       assertEquals((i + 1) * docsPerRound, writer.maxDoc());
-      writer.close();
+      writer.shutdown();
     }
     dir.close();
   }
@@ -319,7 +319,7 @@
       dateField.setStringValue(Integer.toString(random().nextInt(100)));
       iw.addDocument(doc);
     }
-    iw.close();
+    iw.shutdown();
     dir.close(); // checkindex
   }
 }
Index: lucene/core/src/test/org/apache/lucene/codecs/lucene40/TestReuseDocsEnum.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/codecs/lucene40/TestReuseDocsEnum.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/codecs/lucene40/TestReuseDocsEnum.java	(working copy)
@@ -71,6 +71,7 @@
       
       assertEquals(terms.size(), enums.size());
     }
+    writer.commit();
     IOUtils.close(writer, open, dir);
   }
   
@@ -115,7 +116,8 @@
       }
       assertEquals(1, enums.size());  
     }
-    IOUtils.close(writer, open, dir);
+    writer.shutdown();
+    IOUtils.close(open, dir);
   }
   
   // make sure we never reuse from another reader even if it is the same field & codec etc
@@ -159,7 +161,8 @@
       }
       assertEquals(terms.size(), enums.size());
     }
-    IOUtils.close(writer, firstReader, secondReader, dir);
+    writer.shutdown();
+    IOUtils.close(firstReader, secondReader, dir);
   }
   
   public DocsEnum randomDocsEnum(String field, BytesRef term, List<AtomicReaderContext> readers, Bits bits) throws IOException {
Index: lucene/core/src/test/org/apache/lucene/codecs/lucene40/TestLucene40PostingsReader.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/codecs/lucene40/TestLucene40PostingsReader.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/codecs/lucene40/TestLucene40PostingsReader.java	(working copy)
@@ -98,7 +98,7 @@
       // delete 1-100% of docs
       iw.deleteDocuments(new Term("title", terms[random().nextInt(terms.length)]));
     }
-    iw.close();
+    iw.shutdown();
     dir.close(); // checkindex
   }
   
Index: lucene/core/src/test/org/apache/lucene/codecs/lucene41/TestBlockPostingsFormat2.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/codecs/lucene41/TestBlockPostingsFormat2.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/codecs/lucene41/TestBlockPostingsFormat2.java	(working copy)
@@ -52,12 +52,12 @@
   
   @Override
   public void tearDown() throws Exception {
-    iw.close();
+    iw.shutdown();
     TestUtil.checkIndex(dir); // for some extra coverage, checkIndex before we forceMerge
     iwc.setOpenMode(OpenMode.APPEND);
     IndexWriter iw = new IndexWriter(dir, iwc.clone());
     iw.forceMerge(1);
-    iw.close();
+    iw.shutdown();
     dir.close(); // just force a checkindex for now
     super.tearDown();
   }
Index: lucene/core/src/test/org/apache/lucene/codecs/lucene41/TestBlockPostingsFormat3.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/codecs/lucene41/TestBlockPostingsFormat3.java	(revision 1584870)
+++ lucene/core/src/test/org/apache/lucene/codecs/lucene41/TestBlockPostingsFormat3.java	(working copy)
@@ -134,13 +134,13 @@
       field8.setStringValue(stringValue);
       iw.addDocument(doc);
     }
-    iw.close();
+    iw.shutdown();
     verify(dir);
     TestUtil.checkIndex(dir); // for some extra coverage, checkIndex before we forceMerge
     iwc.setOpenMode(OpenMode.APPEND);
     IndexWriter iw2 = new IndexWriter(dir, iwc.clone());
     iw2.forceMerge(1);
-    iw2.close();
+    iw2.shutdown();
     verify(dir);
     dir.close();
   }
Index: lucene/core/src/java/org/apache/lucene/index/DocumentsWriter.java
===================================================================
--- lucene/core/src/java/org/apache/lucene/index/DocumentsWriter.java	(revision 1584870)
+++ lucene/core/src/java/org/apache/lucene/index/DocumentsWriter.java	(working copy)
@@ -424,9 +424,12 @@
       final DocumentsWriterPerThread dwpt = perThread.dwpt;
       final int dwptNumDocs = dwpt.getNumDocsInRAM();
       try {
-        final int docCount = dwpt.updateDocuments(docs, analyzer, delTerm);
-        numDocsInRAM.addAndGet(docCount);
+        dwpt.updateDocuments(docs, analyzer, delTerm);
       } finally {
+        // We don't know how many documents were actually
+        // counted as indexed, so we must subtract here to
+        // accumulate our separate counter:
+        numDocsInRAM.addAndGet(dwpt.getNumDocsInRAM() - dwptNumDocs);
         if (dwpt.checkAndResetHasAborted()) {
           if (!dwpt.pendingFilesToDelete().isEmpty()) {
             putEvent(new DeleteNewFilesEvent(dwpt.pendingFilesToDelete()));
@@ -463,8 +466,11 @@
       final int dwptNumDocs = dwpt.getNumDocsInRAM();
       try {
         dwpt.updateDocument(doc, analyzer, delTerm); 
-        numDocsInRAM.incrementAndGet();
       } finally {
+        // We don't know whether the document actually
+        // counted as being indexed, so we must subtract here to
+        // accumulate our separate counter:
+        numDocsInRAM.addAndGet(dwpt.getNumDocsInRAM() - dwptNumDocs);
         if (dwpt.checkAndResetHasAborted()) {
           if (!dwpt.pendingFilesToDelete().isEmpty()) {
             putEvent(new DeleteNewFilesEvent(dwpt.pendingFilesToDelete()));
@@ -585,6 +591,7 @@
     while (!numDocsInRAM.compareAndSet(oldValue, oldValue - numFlushed)) {
       oldValue = numDocsInRAM.get();
     }
+    assert numDocsInRAM.get() >= 0;
   }
   
   // for asserts
Index: lucene/core/src/java/org/apache/lucene/index/MergePolicy.java
===================================================================
--- lucene/core/src/java/org/apache/lucene/index/MergePolicy.java	(revision 1584870)
+++ lucene/core/src/java/org/apache/lucene/index/MergePolicy.java	(working copy)
@@ -345,9 +345,9 @@
   }
 
   /** Thrown when a merge was explicity aborted because
-   *  {@link IndexWriter#close(boolean)} was called with
-   *  <code>false</code>.  Normally this exception is
-   *  privately caught and suppresed by {@link IndexWriter}.  */
+   *  {@link IndexWriter#abortMerges} was called.  Normally
+   *  this exception is privately caught and suppresed by
+   *  {@link IndexWriter}. */
   public static class MergeAbortedException extends IOException {
     /** Create a {@link MergeAbortedException}. */
     public MergeAbortedException() {
Index: lucene/core/src/java/org/apache/lucene/index/IndexWriter.java
===================================================================
--- lucene/core/src/java/org/apache/lucene/index/IndexWriter.java	(revision 1584870)
+++ lucene/core/src/java/org/apache/lucene/index/IndexWriter.java	(working copy)
@@ -59,6 +59,7 @@
 import org.apache.lucene.util.IOUtils;
 import org.apache.lucene.util.InfoStream;
 import org.apache.lucene.util.ThreadInterruptedException;
+import org.apache.lucene.util.Version;
 
 /**
   An <code>IndexWriter</code> creates and maintains an index.
@@ -843,109 +844,113 @@
     }
   }
 
-  /**
-   * Commits all changes to an index, waits for pending merges
-   * to complete, and closes all associated files.  
-   * <p>
-   * This is a "slow graceful shutdown" which may take a long time
-   * especially if a big merge is pending: If you only want to close
-   * resources use {@link #rollback()}. If you only want to commit
-   * pending changes and close resources see {@link #close(boolean)}.
-   * <p>
-   * Note that this may be a costly
-   * operation, so, try to re-use a single writer instead of
-   * closing and opening a new one.  See {@link #commit()} for
-   * caveats about write caching done by some IO devices.
+  /** Gracefully shut down this {@code IndexWriter} instance,
+   *  by writing any changes, waiting for any running
+   *  merges, committing, and closing.  If you don't want to
+   *  wait for merges, use {@link #shutdown(boolean)} instead.
    *
-   * <p> If an Exception is hit during close, eg due to disk
-   * full or some other reason, then both the on-disk index
-   * and the internal state of the IndexWriter instance will
-   * be consistent.  However, the close will not be complete
-   * even though part of it (flushing buffered documents)
-   * may have succeeded, so the write lock will still be
-   * held.</p>
+   *  <p>If you called prepareCommit but failed to call
+   *  commit, this method will throw {@code
+   *  IllegalStateException} and the {@code IndexWriter}
+   *  will not be closed.
    *
-   * <p> If you can correct the underlying cause (eg free up
-   * some disk space) then you can call close() again.
-   * Failing that, if you want to force the write lock to be
-   * released (dangerous, because you may then lose buffered
-   * docs in the IndexWriter instance) then you can do
-   * something like this:</p>
+   *  <p>If this method throws any other
+   *  exception, the {@code IndexWriter} will be closed, but changes may have been
+   *  lost.
    *
-   * <pre class="prettyprint">
-   * try {
-   *   writer.close();
-   * } finally {
-   *   if (IndexWriter.isLocked(directory)) {
-   *     IndexWriter.unlock(directory);
-   *   }
-   * }
-   * </pre>
+   *  <p><b>NOTE</b>: You must ensure no
+   *  other threads are still making changes at the same
+   *  time that this method is invoked.  */
+  public void shutdown() throws IOException {
+    shutdown(true);
+  }
+
+  /** Gracefully shut down this {@code IndexWriter}
+   *  instance, with control over whether to wait for
+   *  merges.  See {@link #shutdown()}. */
+  public void shutdown(boolean waitForMerges) throws IOException {
+    if (pendingCommit != null) {
+      throw new IllegalStateException("cannot shutdown: prepareCommit was already called with no corresponding call to commit");
+    }
+    if (infoStream.isEnabled("IW")) {
+      infoStream.message("IW", "now flush at shutdown");
+    }
+    boolean success = false;
+    try {
+      flush(waitForMerges, true);
+      finishMerges(waitForMerges);
+      commit();
+      // TODO: we could just call rollback, but ... it's nice
+      // to catch IW bugs where after waitForMerges/commit we
+      // still have running merges / uncommitted changes, or
+      // tests that illegally leave threads indexing and then
+      // try to use shutdown:
+      close();
+      success = true;
+    } finally {
+      if (success == false) {
+        // Be certain to close the index on any exception
+        try {
+          rollback();
+        } catch (Throwable t) {
+          // Suppress so we keep throwing original exception
+        }
+      }
+    }
+  }
+  
+  /**
+   * Closes all open resources and releases the write lock.
+   * If there are running merges or uncommitted
+   * changes:
+   * <ul>
+   *   <li> If config.matchVersion >= LUCENE_50 then the
+   *        changes are silently discarded.
+   *   <li> Otherwise, a RuntimeException is thrown to
+   *        indicate what was lost, but the IndexWriter is
+   *        still closed.
+   * </ul>
    *
-   * after which, you must be certain not to use the writer
-   * instance anymore.</p>
-   *
-   * <p><b>NOTE</b>: if this method hits an OutOfMemoryError
-   * you should immediately close the writer, again.  See <a
-   * href="#OOME">above</a> for details.</p>
-   *
+   * Use {@link #shutdown} if you want to flush, commit, and
+   * wait for merges, before closing.
+   * 
    * @throws IOException if there is a low-level IO error
+   *   (the IndexWriter will still be closed)
+   * @throws RuntimeException if config.matchVersion <
+   *   LUCENE_50 and there were pending changes that were
+   *   lost (the IndexWriter will still be closed)
    */
   @Override
   public void close() throws IOException {
-    close(true);
-  }
 
-  /**
-   * Closes the index with or without waiting for currently
-   * running merges to finish.  This is only meaningful when
-   * using a MergeScheduler that runs merges in background
-   * threads.
-   *
-   * <p><b>NOTE</b>: if this method hits an OutOfMemoryError
-   * you should immediately close the writer, again.  See <a
-   * href="#OOME">above</a> for details.</p>
-   *
-   * <p><b>NOTE</b>: it is dangerous to always call
-   * close(false), especially when IndexWriter is not open
-   * for very long, because this can result in "merge
-   * starvation" whereby long merges will never have a
-   * chance to finish.  This will cause too many segments in
-   * your index over time.</p>
-   *
-   * @param waitForMerges if true, this call will block
-   * until all merges complete; else, it will ask all
-   * running merges to abort, wait until those merges have
-   * finished (which should be at most a few seconds), and
-   * then return.
-   */
-  public void close(boolean waitForMerges) throws IOException {
+    // If there are uncommitted changes, or still running
+    // merges, we will in fact close, but we'll throw an
+    // exception notifying the caller that they lost
+    // changes, if IWC.matchVersion is < 5.0:
+    boolean lostChanges = false;
 
-    // Ensure that only one thread actually gets to do the
-    // closing, and make sure no commit is also in progress:
-    synchronized(commitLock) {
-      if (shouldClose()) {
-        // If any methods have hit OutOfMemoryError, then abort
-        // on close, in case the internal state of IndexWriter
-        // or DocumentsWriter is corrupt
-        if (hitOOM) {
-          rollbackInternal();
-        } else {
-          closeInternal(waitForMerges, true);
+    // Only check for lost changes if the version earlier than 5.0:
+    if (config.getMatchVersion().onOrAfter(Version.LUCENE_50) == false) {
+      lostChanges = hasUncommittedChanges();
+      if (lostChanges == false) {
+        synchronized(this) {
+          if (pendingMerges.isEmpty() == false) {
+            lostChanges = true;
+          }
+          if (runningMerges.isEmpty() == false) {
+            lostChanges = true;
+          }
         }
       }
-      assert assertEventQueueAfterClose();
     }
-  }
 
-  private boolean assertEventQueueAfterClose() {
-    if (eventQueue.isEmpty()) {
-      return true;
+    // As long as there are no pending changes and no
+    // running merges, we just rollback to close:
+    rollback();
+
+    if (lostChanges) {
+      throw new RuntimeException("this writer is closed, but some pending changes or running merges were discarded; use shutdown to save pending changes and finish merges before closing");
     }
-    for (Event e : eventQueue) {
-      assert e instanceof DocumentsWriter.MergePendingEvent : e;
-    }
-    return true;
   }
 
   // Returns true if this thread should attempt to close, or
@@ -969,117 +974,6 @@
     }
   }
 
-  private void closeInternal(boolean waitForMerges, boolean doFlush) throws IOException {
-    boolean interrupted = false;
-    try {
-
-      if (pendingCommit != null) {
-        throw new IllegalStateException("cannot close: prepareCommit was already called with no corresponding call to commit");
-      }
-
-      if (infoStream.isEnabled("IW")) {
-        infoStream.message("IW", "now flush at close waitForMerges=" + waitForMerges);
-      }
-
-      docWriter.close();
-
-      try {
-        // Only allow a new merge to be triggered if we are
-        // going to wait for merges:
-        if (doFlush) {
-          flush(waitForMerges, true);
-        } else {
-          docWriter.abort(this); // already closed -- never sync on IW 
-        }
-        
-      } finally {
-        try {
-          // clean up merge scheduler in all cases, although flushing may have failed:
-          interrupted = Thread.interrupted();
-        
-          if (waitForMerges) {
-            try {
-              // Give merge scheduler last chance to run, in case
-              // any pending merges are waiting:
-              mergeScheduler.merge(this, MergeTrigger.CLOSING, false);
-            } catch (ThreadInterruptedException tie) {
-              // ignore any interruption, does not matter
-              interrupted = true;
-              if (infoStream.isEnabled("IW")) {
-                infoStream.message("IW", "interrupted while waiting for final merges");
-              }
-            }
-          }
-          
-          synchronized(this) {
-            for (;;) {
-              try {
-                finishMerges(waitForMerges && !interrupted);
-                break;
-              } catch (ThreadInterruptedException tie) {
-                // by setting the interrupted status, the
-                // next call to finishMerges will pass false,
-                // so it will not wait
-                interrupted = true;
-                if (infoStream.isEnabled("IW")) {
-                  infoStream.message("IW", "interrupted while waiting for merges to finish");
-                }
-              }
-            }
-            stopMerges = true;
-          }
-          
-        } finally {
-          // shutdown policy, scheduler and all threads (this call is not interruptible):
-          IOUtils.closeWhileHandlingException(mergePolicy, mergeScheduler);
-        }
-      }
-
-      if (infoStream.isEnabled("IW")) {
-        infoStream.message("IW", "now call final commit()");
-      }
-
-      if (doFlush) {
-        commitInternal();
-      }
-      processEvents(false, true);
-      synchronized(this) {
-        // commitInternal calls ReaderPool.commit, which
-        // writes any pending liveDocs from ReaderPool, so
-        // it's safe to drop all readers now:
-        readerPool.dropAll(true);
-        deleter.close();
-      }
-
-      if (infoStream.isEnabled("IW")) {
-        infoStream.message("IW", "at close: " + segString());
-      }
-
-      if (writeLock != null) {
-        writeLock.close();                          // release write lock
-        writeLock = null;
-      }
-      synchronized(this) {
-        closed = true;
-      }
-      assert docWriter.perThreadPool.numDeactivatedThreadStates() == docWriter.perThreadPool.getMaxThreadStates() : "" +  docWriter.perThreadPool.numDeactivatedThreadStates() + " " +  docWriter.perThreadPool.getMaxThreadStates();
-    } catch (OutOfMemoryError oom) {
-      handleOOM(oom, "closeInternal");
-    } finally {
-      synchronized(this) {
-        closing = false;
-        notifyAll();
-        if (!closed) {
-          if (infoStream.isEnabled("IW")) {
-            infoStream.message("IW", "hit exception while closing");
-          }
-        }
-      }
-      // finally, restore interrupt status:
-      if (interrupted) Thread.currentThread().interrupt();
-    }
-  }
-
   /** Returns the Directory used by this index. */
   public Directory getDirectory() {
     return directory;
@@ -1732,10 +1626,10 @@
    * you should immediately close the writer.  See <a
    * href="#OOME">above</a> for details.</p>
    *
-   * <p><b>NOTE</b>: if you call {@link #close(boolean)}
-   * with <tt>false</tt>, which aborts all running merges,
-   * then any thread still running this method might hit a
-   * {@link MergePolicy.MergeAbortedException}.
+   * <p><b>NOTE</b>: if you call {@link #abortMerges}, which
+   * aborts all running merges, then any thread still
+   * running this method might hit a {@link
+   * MergePolicy.MergeAbortedException}.
    *
    * @param maxNumSegments maximum number of segments left
    * in the index after merging finishes
@@ -1863,11 +1757,10 @@
    * you should immediately close the writer.  See <a
    * href="#OOME">above</a> for details.</p>
    *
-   * <p><b>NOTE</b>: if you call {@link #close(boolean)}
-   * with <tt>false</tt>, which aborts all running merges,
-   * then any thread still running this method might hit a
-   * {@link MergePolicy.MergeAbortedException}.
-   */
+   * <p><b>NOTE</b>: if you call {@link #abortMerges}, which
+   * aborts all running merges, then any thread still
+   * running this method might hit a {@link
+   * MergePolicy.MergeAbortedException}. */
   public void forceMergeDeletes(boolean doWait)
     throws IOException {
     ensureOpen();
@@ -2136,7 +2029,6 @@
         if (infoStream.isEnabled("IW") ) {
           infoStream.message("IW", "rollback: infos=" + segString(segmentInfos));
         }
-        
 
         assert testPoint("rollback before checkpoint");
 
@@ -2147,7 +2039,6 @@
 
         lastCommitChangeCount = changeCount;
         
-        processEvents(false, true);
         deleter.refresh();
         deleter.close();
 
@@ -2161,6 +2052,12 @@
     } catch (OutOfMemoryError oom) {
       handleOOM(oom, "rollbackInternal");
     } finally {
+      if (!success) {
+        // Must not hold IW's lock while closing
+        // mergePolicy/Scheduler: this can lead to deadlock,
+        // e.g. TestIW.testThreadInterruptDeadlock
+        IOUtils.closeWhileHandlingException(mergePolicy, mergeScheduler);
+      }
       synchronized(this) {
         if (!success) {
           // we tried to be nice about it: do the minimum
@@ -2174,7 +2071,7 @@
           }
           
           // close all the closeables we can (but important is readerPool and writeLock to prevent leaks)
-          IOUtils.closeWhileHandlingException(mergePolicy, mergeScheduler, readerPool, deleter, writeLock);
+          IOUtils.closeWhileHandlingException(readerPool, deleter, writeLock);
           writeLock = null;
         }
         closed = true;
@@ -2262,6 +2159,13 @@
     }
   }
 
+  /** Aborts running merges.  Be careful when using this
+   *  method: when you abort a long-running merge, you lose
+   *  a lot of work that must later be redone. */
+  public void abortMerges() {
+    finishMerges(false);
+  }
+
   private synchronized void finishMerges(boolean waitForMerges) {
     if (!waitForMerges) {
 
@@ -2613,7 +2517,7 @@
    * call.
    * 
    * <p>
-   * <b>NOTE</b>: if you call {@link #close(boolean)} with <tt>false</tt>, which
+   * <b>NOTE</b>: if you call {@link #abortMerges}, which
    * aborts all running merges, then any thread still running this method might
    * hit a {@link MergePolicy.MergeAbortedException}.
    * 
Index: lucene/core/src/java/org/apache/lucene/index/LiveIndexWriterConfig.java
===================================================================
--- lucene/core/src/java/org/apache/lucene/index/LiveIndexWriterConfig.java	(revision 1584870)
+++ lucene/core/src/java/org/apache/lucene/index/LiveIndexWriterConfig.java	(working copy)
@@ -527,6 +527,9 @@
     return sb.toString();
   }
 
-
-
+  /** Returns the {@code matchVersion} that was provided to
+   *  the constructor. */
+  public Version getMatchVersion() {
+    return matchVersion;
+  }
 }
Index: lucene/core/src/java/org/apache/lucene/index/IndexUpgrader.java
===================================================================
--- lucene/core/src/java/org/apache/lucene/index/IndexUpgrader.java	(revision 1584870)
+++ lucene/core/src/java/org/apache/lucene/index/IndexUpgrader.java	(working copy)
@@ -169,7 +169,7 @@
         infoStream.message("IndexUpgrader", "All segments upgraded to version " + Constants.LUCENE_MAIN_VERSION);
       }
     } finally {
-      w.close();
+      w.shutdown();
     }
   }
   
Index: solr/core/src/test/org/apache/solr/search/TestStressLucene.java
===================================================================
--- solr/core/src/test/org/apache/solr/search/TestStressLucene.java	(revision 1584870)
+++ solr/core/src/test/org/apache/solr/search/TestStressLucene.java	(working copy)
@@ -368,7 +368,7 @@
       thread.join();
     }
 
-    writer.close();
+    writer.shutdown();
     reader.close();
     dir.close();
   }
Index: solr/core/src/test/org/apache/solr/search/TestSort.java
===================================================================
--- solr/core/src/test/org/apache/solr/search/TestSort.java	(revision 1584870)
+++ solr/core/src/test/org/apache/solr/search/TestSort.java	(working copy)
@@ -219,7 +219,7 @@
           iw.commit();
         }
       }
-      iw.close();
+      iw.shutdown();
 
 
       DirectoryReader reader = DirectoryReader.open(dir);
Index: solr/core/src/test/org/apache/solr/spelling/IndexBasedSpellCheckerTest.java
===================================================================
--- solr/core/src/test/org/apache/solr/spelling/IndexBasedSpellCheckerTest.java	(revision 1584870)
+++ solr/core/src/test/org/apache/solr/spelling/IndexBasedSpellCheckerTest.java	(working copy)
@@ -297,7 +297,7 @@
       iw.addDocument(doc);
     }
     iw.forceMerge(1);
-    iw.close();
+    iw.shutdown();
     dir.close();
     indexDir.mkdirs();
     spellchecker.add(AbstractLuceneSpellChecker.INDEX_DIR, indexDir.getAbsolutePath());
Index: solr/core/src/test/org/apache/solr/core/SolrCoreCheckLockOnStartupTest.java
===================================================================
--- solr/core/src/test/org/apache/solr/core/SolrCoreCheckLockOnStartupTest.java	(revision 1584870)
+++ solr/core/src/test/org/apache/solr/core/SolrCoreCheckLockOnStartupTest.java	(working copy)
@@ -46,7 +46,7 @@
     new IndexWriter(
         directory,
         indexWriterConfig.setOpenMode(IndexWriterConfig.OpenMode.CREATE)
-    ).close();
+    ).shutdown();
     directory.close();
   }
 
@@ -68,7 +68,7 @@
     } finally {
       System.clearProperty("solr.tests.lockType");
       unIgnoreException("locked");
-      indexWriter.close();
+      indexWriter.shutdown();
       directory.close();
       deleteCore();
     }
@@ -95,7 +95,7 @@
     } finally {
       System.clearProperty("solr.tests.lockType");
       unIgnoreException("locked");
-      indexWriter.close();
+      indexWriter.shutdown();
       directory.close();
       deleteCore();
     }
Index: solr/core/src/test/org/apache/solr/core/TestArbitraryIndexDir.java
===================================================================
--- solr/core/src/test/org/apache/solr/core/TestArbitraryIndexDir.java	(revision 1584870)
+++ solr/core/src/test/org/apache/solr/core/TestArbitraryIndexDir.java	(working copy)
@@ -125,7 +125,7 @@
     doc.add(new TextField("name", "name2", Field.Store.YES));
     iw.addDocument(doc);
     iw.commit();
-    iw.close();
+    iw.shutdown();
 
     //commit will cause searcher to open with the new index dir
     assertU(commit());
Index: solr/core/src/java/org/apache/solr/spelling/FileBasedSpellChecker.java
===================================================================
--- solr/core/src/java/org/apache/solr/spelling/FileBasedSpellChecker.java	(revision 1584870)
+++ solr/core/src/java/org/apache/solr/spelling/FileBasedSpellChecker.java	(working copy)
@@ -112,7 +112,7 @@
           writer.addDocument(d);
         }
         writer.forceMerge(1);
-        writer.close();
+        writer.shutdown();
 
         dictionary = new HighFrequencyDictionary(DirectoryReader.open(ramDir),
                 WORD_FIELD_NAME, 0.0f);
Index: solr/core/src/java/org/apache/solr/update/SolrIndexSplitter.java
===================================================================
--- solr/core/src/java/org/apache/solr/update/SolrIndexSplitter.java	(revision 1584870)
+++ solr/core/src/java/org/apache/solr/update/SolrIndexSplitter.java	(working copy)
@@ -138,7 +138,7 @@
           iwRef.decref();
         } else {
           if (success) {
-            IOUtils.close(iw);
+            iw.shutdown();
           } else {
             IOUtils.closeWhileHandlingException(iw);
           }
Index: solr/core/src/java/org/apache/solr/update/SolrIndexWriter.java
===================================================================
--- solr/core/src/java/org/apache/solr/update/SolrIndexWriter.java	(revision 1584870)
+++ solr/core/src/java/org/apache/solr/update/SolrIndexWriter.java	(working copy)
@@ -129,7 +129,10 @@
     try {
       while (true) {
         try {
-          super.close();
+          flush(true, true);
+          waitForMerges();
+          commit();
+          super.rollback();
         } catch (ThreadInterruptedException e) {
           // don't allow interruption
           continue;
Index: solr/core/src/java/org/apache/solr/update/DirectUpdateHandler2.java
===================================================================
--- solr/core/src/java/org/apache/solr/update/DirectUpdateHandler2.java	(revision 1584870)
+++ solr/core/src/java/org/apache/solr/update/DirectUpdateHandler2.java	(working copy)
@@ -786,7 +786,7 @@
         }
       }
 
-      if (writer != null) writer.close();
+      if (writer != null) writer.shutdown();
 
     } finally {
       solrCoreState.getCommitLock().unlock();
Index: solr/contrib/map-reduce/src/java/org/apache/solr/hadoop/TreeMergeOutputFormat.java
===================================================================
--- solr/contrib/map-reduce/src/java/org/apache/solr/hadoop/TreeMergeOutputFormat.java	(revision 1584870)
+++ solr/contrib/map-reduce/src/java/org/apache/solr/hadoop/TreeMergeOutputFormat.java	(working copy)
@@ -163,7 +163,7 @@
         
         start = System.nanoTime();
         LOG.info("Optimizing Solr: Closing index writer");
-        writer.close();
+        writer.shutdown();
         secs = (System.nanoTime() - start) / (float)(10^9);
         LOG.info("Optimizing Solr: Done closing index writer in {} secs", secs);
         context.setStatus("Done");
