private void reserveOneDoc(){
  if (pendingNumDocs.incrementAndGet() > IndexWriter.getActualMaxDocs()) {
    pendingNumDocs.decrementAndGet();
    throw new IllegalArgumentException("number of documents in the index cannot exceed " + IndexWriter.getActualMaxDocs());
  }
}

private void reserveOneDoc ( ) { if ( pendingNumDocs . incrementAndGet ( ) > IndexWriter . getActualMaxDocs ( ) ) { pendingNumDocs . decrementAndGet ( ) ; throw new IllegalArgumentException ( "number of documents in the index cannot exceed " + IndexWriter . getActualMaxDocs ( ) ) ; } }
anything that will add n docs to the index should reserve first to make sure it ' s allowed .
