Index: contrib/spellchecker/src/java/org/apache/lucene/search/spell/SpellChecker.java
===================================================================
--- contrib/spellchecker/src/java/org/apache/lucene/search/spell/SpellChecker.java	(revision 887167)
+++ contrib/spellchecker/src/java/org/apache/lucene/search/spell/SpellChecker.java	(working copy)
@@ -19,6 +19,8 @@
 
 import java.io.IOException;
 import java.util.Iterator;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
 
 import org.apache.lucene.analysis.WhitespaceAnalyzer;
 import org.apache.lucene.document.Document;
@@ -32,6 +34,7 @@
 import org.apache.lucene.search.Query;
 import org.apache.lucene.search.ScoreDoc;
 import org.apache.lucene.search.TermQuery;
+import org.apache.lucene.store.AlreadyClosedException;
 import org.apache.lucene.store.Directory;
 
 /**
@@ -60,6 +63,8 @@
    * Field name for each word in the ngram index.
    */
   public static final String F_WORD = "word";
+  
+  public static final Term F_WORD_TERM = new Term(F_WORD);
 
   /**
    * the spell index
@@ -71,9 +76,10 @@
    */
   private float bStart = 2.0f;
   private float bEnd = 1.0f;
+  private SearcherHolder searcherHolder;
+  private final Object lock = new Object();
+  private final AtomicBoolean closed = new AtomicBoolean(false);
 
-  private IndexSearcher searcher;
-
   // minimum score for hits generated by the spell checker query
   private float minScore = 0.5f;
   
@@ -83,14 +89,22 @@
    * Use the given directory as a spell checker index. The directory
    * is created if it doesn't exist yet.
    * 
-   * @param spellIndex
-   * @throws IOException
+   * @param spellIndex the spell index directory
+   * @param sd the {@link StringDistance} measurement to use 
+   * @throws IOException if spellchecker can not open the directory
    */
-  public SpellChecker(Directory spellIndex,StringDistance sd) throws IOException {
+  public SpellChecker(Directory spellIndex, StringDistance sd) throws IOException {
     this.setSpellIndex(spellIndex);
     this.setStringDistance(sd);
   }
 
+  /**
+   * Use the given directory as a spell checker index with a
+   * {@link LevensteinDistance} as the default {@link StringDistance}.
+   * The directory is created if it doesn't exist yet. 
+   * @param spellIndex the spell index directory
+   * @throws IOException if spellchecker can not open the directory
+   */
   public SpellChecker(Directory spellIndex) throws IOException {
     this(spellIndex, new LevensteinDistance());
   }
@@ -99,27 +113,36 @@
    * Use a different index as the spell checker index or re-open
    * the existing index if <code>spellIndex</code> is the same value
    * as given in the constructor.
-   * 
-   * @param spellIndex
-   * @throws IOException
+   * @throws AlreadyClosedException if the Spellchecker is already closed
+   * @param spellIndex the spell directory to use
+   * @throws IOException if spellchecker can not open the directory
    */
   public void setSpellIndex(Directory spellIndex) throws IOException {
+    ensureOpen();
     this.spellIndex = spellIndex;
     if (!IndexReader.indexExists(spellIndex)) {
         IndexWriter writer = new IndexWriter(spellIndex, null, true, IndexWriter.MaxFieldLength.UNLIMITED);
         writer.close();
     }
-    // close the old searcher, if there was one
-    if (searcher != null) {
-      searcher.close();
-    }
-    searcher = new IndexSearcher(this.spellIndex, true);
+    releaseNewSearcher(this.spellIndex);
   }
   
+  /**
+   * Sets the {@link StringDistance} implementation for this
+   * {@link SpellChecker} instance
+   * @param sd the {@link StringDistance} implementation for this
+   * {@link SpellChecker} instance
+   */
   public void setStringDistance(StringDistance sd) {
     this.sd = sd;
   }
 
+  /**
+   * Returns the {@link StringDistance} instance used by this
+   * {@link SpellChecker} instance.
+   * @return the {@link StringDistance} instance used by this
+   * {@link SpellChecker} instance.
+   */
   public StringDistance getStringDistance() {
     return sd;
   }
@@ -145,6 +168,7 @@
    * @param word the word you want a spell check done on
    * @param numSug the number of suggested words
    * @throws IOException
+   * @throws AlreadyClosedException if the Spellchecker is already closed
    * @return String[]
    */
   public String[] suggestSimilar(String word, int numSug) throws IOException {
@@ -169,98 +193,105 @@
    * words are restricted to the words present in this field.
    * @param morePopular return only the suggest words that are as frequent or more frequent than the searched word
    * (only if restricted mode = (indexReader!=null and field!=null)
-   * @throws IOException
+   * @throws IOException if the underlying index throws an {@link IOException}
+   * @throws AlreadyClosedException if the Spellchecker is already closed
    * @return String[] the sorted list of the suggest words with these 2 criteria:
    * first criteria: the edit distance, second criteria (only if restricted mode): the popularity
    * of the suggest words in the field of the user index
    */
   public String[] suggestSimilar(String word, int numSug, IndexReader ir,
       String field, boolean morePopular) throws IOException {
-
-    float min = this.minScore;
-    final int lengthWord = word.length();
-
-    final int freq = (ir != null && field != null) ? ir.docFreq(new Term(field, word)) : 0;
-    final int goalFreq = (morePopular && ir != null && field != null) ? freq : 0;
-    // if the word exists in the real index and we don't care for word frequency, return the word itself
-    if (!morePopular && freq > 0) {
-      return new String[] { word };
-    }
-
-    BooleanQuery query = new BooleanQuery();
-    String[] grams;
-    String key;
-
-    for (int ng = getMin(lengthWord); ng <= getMax(lengthWord); ng++) {
-
-      key = "gram" + ng; // form key
-
-      grams = formGrams(word, ng); // form word into ngrams (allow dups too)
-
-      if (grams.length == 0) {
-        continue; // hmm
+    final SearcherHolder holder = getSearcherHolder();
+    try {
+      IndexSearcher searcher = holder.get();
+      float min = this.minScore;
+      final int lengthWord = word.length();
+  
+      final int freq = (ir != null && field != null) ? ir.docFreq(new Term(field, word)) : 0;
+      final int goalFreq = (morePopular && ir != null && field != null) ? freq : 0;
+      // if the word exists in the real index and we don't care for word frequency, return the word itself
+      if (!morePopular && freq > 0) {
+        return new String[] { word };
       }
-
-      if (bStart > 0) { // should we boost prefixes?
-        add(query, "start" + ng, grams[0], bStart); // matches start of word
-
+  
+      BooleanQuery query = new BooleanQuery();
+      String[] grams;
+      String key;
+  
+      for (int ng = getMin(lengthWord); ng <= getMax(lengthWord); ng++) {
+  
+        key = "gram" + ng; // form key
+  
+        grams = formGrams(word, ng); // form word into ngrams (allow dups too)
+  
+        if (grams.length == 0) {
+          continue; // hmm
+        }
+  
+        if (bStart > 0) { // should we boost prefixes?
+          add(query, "start" + ng, grams[0], bStart); // matches start of word
+  
+        }
+        if (bEnd > 0) { // should we boost suffixes
+          add(query, "end" + ng, grams[grams.length - 1], bEnd); // matches end of word
+  
+        }
+        for (int i = 0; i < grams.length; i++) {
+          add(query, key, grams[i]);
+        }
       }
-      if (bEnd > 0) { // should we boost suffixes
-        add(query, "end" + ng, grams[grams.length - 1], bEnd); // matches end of word
-
-      }
-      for (int i = 0; i < grams.length; i++) {
-        add(query, key, grams[i]);
-      }
-    }
-
-    int maxHits = 10 * numSug;
-    
-//    System.out.println("Q: " + query);
-    ScoreDoc[] hits = searcher.search(query, null, maxHits).scoreDocs;
-//    System.out.println("HITS: " + hits.length());
-    SuggestWordQueue sugQueue = new SuggestWordQueue(numSug);
-
-    // go thru more than 'maxr' matches in case the distance filter triggers
-    int stop = Math.min(hits.length, maxHits);
-    SuggestWord sugWord = new SuggestWord();
-    for (int i = 0; i < stop; i++) {
-
-      sugWord.string = searcher.doc(hits[i].doc).get(F_WORD); // get orig word
-
-      // don't suggest a word for itself, that would be silly
-      if (sugWord.string.equals(word)) {
-        continue;
-      }
-
-      // edit distance
-      sugWord.score = sd.getDistance(word,sugWord.string);
-      if (sugWord.score < min) {
-        continue;
-      }
-
-      if (ir != null && field != null) { // use the user index
-        sugWord.freq = ir.docFreq(new Term(field, sugWord.string)); // freq in the index
-        // don't suggest a word that is not present in the field
-        if ((morePopular && goalFreq > sugWord.freq) || sugWord.freq < 1) {
+  
+      int maxHits = 10 * numSug;
+      
+  //    System.out.println("Q: " + query);
+      ScoreDoc[] hits = searcher.search(query, null, maxHits).scoreDocs;
+  //    System.out.println("HITS: " + hits.length());
+      SuggestWordQueue sugQueue = new SuggestWordQueue(numSug);
+  
+      // go thru more than 'maxr' matches in case the distance filter triggers
+      int stop = Math.min(hits.length, maxHits);
+      SuggestWord sugWord = new SuggestWord();
+      for (int i = 0; i < stop; i++) {
+  
+        sugWord.string = searcher.doc(hits[i].doc).get(F_WORD); // get orig word
+  
+        // don't suggest a word for itself, that would be silly
+        if (sugWord.string.equals(word)) {
           continue;
         }
+  
+        // edit distance
+        sugWord.score = sd.getDistance(word,sugWord.string);
+        if (sugWord.score < min) {
+          continue;
+        }
+  
+        if (ir != null && field != null) { // use the user index
+          sugWord.freq = ir.docFreq(new Term(field, sugWord.string)); // freq in the index
+          // don't suggest a word that is not present in the field
+          if ((morePopular && goalFreq > sugWord.freq) || sugWord.freq < 1) {
+            continue;
+          }
+        }
+        sugQueue.insertWithOverflow(sugWord);
+        if (sugQueue.size() == numSug) {
+          // if queue full, maintain the minScore score
+          min = sugQueue.top().score;
+        }
+        sugWord = new SuggestWord();
       }
-      sugQueue.insertWithOverflow(sugWord);
-      if (sugQueue.size() == numSug) {
-        // if queue full, maintain the minScore score
-        min = sugQueue.top().score;
+  
+      // convert to array string
+      String[] list = new String[sugQueue.size()];
+      for (int i = sugQueue.size() - 1; i >= 0; i--) {
+        list[i] = sugQueue.pop().string;
       }
-      sugWord = new SuggestWord();
+      return list;
+    }finally{
+      holder.decRef();
     }
 
-    // convert to array string
-    String[] list = new String[sugQueue.size()];
-    for (int i = sugQueue.size() - 1; i >= 0; i--) {
-      list[i] = sugQueue.pop().string;
-    }
-
-    return list;
+    
   }
 
   /**
@@ -297,24 +328,31 @@
   /**
    * Removes all terms from the spell check index.
    * @throws IOException
+   * @throws AlreadyClosedException if the Spellchecker is already closed
    */
   public void clearIndex() throws IOException {
+    ensureOpen();
     IndexWriter writer = new IndexWriter(spellIndex, null, true, IndexWriter.MaxFieldLength.UNLIMITED);
     writer.close();
     
-    //close the old searcher
-    searcher.close();
-    searcher = new IndexSearcher(this.spellIndex, true);
+    releaseNewSearcher(this.spellIndex);
   }
 
   /**
    * Check whether the word exists in the index.
    * @param word
    * @throws IOException
-   * @return true iff the word exists in the index
+   * @throws AlreadyClosedException if the Spellchecker is already closed
+   * @return true if the word exists in the index
    */
   public boolean exist(String word) throws IOException {
-    return searcher.docFreq(new Term(F_WORD, word)) > 0;
+    final SearcherHolder holder = getSearcherHolder();
+    try{
+      // use F_WORD_TERM to prevent String.intern each time exists is called
+      return holder.get().docFreq(F_WORD_TERM.createTerm(word)) > 0;
+    } finally {
+      holder.decRef();
+    }
   }
 
   /**
@@ -322,9 +360,11 @@
    * @param dict Dictionary to index
    * @param mergeFactor mergeFactor to use when indexing
    * @param ramMB the max amount or memory in MB to use
+   * @throws AlreadyClosedException if the Spellchecker is already closed
    * @throws IOException
    */
   public void indexDictionary(Dictionary dict, int mergeFactor, int ramMB) throws IOException {
+    ensureOpen();
     IndexWriter writer = new IndexWriter(spellIndex, new WhitespaceAnalyzer(), IndexWriter.MaxFieldLength.UNLIMITED);
     writer.setMergeFactor(mergeFactor);
     writer.setRAMBufferSizeMB(ramMB);
@@ -351,8 +391,7 @@
     writer.close();
     // also re-open the spell index to see our own changes when the next suggestion
     // is fetched:
-    searcher.close();
-    searcher = new IndexSearcher(this.spellIndex, true);
+    releaseNewSearcher(spellIndex);
   }
 
   /**
@@ -385,14 +424,14 @@
   }
 
   private static Document createDocument(String text, int ng1, int ng2) {
-    Document doc = new Document();
+    final Document doc = new Document();
     doc.add(new Field(F_WORD, text, Field.Store.YES, Field.Index.NOT_ANALYZED)); // orig term
     addGram(text, doc, ng1, ng2);
     return doc;
   }
 
   private static void addGram(String text, Document doc, int ng1, int ng2) {
-    int len = text.length();
+    final int len = text.length();
     for (int ng = ng1; ng <= ng2; ng++) {
       String key = "gram" + ng;
       String end = null;
@@ -409,12 +448,94 @@
       }
     }
   }
+  
+  private void ensureOpen(){
+    if(closed.get()){
+      throw new AlreadyClosedException("Spellchecker has been closed");
+    }
+  }
 
   /**
-   * Close the IndexSearcher used by this SpellChecker.
+   * Close the IndexSearcher used by this SpellChecker
+   * @throws IOException if the close operation causes an {@link IOException}
+   * @throws AlreadyClosedException if the {@link SpellChecker} is already closed
    */
   public void close() throws IOException {
-    searcher.close();
-    searcher = null;
+    synchronized (lock) {
+      ensureOpen();
+      if(this.searcherHolder != null){
+        // decrement the searcher ref - there could still be a thread in suggestSimilar
+        this.searcherHolder.decRef();
+      }
+      this.closed.set(true);
+    }
   }
+  
+  /*
+   * Creates a new RO - IndexSearcher using the given directory if the spellchecker
+   * is still open. If another searcher already exists the global reference will
+   * be decremented.
+   */
+  private void releaseNewSearcher(Directory directory) throws IOException {
+    synchronized (lock) {
+      ensureOpen();
+      // close the old searcher, if there was one
+      if(this.searcherHolder != null){
+        // decrement the global reference
+        this.searcherHolder.decRef();
+      }
+      this.searcherHolder = newHolder(new IndexSearcher(directory, true));
+    }
+  }
+  
+  // for testing
+  SearcherHolder newHolder(IndexSearcher searcher){
+    return new SearcherHolder(searcher);
+  }
+  
+  /*
+   * Returns a new SearcherHolder with an already incremented ref counter
+   * if the SpellChecker is still open.
+   * It's the callers responsibility to decrement the reference.
+   * Make sure you use a try / finally block otherwise the searcher
+   * will not be closed.
+   */
+  private SearcherHolder getSearcherHolder() throws IOException{
+    // make sure to reserve this instance to prevent a race
+    this.searcherHolder.incRef();
+    if(closed.get()){
+      // already closed? make sure to release the reference
+      this.searcherHolder.decRef();
+      throw new AlreadyClosedException("Spellchecker has been closed");
+    }
+    return this.searcherHolder;
+  }
+  
+  final static class SearcherHolder {
+    final IndexSearcher searcher;
+    final AtomicInteger count;
+    // mainly for testing
+    final AtomicBoolean closed = new AtomicBoolean(false);
+    SearcherHolder(IndexSearcher searcher) {
+      this.searcher = searcher;
+      // initialize with 1 - the global reference
+      // the global ref is decremented in close or releaseNewSearcher
+      this.count = new AtomicInteger(1);
+    }
+    
+    IndexSearcher get(){
+      return searcher;
+    }
+    
+    void incRef(){
+      this.count.incrementAndGet();
+    }
+    
+    void decRef() throws IOException {
+      if(this.count.decrementAndGet() == 0){
+        this.searcher.close();
+        this.closed.set(true);
+      }
+    }
+  }
 }
Index: contrib/spellchecker/src/test/org/apache/lucene/search/spell/TestSpellChecker.java
===================================================================
--- contrib/spellchecker/src/test/org/apache/lucene/search/spell/TestSpellChecker.java	(revision 887167)
+++ contrib/spellchecker/src/test/org/apache/lucene/search/spell/TestSpellChecker.java	(working copy)
@@ -18,18 +18,27 @@
  */
 
 import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Random;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
 
-import junit.framework.TestCase;
-
 import org.apache.lucene.analysis.SimpleAnalyzer;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
 import org.apache.lucene.index.CorruptIndexException;
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.IndexWriter;
+import org.apache.lucene.search.IndexSearcher;
+import org.apache.lucene.search.spell.SpellChecker.SearcherHolder;
+import org.apache.lucene.store.AlreadyClosedException;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.store.RAMDirectory;
 import org.apache.lucene.util.English;
+import org.apache.lucene.util.LuceneTestCase;
 
 
 /**
@@ -37,9 +46,11 @@
  *
  *
  */
-public class TestSpellChecker extends TestCase {
-  private SpellChecker spellChecker;
+public class TestSpellChecker extends LuceneTestCase {
+  private SpellCheckerMock spellChecker;
   private Directory userindex, spellindex;
+  private final Random random = newRandom();
+  private List<SearcherHolder> holders;
 
   @Override
   protected void setUp() throws Exception {
@@ -56,10 +67,10 @@
       writer.addDocument(doc);
     }
     writer.close();
-
+    holders = Collections.synchronizedList(new ArrayList<SearcherHolder>());
     // create the spellChecker
     spellindex = new RAMDirectory();
-    spellChecker = new SpellChecker(spellindex);
+    spellChecker = new SpellCheckerMock(spellindex);
   }
 
 
@@ -75,7 +86,9 @@
     int num_field2 = this.numdoc();
 
     assertEquals(num_field2, num_field1 + 1);
-
+    
+    assertLastSearcherOpen(4);
+    
     checkCommonSuggestions(r);
     checkLevenshteinSuggestions(r);
     
@@ -91,6 +104,8 @@
     
   }
 
+ 
+
   private void checkCommonSuggestions(IndexReader r) throws IOException {
     String[] similar = spellChecker.suggestSimilar("fvie", 2);
     assertTrue(similar.length > 0);
@@ -201,4 +216,193 @@
     return num;
   }
   
+  public void testClose() throws IOException {
+    IndexReader r = IndexReader.open(userindex, true);
+    spellChecker.clearIndex();
+    String field = "field1";
+    addwords(r, "field1");
+    int num_field1 = this.numdoc();
+    addwords(r, "field2");
+    int num_field2 = this.numdoc();
+    assertEquals(num_field2, num_field1 + 1);
+    checkCommonSuggestions(r);
+    assertLastSearcherOpen(4);
+    spellChecker.close();
+    assertSearchersClosed();
+    try {
+      spellChecker.close();
+      fail("spellchecker was already closed");
+    } catch (AlreadyClosedException e) {
+      // expected
+    }
+    try {
+      checkCommonSuggestions(r);
+      fail("spellchecker was already closed");
+    } catch (AlreadyClosedException e) {
+      // expected
+    }
+    
+    try {
+      spellChecker.clearIndex();
+      fail("spellchecker was already closed");
+    } catch (AlreadyClosedException e) {
+      // expected
+    }
+    
+    try {
+      spellChecker.indexDictionary(new LuceneDictionary(r, field));
+      fail("spellchecker was already closed");
+    } catch (AlreadyClosedException e) {
+      // expected
+    }
+    
+    try {
+      spellChecker.setSpellIndex(spellindex);
+      fail("spellchecker was already closed");
+    } catch (AlreadyClosedException e) {
+      // expected
+    }
+    assertEquals(4, holders.size());
+    assertSearchersClosed();
+  }
+  
+  /*
+   * tests if the internally shared indexsearcher is correctly closed 
+   * when the spellchecker is concurrently accessed and closed.
+   */
+  public void testConcurrentAccess() throws IOException, InterruptedException {
+    assertEquals(1, holders.size());
+    final IndexReader r = IndexReader.open(userindex, true);
+    spellChecker.clearIndex();
+    assertEquals(2, holders.size());
+    addwords(r, "field1");
+    assertEquals(3, holders.size());
+    int num_field1 = this.numdoc();
+    addwords(r, "field2");
+    assertEquals(4, holders.size());
+    int num_field2 = this.numdoc();
+    assertEquals(num_field2, num_field1 + 1);
+    int numThreads = 5 + this.random.nextInt(5);
+    ExecutorService executor = Executors.newFixedThreadPool(numThreads);
+    SpellCheckWorker[] workers = new SpellCheckWorker[numThreads];
+    for (int i = 0; i < numThreads; i++) {
+      SpellCheckWorker spellCheckWorker = new SpellCheckWorker(r);
+      executor.execute(spellCheckWorker);
+      workers[i] = spellCheckWorker;
+      
+    }
+    int iterations = 5 + random.nextInt(5);
+    for (int i = 0; i < iterations; i++) {
+      Thread.sleep(100);
+      // concurrently reset the spell index
+      spellChecker.setSpellIndex(this.spellindex);
+      // for debug - prints the internal open searchers 
+      //showSearchersOpen();
+    }
+    
+    spellChecker.close();
+    executor.shutdown();
+    executor.awaitTermination(500, TimeUnit.MILLISECONDS);
+    
+    
+    for (int i = 0; i < workers.length; i++) {
+      assertFalse(workers[i].failed);
+      assertTrue(workers[i].terminated);
+    }
+    // 4 holders more than iterations
+    // 1. at creation
+    // 2. clearIndex()
+    // 2. and 3. during addwords
+    assertEquals(iterations + 4, holders.size());
+    assertSearchersClosed();
+    
+  }
+  
+  private void assertLastSearcherOpen(int numSearchers) {
+    assertEquals(numSearchers, holders.size());
+    SearcherHolder[] holderArray = holders.toArray(new SearcherHolder[0]);
+    for (int i = 0; i < holderArray.length; i++) {
+      if (i == holderArray.length - 1) {
+        assertFalse("expected last searcher open but was closed",
+            holderArray[i].closed.get());
+        assertEquals("expected only global reference but ref count was "
+            + holderArray[i].count.get(), 1, holderArray[i].count.get());
+      } else {
+        assertTrue("expected closed searcher but was open - Index: " + i,
+            holderArray[i].closed.get());
+        assertEquals("expected ref count 0 but was "
+            + holderArray[i].count.get(), 0, holderArray[i].count.get());
+      }
+    }
+  }
+  
+  private void assertSearchersClosed() {
+    for (SearcherHolder holder : holders) {
+      assertEquals(0, holder.count.get());
+      assertTrue(holder.closed.get());
+    }
+  }
+  
+  private void showSearchersOpen() {
+    int count = 0;
+    for (SearcherHolder holder : holders) {
+      if(!holder.closed.get())
+        ++count;
+    } 
+    System.out.println(count);
+  }
+
+  
+  private class SpellCheckWorker implements Runnable {
+    private final IndexReader reader;
+    boolean terminated = false;
+    boolean failed = false;
+    
+    SpellCheckWorker(IndexReader reader) {
+      super();
+      this.reader = reader;
+    }
+    
+    public void run() {
+      try {
+        while (true) {
+          try {
+            checkCommonSuggestions(reader);
+          } catch (AlreadyClosedException e) {
+            
+            return;
+          } catch (Throwable e) {
+            
+            e.printStackTrace();
+            failed = true;
+            return;
+          }
+        }
+      } finally {
+        terminated = true;
+      }
+    }
+    
+  }
+  
+  class SpellCheckerMock extends SpellChecker {
+    public SpellCheckerMock(Directory spellIndex) throws IOException {
+      super(spellIndex);
+    }
+
+    public SpellCheckerMock(Directory spellIndex, StringDistance sd)
+        throws IOException {
+      super(spellIndex, sd);
+    }
+
+    @Override
+    SearcherHolder newHolder(IndexSearcher searcher) {
+      SearcherHolder newHolder = super.newHolder(searcher);
+      TestSpellChecker.this.holders.add(newHolder);
+      return newHolder;
+    }
+    
+    
+  }
+  
 }
