code: void addDocuments(final Document[] docs) throws IOException
     {
        final IndexWriter writer = getIndexWriter();
  
        IOException ioExc = null;
        try
        {
           for (Document doc : docs)
           {
              try
              {
                 writer.addDocument(doc);
              }
              catch (Throwable e) //NOSONAR
              {
                 if (ioExc == null)
                 {
                    if (e instanceof IOException)
                    {
                       ioExc = (IOException)e;
                    }
                    else
                    {
                       ioExc = Util.createIOException(e);
                    }
                 }
  
                 log.warn("Exception while inverting document", e);
              }
           }
        }
        finally
        {
           invalidateSharedReader();
        }
  
        if (ioExc != null)
        {
           throw ioExc;
        }
     }
docs: Adds documents to this index and invalidates the shared reader.
  
  @param docs the documents to add.
  @throws IOException if an error occurs while writing to the index.