public void testEmptyIndex() throws IOException {
  Directory rd1=newDirectory();
  IndexWriter iw=new IndexWriter(rd1,newIndexWriterConfig(new MockAnalyzer(random())));
  iw.close();
  Directory rd2=newDirectory(rd1);
  Directory rdOut=newDirectory();
  IndexWriter iwOut=new IndexWriter(rdOut,newIndexWriterConfig(new MockAnalyzer(random())));
  iwOut.addIndexes(SlowCodecReaderWrapper.wrap(new ParallelLeafReader()));
  iwOut.forceMerge(1);
  ParallelCompositeReader cpr=new ParallelCompositeReader(DirectoryReader.open(rd1),DirectoryReader.open(rd2));
  List<CodecReader> leaves=new ArrayList<>();
  for (  LeafReaderContext leaf : cpr.leaves()) {
    leaves.add(SlowCodecReaderWrapper.wrap(leaf.reader()));
  }
  iwOut.addIndexes(leaves.toArray(new CodecReader[0]));
  iwOut.forceMerge(1);
  iwOut.close();
  rdOut.close();
  rd1.close();
  rd2.close();
}

public void testEmptyIndex ( ) throws IOException { Directory rd1 = newDirectory ( ) ; IndexWriter iw = new IndexWriter ( rd1 , newIndexWriterConfig ( new MockAnalyzer ( random ( ) ) ) ) ; iw . close ( ) ; Directory rd2 = newDirectory ( rd1 ) ; Directory rdOut = newDirectory ( ) ; IndexWriter iwOut = new IndexWriter ( rdOut , newIndexWriterConfig ( new MockAnalyzer ( random ( ) ) ) ) ; iwOut . addIndexes ( SlowCodecReaderWrapper . wrap ( new ParallelLeafReader ( ) ) ) ; iwOut . forceMerge ( 1 ) ; ParallelCompositeReader cpr = new ParallelCompositeReader ( DirectoryReader . open ( rd1 ) , DirectoryReader . open ( rd2 ) ) ; List < CodecReader > leaves = new ArrayList < > ( ) ; for ( LeafReaderContext leaf : cpr . leaves ( ) ) { leaves . add ( SlowCodecReaderWrapper . wrap ( leaf . reader ( ) ) ) ; } iwOut . addIndexes ( leaves . toArray ( new CodecReader [ 0 ] ) ) ; iwOut . forceMerge ( 1 ) ; iwOut . close ( ) ; rdOut . close ( ) ; rd1 . close ( ) ; rd2 . close ( ) ; }
creates two empty indexes and wraps a parallelreader around . adding this reader to a new index should not throw any exception .
