Program: 75181
Project: 75181
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.
 * @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());
            catchTableau(tableau);
            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());
      catchTableau(tableau);
      tableau.show();
      return tableau;
    }
 catch (    Exception ex) {
      MessageHandler.error("String_Node_Str" + effigy.identifier.getExpression(),ex);
      try {
        effigy.setContainer(null);
      }
 catch (      KernelException kernelException) {
        throw new InternalErrorException(this,kernelException,null);
      }
    }
  }
  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.
 * @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());
            catchTableau(tableau);
            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());
      catchTableau(tableau);
      tableau.show();
      return tableau;
    }
 catch (    Exception ex) {
      MessageHandler.error("String_Node_Str" + effigy.identifier.getExpression(),ex);
      try {
        effigy.setContainer(null);
      }
 catch (      KernelException kernelException) {
        throw new InternalErrorException(this,kernelException,null);
      }
    }
  }
  return null;
}