Program: 75948
Project: 75948
Buggy source:
/** 
 * Create a new effigy in the given container by reading the specified URL. If the specified URL is null, then create a blank effigy. The blank effigy will have a new model associated with it. If this effigy factory contains an entity named "blank", then the new model will be a clone of that entity.  Otherwise, it will be an instance of TypedCompositeActor. If the URL does not end with extension ".xml" or ".moml", then return null.  If the URL points to an XML file that is not a MoML file, then also return null. The specified base is used to expand any relative file references within the URL.
 * @param container The container for the effigy.
 * @param base The base for relative file references, or null ifthere are no relative file references.
 * @param in The input URL.
 * @return A new instance of PtolemyEffigy, or null if the URLdoes not specify a Ptolemy II model.
 * @exception Exception If the URL cannot be read, or if the datais malformed in some way.
 */
public Effigy createEffigy(CompositeEntity container,URL base,URL in) throws Exception {
  PtolemyEffigy effigy=new PtolemyEffigy(container,container.uniqueName("String_Node_Str"));
  if (in == null) {
    NamedObj entity=getEntity("String_Node_Str");
    NamedObj newModel;
    if (entity != null) {
      newModel=(NamedObj)entity.clone(new Workspace());
    }
 else {
      newModel=new TypedCompositeActor(new Workspace());
    }
    newModel.setName("String_Node_Str");
    effigy.setModel(newModel);
    return effigy;
  }
 else {
    String extension=getExtension(in);
    if (!extension.equals("String_Node_Str") && !extension.equals("String_Node_Str")) {
      return null;
    }
    MoMLParser parser=new MoMLParser();
    NamedObj toplevel=null;
    try {
      try {
        toplevel=parser.parse(base,in.openStream());
        if (toplevel != null) {
          effigy.setModel(toplevel);
          URLAttribute url=new URLAttribute(toplevel,"String_Node_Str");
          url.setURL(in);
          effigy.url.setURL(in);
          return effigy;
        }
 else {
          effigy.setContainer(null);
        }
      }
 catch (      Exception e) {
        ModelDirectory dir=(ModelDirectory)effigy.topEffigy().getContainer();
        List effigies=dir.entityList(Effigy.class);
        if (effigies.size() <= 2) {
          MessageHandler.error("String_Node_Str" + in,e);
        }
 else {
          throw e;
        }
      }
    }
  finally {
      if (toplevel == null) {
        effigy.setContainer(null);
      }
    }
    return null;
  }
}

Fixed version (ground truth):
/** 
 * Create a new effigy in the given container by reading the specified URL. If the specified URL is null, then create a blank effigy. The blank effigy will have a new model associated with it. If this effigy factory contains an entity named "blank", then the new model will be a clone of that entity.  Otherwise, it will be an instance of TypedCompositeActor. If the URL does not end with extension ".xml" or ".moml", then return null.  If the URL points to an XML file that is not a MoML file, then also return null. The specified base is used to expand any relative file references within the URL.
 * @param container The container for the effigy.
 * @param base The base for relative file references, or null ifthere are no relative file references.
 * @param in The input URL.
 * @return A new instance of PtolemyEffigy, or null if the URLdoes not specify a Ptolemy II model.
 * @exception Exception If the URL cannot be read, or if the datais malformed in some way.
 */
public Effigy createEffigy(CompositeEntity container,URL base,URL in) throws Exception {
  if (in == null) {
    PtolemyEffigy effigy=new PtolemyEffigy(container,container.uniqueName("String_Node_Str"));
    NamedObj entity=getEntity("String_Node_Str");
    NamedObj newModel;
    if (entity != null) {
      newModel=(NamedObj)entity.clone(new Workspace());
    }
 else {
      newModel=new TypedCompositeActor(new Workspace());
    }
    newModel.setName("String_Node_Str");
    effigy.setModel(newModel);
    return effigy;
  }
 else {
    String extension=getExtension(in);
    if (!extension.equals("String_Node_Str") && !extension.equals("String_Node_Str")) {
      return null;
    }
    PtolemyEffigy effigy=new PtolemyEffigy(container,container.uniqueName("String_Node_Str"));
    MoMLParser parser=new MoMLParser();
    NamedObj toplevel=null;
    try {
      try {
        toplevel=parser.parse(base,in.openStream());
        if (toplevel != null) {
          effigy.setModel(toplevel);
          URLAttribute url=new URLAttribute(toplevel,"String_Node_Str");
          url.setURL(in);
          effigy.url.setURL(in);
          return effigy;
        }
 else {
          effigy.setContainer(null);
        }
      }
 catch (      Exception e) {
        ModelDirectory dir=(ModelDirectory)effigy.topEffigy().getContainer();
        List effigies=dir.entityList(Effigy.class);
        if (effigies.size() <= 2) {
          MessageHandler.error("String_Node_Str" + in,e);
        }
 else {
          throw e;
        }
      }
    }
  finally {
      if (toplevel == null) {
        effigy.setContainer(null);
      }
    }
    return null;
  }
}