Program: 24773
Project: 24773
Buggy source:
/** 
 * Does the work of locating and loading the source document. Handles fetching a file from a URL, lazy file, or a plain XML file on disk. Also fires up a text query if requested.
 * @param docInfo       Tells which document to load, the query toapply, tec.
 * @param transformer   The XSLT transformer that will be used on thedocument.
 * @return              An XML Source object representing the loadeddocument.
 * @throws IOException  If a problem is encountered loading a file or URL
 * @throws SAXException If the document cannot be parsed as valid XML
 * @throws ParserConfigurationException Miscellaneous configuration problems
 */
protected Source getSourceDoc(DocInfo docInfo,Transformer transformer) throws IOException, SAXException, ParserConfigurationException, InvalidDocumentException {
  Templates preFilter=null;
  if (docInfo.preFilter != null) {
    try {
      preFilter=stylesheetCache.find(docInfo.preFilter);
    }
 catch (    IOException e) {
      throw e;
    }
catch (    SAXException e) {
      throw e;
    }
catch (    Exception e) {
      throw new RuntimeException(e);
    }
  }
  StructuredStore lazyStore=docLocator.getLazyStore(docInfo.indexConfig,docInfo.indexName,docInfo.source,preFilter,docInfo.removeDoctypeDecl);
  if (lazyStore == null) {
    if (docInfo.query != null)     throw new UnsupportedQueryException();
    if (forceLazy)     throw new InvalidDocumentException();
    XMLReader xmlReader=IndexUtil.createXMLReader();
    InputSource inSrc=docLocator.getInputSource(docInfo.source,docInfo.removeDoctypeDecl);
    return new SAXSource(xmlReader,inSrc);
  }
  Source sourceDoc=null;
  if (docInfo.query != null && docInfo.query.query != null) {
    String docKey=IndexUtil.calcDocKey(new File(getRealPath("String_Node_Str")),new File(docInfo.indexConfig),docInfo.indexName,new File(docInfo.source));
    SearchTree tree=new SearchTree(docKey,lazyStore);
    tree.search(createQueryProcessor(),docInfo.query);
    sourceDoc=tree;
  }
 else {
    LazyTreeBuilder builder=new LazyTreeBuilder();
    builder.setNamePool(NamePool.getDefaultNamePool());
    sourceDoc=builder.load(lazyStore);
  }
  ((LazyDocument)sourceDoc).setDebug(true);
  Controller c=(Controller)transformer;
  Executable e=c.getExecutable();
  KeyManager k=e.getKeyManager();
  if (!(k instanceof LazyKeyManager))   e.setKeyManager(new LazyKeyManager(k,c.getConfiguration()));
  return sourceDoc;
}

Fixed version (ground truth):
/** 
 * Does the work of locating and loading the source document. Handles fetching a file from a URL, lazy file, or a plain XML file on disk. Also fires up a text query if requested.
 * @param docInfo       Tells which document to load, the query toapply, tec.
 * @param transformer   The XSLT transformer that will be used on thedocument.
 * @return              An XML Source object representing the loadeddocument.
 * @throws IOException  If a problem is encountered loading a file or URL
 * @throws SAXException If the document cannot be parsed as valid XML
 * @throws ParserConfigurationException Miscellaneous configuration problems
 */
protected Source getSourceDoc(DocInfo docInfo,Transformer transformer) throws IOException, SAXException, ParserConfigurationException, InvalidDocumentException {
  Templates preFilter=null;
  if (docInfo.preFilter != null) {
    try {
      preFilter=stylesheetCache.find(docInfo.preFilter);
    }
 catch (    IOException e) {
      throw e;
    }
catch (    SAXException e) {
      throw e;
    }
catch (    Exception e) {
      throw new RuntimeException(e);
    }
  }
  StructuredStore lazyStore=docLocator.getLazyStore(docInfo.indexConfig,docInfo.indexName,docInfo.source,preFilter,docInfo.removeDoctypeDecl);
  if (lazyStore == null) {
    if (docInfo.query != null)     throw new UnsupportedQueryException();
    if (forceLazy)     throw new InvalidDocumentException();
    File srcFile=new File(docInfo.source);
    if (!srcFile.isFile() || !srcFile.canRead())     throw new InvalidDocumentException();
    XMLReader xmlReader=IndexUtil.createXMLReader();
    InputSource inSrc=docLocator.getInputSource(docInfo.source,docInfo.removeDoctypeDecl);
    return new SAXSource(xmlReader,inSrc);
  }
  Source sourceDoc=null;
  if (docInfo.query != null && docInfo.query.query != null) {
    String docKey=IndexUtil.calcDocKey(new File(getRealPath("String_Node_Str")),new File(docInfo.indexConfig),docInfo.indexName,new File(docInfo.source));
    SearchTree tree=new SearchTree(docKey,lazyStore);
    tree.search(createQueryProcessor(),docInfo.query);
    sourceDoc=tree;
  }
 else {
    LazyTreeBuilder builder=new LazyTreeBuilder();
    builder.setNamePool(NamePool.getDefaultNamePool());
    sourceDoc=builder.load(lazyStore);
  }
  ((LazyDocument)sourceDoc).setDebug(true);
  Controller c=(Controller)transformer;
  Executable e=c.getExecutable();
  KeyManager k=e.getKeyManager();
  if (!(k instanceof LazyKeyManager))   e.setKeyManager(new LazyKeyManager(k,c.getConfiguration()));
  return sourceDoc;
}