Program: 101551
Project: 101551
Buggy source:
/** 
 * Generate an index to use, telling the job about progress as you go.
 * @throws BookException If we fail to read the index files
 */
public LuceneIndex(Book book,URI storage,boolean create) throws BookException {
  assert create;
  this.book=book;
  File finalPath=null;
  try {
    finalPath=NetUtil.getAsFile(storage);
    this.path=finalPath.getCanonicalPath();
  }
 catch (  IOException ex) {
    throw new BookException(UserMsg.LUCENE_INIT,ex);
  }
  DataPolice.setBook(book.getBookMetaData());
  Progress job=JobManager.createJob(UserMsg.INDEX_START.toString(),Thread.currentThread(),false);
  IndexStatus finalStatus=IndexStatus.UNDONE;
  String bookLang=book.getLanguage().getName();
  Analyzer analyzer=new LuceneAnalyzer(bookLang);
  List errors=new ArrayList();
  File tempPath=new File(path + '.' + IndexStatus.CREATING.toString());
  try {
synchronized (CREATING) {
      book.setIndexStatus(IndexStatus.CREATING);
      RAMDirectory ramDir=new RAMDirectory();
      IndexWriter writer=new IndexWriter(ramDir,analyzer,true);
      generateSearchIndexImpl(job,errors,writer,book.getGlobalKeyList(),0);
      job.setSectionName(UserMsg.OPTIMIZING.toString());
      job.setWork(95);
      writer.close();
      IndexWriter fsWriter=new IndexWriter(tempPath.getCanonicalPath(),analyzer,true);
      fsWriter.addIndexes(new Directory[]{ramDir});
      fsWriter.close();
      ramDir.close();
      job.setCancelable(false);
      if (!job.isFinished()) {
        tempPath.renameTo(finalPath);
      }
      if (finalPath.exists()) {
        finalStatus=IndexStatus.DONE;
      }
      if (errors.size() > 0) {
        StringBuffer buf=new StringBuffer();
        Iterator iter=errors.iterator();
        while (iter.hasNext()) {
          buf.append(iter.next());
          buf.append('\n');
        }
        Reporter.informUser(this,UserMsg.BAD_VERSE,buf);
      }
    }
  }
 catch (  IOException ex) {
    job.cancel();
    throw new BookException(UserMsg.LUCENE_INIT,ex);
  }
 finally {
    book.setIndexStatus(finalStatus);
    job.done();
  }
}

Fixed version (ground truth):
/** 
 * Generate an index to use, telling the job about progress as you go.
 * @throws BookException If we fail to read the index files
 */
public LuceneIndex(Book book,URI storage,boolean create) throws BookException {
  assert create;
  this.book=book;
  File finalPath=null;
  try {
    finalPath=NetUtil.getAsFile(storage);
    this.path=finalPath.getCanonicalPath();
  }
 catch (  IOException ex) {
    throw new BookException(UserMsg.LUCENE_INIT,ex);
  }
  DataPolice.setBook(book.getBookMetaData());
  Progress job=JobManager.createJob(UserMsg.INDEX_START.toString(book.getInitials()),Thread.currentThread(),false);
  IndexStatus finalStatus=IndexStatus.UNDONE;
  String bookLang=book.getLanguage().getName();
  Analyzer analyzer=new LuceneAnalyzer(bookLang);
  List errors=new ArrayList();
  File tempPath=new File(path + '.' + IndexStatus.CREATING.toString());
  try {
synchronized (CREATING) {
      book.setIndexStatus(IndexStatus.CREATING);
      RAMDirectory ramDir=new RAMDirectory();
      IndexWriter writer=new IndexWriter(ramDir,analyzer,true);
      generateSearchIndexImpl(job,errors,writer,book.getGlobalKeyList(),0);
      job.setSectionName(UserMsg.OPTIMIZING.toString());
      job.setWork(95);
      writer.close();
      IndexWriter fsWriter=new IndexWriter(tempPath.getCanonicalPath(),analyzer,true);
      fsWriter.addIndexes(new Directory[]{ramDir});
      fsWriter.close();
      ramDir.close();
      job.setCancelable(false);
      if (!job.isFinished()) {
        tempPath.renameTo(finalPath);
      }
      if (finalPath.exists()) {
        finalStatus=IndexStatus.DONE;
      }
      if (errors.size() > 0) {
        StringBuffer buf=new StringBuffer();
        Iterator iter=errors.iterator();
        while (iter.hasNext()) {
          buf.append(iter.next());
          buf.append('\n');
        }
        Reporter.informUser(this,UserMsg.BAD_VERSE,buf);
      }
    }
  }
 catch (  IOException ex) {
    job.cancel();
    throw new BookException(UserMsg.LUCENE_INIT,ex);
  }
 finally {
    book.setIndexStatus(finalStatus);
    job.done();
  }
}