code: public static void closeOrRelease(final IndexReader reader) throws IOException
     {
        if (reader instanceof ReleaseableIndexReader)
        {
           ((ReleaseableIndexReader)reader).release();
        }
        else
        {
           reader.close();
        }
     }
docs: Depending on the type of the <code>reader</code> this method either
  closes or releases the reader. The reader is released if it implements
  {@link ReleaseableIndexReader}.
  
  @param reader the index reader to close or release.
  @throws IOException if an error occurs while closing or releasing the
  index reader.