Program: 75351
Project: 75351
Buggy source:
/** 
 * Use the specified parser to parse the file or URL, which contains MoML, using the specified base to find the URL. If the URL has been previously parsed by this application, then return the instance that was the result of the previous parse. If the URL cannot be found relative to this base, then it is searched for relative to the current working directory (if this is permitted with the current security restrictions), and then relative to the classpath.
 * @param parser The parser to use.
 * @param base The base URL for relative references, or null ifnot known.
 * @param file The file or URL from which to read MoML.
 * @param className The class name to assign if the file isparsed anew.
 * @param source The source file to assign if the file isparsed anew, or null to not assign one.
 * @return The top-level composite entity of the Ptolemy II model.
 * @exception Exception If the parser fails.
 */
private NamedObj _findOrParse(MoMLParser parser,URL base,String file,String className,String source) throws Exception {
  _xmlFile=fileNameToURL(file,base);
  if (_imports != null) {
    NamedObj previous=(NamedObj)_imports.get(_xmlFile);
    if (previous != null) {
      return previous;
    }
  }
  InputStream input=_xmlFile.openStream();
  try {
    NamedObj toplevel=parser.parse(_xmlFile,input);
    input.close();
    toplevel.setClassName(className);
    toplevel.setSource(source);
    if (_imports == null) {
      _imports=new HashMap();
    }
    _imports.put(_xmlFile,toplevel);
    return toplevel;
  }
 catch (  CancelException ex) {
    return null;
  }
 finally {
    input.close();
    _xmlFile=null;
  }
}

Fixed version (ground truth):
/** 
 * Use the specified parser to parse the file or URL, which contains MoML, using the specified base to find the URL. If the URL has been previously parsed by this application, then return the instance that was the result of the previous parse. If the URL cannot be found relative to this base, then it is searched for relative to the current working directory (if this is permitted with the current security restrictions), and then relative to the classpath.
 * @param parser The parser to use.
 * @param base The base URL for relative references, or null ifnot known.
 * @param file The file or URL from which to read MoML.
 * @param className The class name to assign if the file isparsed anew.
 * @param source The source file to assign if the file isparsed anew, or null to not assign one.
 * @return The top-level composite entity of the Ptolemy II model.
 * @exception Exception If the parser fails.
 */
private NamedObj _findOrParse(MoMLParser parser,URL base,String file,String className,String source) throws Exception {
  URL previousXmlFile=parser._xmlFile;
  parser._xmlFile=fileNameToURL(file,base);
  if (_imports != null) {
    NamedObj previous=(NamedObj)_imports.get(parser._xmlFile);
    if (previous != null) {
      return previous;
    }
  }
  InputStream input=parser._xmlFile.openStream();
  try {
    NamedObj toplevel=parser.parse(parser._xmlFile,input);
    input.close();
    toplevel.setSource(source);
    if (_imports == null) {
      _imports=new HashMap();
    }
    _imports.put(parser._xmlFile,toplevel);
    return toplevel;
  }
 catch (  CancelException ex) {
    return null;
  }
 finally {
    input.close();
    parser._xmlFile=previousXmlFile;
  }
}