Program: 75182
Project: 75182
Buggy source:
/** 
 * Create the first tableau for the given effigy, using the tableau factory.  This is called after an effigy is first opened, or when a new effigy is created.  If the method fails to create a tableau, then it removes the effigy from the directory. This prevents us from having lingering effigies that have no user interface.
 * @return A tableau for the specified effigy, or null if nonecan be opened.
 * @param effigy The effigy for which to create a tableau.
 */
public Tableau createPrimaryTableau(final Effigy effigy){
  TableauFactory factory=null;
  if (effigy instanceof PtolemyEffigy) {
    NamedObj model=((PtolemyEffigy)effigy).getModel();
    if (model != null) {
      Iterator factories=model.attributeList(TableauFactory.class).iterator();
      while (factories.hasNext() && factory == null) {
        factory=(TableauFactory)factories.next();
        try {
          Tableau tableau=factory.createTableau(effigy);
          if (tableau != null) {
            if (effigy.getContainer() instanceof ModelDirectory) {
              tableau.setMaster(true);
            }
            tableau.setEditable(effigy.isModifiable());
            tableau.show();
            return tableau;
          }
        }
 catch (        Exception ex) {
          factory=null;
        }
      }
    }
  }
  factory=(TableauFactory)getAttribute("String_Node_Str");
  if (factory != null) {
    try {
      Tableau tableau=factory.createTableau(effigy);
      if (tableau == null) {
        throw new Exception("String_Node_Str");
      }
      if (effigy.getContainer() instanceof ModelDirectory) {
        tableau.setMaster(true);
      }
      tableau.setEditable(effigy.isModifiable());
      tableau.show();
      return tableau;
    }
 catch (    Exception ex) {
      try {
        effigy.setContainer(null);
      }
 catch (      KernelException kernelException) {
        throw new InternalErrorException(this,kernelException,null);
      }
      if (effigy instanceof PtolemyEffigy) {
        NamedObj object=((PtolemyEffigy)effigy).getModel();
        String filename=StringUtilities.objectToSourceFileName(object);
        try {
          URL toRead=getClass().getClassLoader().getResource(filename);
          if (toRead != null) {
            return openModel(null,toRead,toRead.toExternalForm());
          }
 else {
            MessageHandler.error("String_Node_Str" + object.getFullName());
          }
        }
 catch (        Exception exception) {
          MessageHandler.error("String_Node_Str" + object.getFullName(),exception);
        }
      }
      MessageHandler.error("String_Node_Str" + effigy.identifier.getExpression(),ex);
    }
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Create the first tableau for the given effigy, using the tableau factory.  This is called after an effigy is first opened, or when a new effigy is created.  If the method fails to create a tableau, then it removes the effigy from the directory. This prevents us from having lingering effigies that have no user interface.
 * @return A tableau for the specified effigy, or null if nonecan be opened.
 * @param effigy The effigy for which to create a tableau.
 */
public Tableau createPrimaryTableau(final Effigy effigy){
  TableauFactory factory=null;
  if (effigy instanceof PtolemyEffigy) {
    NamedObj model=((PtolemyEffigy)effigy).getModel();
    if (model != null) {
      Iterator factories=model.attributeList(TableauFactory.class).iterator();
      while (factories.hasNext() && factory == null) {
        factory=(TableauFactory)factories.next();
        try {
          Tableau tableau=factory.createTableau(effigy);
          if (tableau != null) {
            if (effigy.masterEffigy() == effigy) {
              tableau.setMaster(true);
            }
            tableau.setEditable(effigy.isModifiable());
            tableau.show();
            return tableau;
          }
        }
 catch (        Exception ex) {
          factory=null;
        }
      }
    }
  }
  factory=(TableauFactory)getAttribute("String_Node_Str");
  if (factory != null) {
    try {
      Tableau tableau=factory.createTableau(effigy);
      if (tableau == null) {
        throw new Exception("String_Node_Str");
      }
      if (effigy.getContainer() instanceof ModelDirectory) {
        tableau.setMaster(true);
      }
      tableau.setEditable(effigy.isModifiable());
      tableau.show();
      return tableau;
    }
 catch (    Exception ex) {
      try {
        effigy.setContainer(null);
      }
 catch (      KernelException kernelException) {
        throw new InternalErrorException(this,kernelException,null);
      }
      if (effigy instanceof PtolemyEffigy) {
        NamedObj object=((PtolemyEffigy)effigy).getModel();
        String filename=StringUtilities.objectToSourceFileName(object);
        try {
          URL toRead=getClass().getClassLoader().getResource(filename);
          if (toRead != null) {
            return openModel(null,toRead,toRead.toExternalForm());
          }
 else {
            MessageHandler.error("String_Node_Str" + object.getFullName());
          }
        }
 catch (        Exception exception) {
          MessageHandler.error("String_Node_Str" + object.getFullName(),exception);
        }
      }
      MessageHandler.error("String_Node_Str" + effigy.identifier.getExpression(),ex);
    }
  }
  return null;
}