public static void checkReader(IndexReader reader) throws IOException {
  for (  LeafReaderContext context : reader.leaves()) {
    checkReader(context.reader(),true);
  }
}

public static void checkReader ( IndexReader reader ) throws IOException { for ( LeafReaderContext context : reader . leaves ( ) ) { checkReader ( context . reader ( ) , true ) ; } }
this runs the checkindex tool on the reader . if any issues are hit , a runtimeexception is thrown
