Program: 73231
Project: 73231
Buggy source:
/** 
 * For the specified effigy, define the relevant href, target, and class area attributes if the effigy has any open tableaux, and those have frames that implement either HTMLExportable or ImageExportable. As a side effect, this may generate HTML files in the specified directory.
 * @param exporter The exporter.
 * @param effigy The effigy.
 * @param object The Ptolemy II object.
 * @param directory The directory into which to write any HTML.
 * @exception IOException If unable to create required HTML files.
 * @exception PrinterException If unable to create required HTML files.
 * @throws IllegalActionException If something goes wrong.
 */
private void _linkTo(WebExporter exporter,PtolemyEffigy effigy,NamedObj object,File directory) throws IOException, PrinterException, IllegalActionException {
  File gifFile;
  List<Tableau> tableaux=effigy.entityList(Tableau.class);
  if (tableaux.size() > 0) {
    String name=object.getName();
    Frame frame=tableaux.get(0).getFrame();
    if (frame instanceof HTMLExportable) {
      File subDirectory=new File(directory,name);
      if (subDirectory.exists()) {
        if (!subDirectory.isDirectory()) {
          File backupFile=new File(directory,name + "String_Node_Str");
          if (!subDirectory.renameTo(backupFile)) {
            throw new IOException("String_Node_Str" + subDirectory + "String_Node_Str"+ backupFile+ "String_Node_Str");
          }
        }
      }
 else       if (!subDirectory.mkdir()) {
        throw new IOException("String_Node_Str" + subDirectory);
      }
      ((HTMLExportable)frame).writeHTML(subDirectory);
      exporter.defineAreaAttribute(object,"String_Node_Str",name + "String_Node_Str",true);
      boolean usePtWebsite=Boolean.valueOf(StringUtilities.getProperty("String_Node_Str"));
      if (usePtWebsite) {
        exporter.addContent("String_Node_Str",false,"String_Node_Str" + name + "String_Node_Str"+ "String_Node_Str"+ ExportHTMLAction._getTitleText(object)+ "String_Node_Str");
      }
    }
 else     if (frame instanceof ImageExportable) {
      gifFile=new File(directory,name + "String_Node_Str");
      OutputStream gifOut=new FileOutputStream(gifFile);
      try {
        ((ImageExportable)frame).writeImage(gifOut,"String_Node_Str");
      }
  finally {
        gifOut.close();
      }
      exporter.defineAreaAttribute(object,"String_Node_Str",name + "String_Node_Str",true);
      exporter.defineAreaAttribute(object,"String_Node_Str","String_Node_Str",true);
    }
  }
}

Fixed version (ground truth):
/** 
 * For the specified effigy, define the relevant href, target, and class area attributes if the effigy has any open tableaux, and those have frames that implement either HTMLExportable or ImageExportable. As a side effect, this may generate HTML files in the specified directory.
 * @param exporter The exporter.
 * @param effigy The effigy.
 * @param sourceObject The source Ptolemy II object (link from).
 * @param destinationObject The destination object (link to, same as sourceObject,or alternatively, a class definition for sourceObject).
 * @param directory The directory into which to write any HTML.
 * @exception IOException If unable to create required HTML files.
 * @exception PrinterException If unable to create required HTML files.
 * @throws IllegalActionException If something goes wrong.
 */
private void _linkTo(WebExporter exporter,PtolemyEffigy effigy,NamedObj sourceObject,NamedObj destinationObject,File directory) throws IOException, PrinterException, IllegalActionException {
  File gifFile;
  List<Tableau> tableaux=effigy.entityList(Tableau.class);
  if (tableaux.size() > 0) {
    String name=destinationObject.getName();
    Frame frame=tableaux.get(0).getFrame();
    if (frame instanceof HTMLExportable) {
      File subDirectory=new File(directory,name);
      if (subDirectory.exists()) {
        if (!subDirectory.isDirectory()) {
          File backupFile=new File(directory,name + "String_Node_Str");
          if (!subDirectory.renameTo(backupFile)) {
            throw new IOException("String_Node_Str" + subDirectory + "String_Node_Str"+ backupFile+ "String_Node_Str");
          }
        }
      }
 else       if (!subDirectory.mkdir()) {
        throw new IOException("String_Node_Str" + subDirectory);
      }
      ((HTMLExportable)frame).writeHTML(subDirectory);
      exporter.defineAreaAttribute(sourceObject,"String_Node_Str",name + "String_Node_Str",true);
      boolean usePtWebsite=Boolean.valueOf(StringUtilities.getProperty("String_Node_Str"));
      if (usePtWebsite) {
        exporter.addContent("String_Node_Str",false,"String_Node_Str" + name + "String_Node_Str"+ "String_Node_Str"+ ExportHTMLAction._getTitleText(destinationObject)+ "String_Node_Str");
      }
    }
 else     if (frame instanceof ImageExportable) {
      gifFile=new File(directory,name + "String_Node_Str");
      OutputStream gifOut=new FileOutputStream(gifFile);
      try {
        ((ImageExportable)frame).writeImage(gifOut,"String_Node_Str");
      }
  finally {
        gifOut.close();
      }
      exporter.defineAreaAttribute(sourceObject,"String_Node_Str",name + "String_Node_Str",true);
      exporter.defineAreaAttribute(sourceObject,"String_Node_Str","String_Node_Str",true);
    }
  }
}