nus-yam/ex-repair huggingface dataset:
Program: 73296
Project: 73296
Buggy source:
/** 
 * Create a new instance of the RemoteSink either by replacing the targetEntity or by replacing all entities connected to it.
 * @param targetEntity The target entity to be processed
 * @param replaceTargetEntity replaceTargetEntity true to replacethe target entity with the proxy, otherwise replace all entities connecting to it with one proxy
 * @param portTypes The map of ports and their resolved types
 * @exception IllegalActionException If the actor cannot be containedby the proposed container.
 * @exception NameDuplicationException If the container already has anactor with this name.
 * @exception CloneNotSupportedException If port cloning is not supported
 * @see ptserver.actor.RemoteSink
 */
private void _createSink(ComponentEntity targetEntity,boolean replaceTargetEntity,HashMap<String,String> portTypes) throws IllegalActionException, NameDuplicationException, CloneNotSupportedException {
  RemoteSink remoteSink=new RemoteSink((CompositeEntity)targetEntity.getContainer(),targetEntity,replaceTargetEntity,portTypes);
  remoteSink.setTokenPublisher(_tokenPublisher);
  _remoteSinkMap.put(remoteSink.getTargetEntityName(),remoteSink);
}

Fixed version (ground truth):
/** 
 * Create a new instance of the RemoteSink either by replacing the targetEntity or by replacing all entities connected to it.
 * @param targetEntity The target entity to be processed
 * @param replaceTargetEntity replaceTargetEntity true to replacethe target entity with the proxy, otherwise replace all entities connecting to it with one proxy
 * @param portTypes The map of ports and their resolved types
 * @exception IllegalActionException If the actor cannot be containedby the proposed container.
 * @exception NameDuplicationException If the container already has anactor with this name.
 * @exception CloneNotSupportedException If port cloning is not supported
 * @see ptserver.actor.RemoteSink
 */
private void _createSink(ComponentEntity targetEntity,boolean replaceTargetEntity,HashMap<String,Type> portTypes) throws IllegalActionException, NameDuplicationException, CloneNotSupportedException {
  RemoteSink remoteSink=new RemoteSink((CompositeEntity)targetEntity.getContainer(),targetEntity,replaceTargetEntity,portTypes);
  remoteSink.setTokenPublisher(_tokenPublisher);
  _remoteSinkMap.put(remoteSink.getTargetEntityName(),remoteSink);
}
Program: 73297
Project: 73297
Buggy source:
/** 
 * Capture inferred types of the entities.
 * @param entities The entities whose inferred types are captured
 * @param portTypes The mapping that stores the types
 * @exception IllegalActionException If there is a probleminferring type of Typeable.
 */
private void _captureModelTypes(HashSet<ComponentEntity> entities,HashMap<String,String> portTypes) throws IllegalActionException {
  for (  ComponentEntity entity : entities) {
    for (    Object portObject : entity.portList()) {
      Port port=(Port)portObject;
      if (port instanceof IOPort) {
        if (port instanceof TypedIOPort) {
          portTypes.put(port.getFullName(),((TypedIOPort)port).getType().toString());
        }
        IOPort ioPort=(IOPort)port;
        for (        Object relationObject : ioPort.linkedRelationList()) {
          Relation relation=(Relation)relationObject;
          List<Port> portList=relation.linkedPortList(port);
          for (          Port connectingPort : portList) {
            if (connectingPort instanceof TypedIOPort) {
              portTypes.put(connectingPort.getFullName(),((TypedIOPort)connectingPort).getType().toString());
            }
          }
        }
      }
    }
    for (    Typeable attribute : entity.attributeList(Typeable.class)) {
      portTypes.put(((Nameable)attribute).getFullName(),attribute.getType().toString());
    }
  }
}

Fixed version (ground truth):
/** 
 * Capture inferred types of the entities.
 * @param entities The entities whose inferred types are captured
 * @param portTypes The mapping that stores the types
 * @exception IllegalActionException If there is a probleminferring type of Typeable.
 */
private void _captureModelTypes(HashSet<ComponentEntity> entities,HashMap<String,Type> portTypes) throws IllegalActionException {
  for (  ComponentEntity entity : entities) {
    for (    Object portObject : entity.portList()) {
      Port port=(Port)portObject;
      if (port instanceof IOPort) {
        if (port instanceof TypedIOPort) {
          portTypes.put(port.getFullName(),((TypedIOPort)port).getType());
        }
        IOPort ioPort=(IOPort)port;
        for (        Object relationObject : ioPort.linkedRelationList()) {
          Relation relation=(Relation)relationObject;
          List<Port> portList=relation.linkedPortList(port);
          for (          Port connectingPort : portList) {
            if (connectingPort instanceof TypedIOPort) {
              portTypes.put(connectingPort.getFullName(),((TypedIOPort)connectingPort).getType());
            }
          }
        }
      }
    }
    for (    Typeable attribute : entity.attributeList(Typeable.class)) {
      portTypes.put(((Nameable)attribute).getFullName(),attribute.getType());
    }
  }
}
Program: 73299
Project: 73299
Buggy source:
/** 
 * Create a new instance of the RemoteSource either by replacing the targetEntity or by replacing all entities connected to it.
 * @param targetEntity The target entity to be processed
 * @param replaceTargetEntity replaceTargetEntity true to replacethe target entity with the proxy, otherwise replace all entities connecting to it with one proxy
 * @param portTypes The map of ports and their resolved types
 * @exception IllegalActionException If the actor cannot be containedby the proposed container.
 * @exception NameDuplicationException If the container already has anactor with this name.
 * @exception CloneNotSupportedException If port cloning is not supported
 * @see ptserver.actor.RemoteSource
 */
private void _createSource(ComponentEntity targetEntity,boolean replaceTargetEntity,HashMap<String,String> portTypes) throws IllegalActionException, NameDuplicationException, CloneNotSupportedException {
  RemoteSource remoteSource=new RemoteSource((CompositeEntity)targetEntity.getContainer(),targetEntity,replaceTargetEntity,portTypes);
  RemoteSourceData data=new RemoteSourceData(remoteSource,this);
  getRemoteSourceMap().put(remoteSource.getTargetEntityName(),data);
}

Fixed version (ground truth):
/** 
 * Create a new instance of the RemoteSource either by replacing the targetEntity or by replacing all entities connected to it.
 * @param targetEntity The target entity to be processed
 * @param replaceTargetEntity replaceTargetEntity true to replacethe target entity with the proxy, otherwise replace all entities connecting to it with one proxy
 * @param portTypes The map of ports and their resolved types
 * @exception IllegalActionException If the actor cannot be containedby the proposed container.
 * @exception NameDuplicationException If the container already has anactor with this name.
 * @exception CloneNotSupportedException If port cloning is not supported
 * @see ptserver.actor.RemoteSource
 */
private void _createSource(ComponentEntity targetEntity,boolean replaceTargetEntity,HashMap<String,Type> portTypes) throws IllegalActionException, NameDuplicationException, CloneNotSupportedException {
  RemoteSource remoteSource=new RemoteSource((CompositeEntity)targetEntity.getContainer(),targetEntity,replaceTargetEntity,portTypes);
  RemoteSourceData data=new RemoteSourceData(remoteSource,this);
  getRemoteSourceMap().put(remoteSource.getTargetEntityName(),data);
}
Program: 73300
Project: 73300
Buggy source:
/** 
 * Get the map from the Typeable's full name to its type.
 * @return The map from the Typeable's full name to its type.
 * @see #setResolvedTypes(HashMap)
 */
public HashMap<String,String> getResolvedTypes(){
  return _resolvedTypes;
}

Fixed version (ground truth):
/** 
 * Get the map from the Typeable's full name to its type.
 * @return The map from the Typeable's full name to its type.
 * @see #setResolvedTypes(HashMap)
 */
public HashMap<String,Type> getResolvedTypes(){
  return _resolvedTypes;
}
Program: 73301
Project: 73301
Buggy source:
/** 
 * Get the map from the model's Typeable objects to its inferred type. <p>This map contains only types for the sinks and sources intended to run on Android.</p>
 * @return the map from the Typeable to its inferred type.
 * @see #setModelTypes(HashMap)
 */
public HashMap<String,String> getModelTypes(){
  return _modelTypes;
}

Fixed version (ground truth):
/** 
 * Get the map from the model's Typeable objects to its inferred type. <p>This map contains only types for the sinks and sources intended to run on Android.</p>
 * @return the map from the Typeable to its inferred type.
 * @see #setModelTypes(HashMap)
 */
public HashMap<String,Type> getModelTypes(){
  return _modelTypes;
}
Program: 73302
Project: 73302
Buggy source:
/** 
 * Set the map from the model's Typeable objects to its inferred type.
 * @param modelTypes The map from the Typeable to its inferred type.
 * @see #getModelTypes()
 */
public void setModelTypes(HashMap<String,String> modelTypes){
  _modelTypes=modelTypes;
}

Fixed version (ground truth):
/** 
 * Set the map from the model's Typeable objects to its inferred type.
 * @param modelTypes The map from the Typeable to its inferred type.
 * @see #getModelTypes()
 */
public void setModelTypes(HashMap<String,Type> modelTypes){
  _modelTypes=modelTypes;
}
Program: 73307
Project: 73307
Buggy source:
/** 
 * Replace the targetSink with the RemoteSink instance.
 * @param container The container
 * @param targetSink The target sink
 * @param replaceTargetEntity replaceTargetEntity true to replace the target entity with the proxy,otherwise replace all entities connecting to it with one proxy
 * @param portTypes Map of ports and their resolved types
 * @exception IllegalActionException If the actor cannot be containedby the proposed container.
 * @exception NameDuplicationException If the container already has anactor with this name.
 * @exception CloneNotSupportedException If port cloning is not supported
 * @see RemoteActor
 */
public RemoteSink(CompositeEntity container,ComponentEntity targetSink,boolean replaceTargetEntity,HashMap<String,Type> portTypes) throws IllegalActionException, NameDuplicationException, CloneNotSupportedException {
  super(container,targetSink,replaceTargetEntity,portTypes);
}

Fixed version (ground truth):
/** 
 * Replace the targetSink with the RemoteSink instance.
 * @param container The container
 * @param targetSink The target sink
 * @param replaceTargetEntity replaceTargetEntity true to replace the target entity with the proxy,otherwise replace all entities connecting to it with one proxy
 * @param portTypes Map of ports and their resolved types
 * @exception IllegalActionException If the actor cannot be containedby the proposed container.
 * @exception NameDuplicationException If the container already has anactor with this name.
 * @exception CloneNotSupportedException If port cloning is not supported
 * @see RemoteActor
 */
public RemoteSink(CompositeEntity container,ComponentEntity targetSink,boolean replaceTargetEntity,HashMap<String,String> portTypes) throws IllegalActionException, NameDuplicationException, CloneNotSupportedException {
  super(container,targetSink,replaceTargetEntity,portTypes);
}
Program: 73308
Project: 73308
Buggy source:
/** 
 * Replace the targetSource with the RemoteSource instance.
 * @param container The container
 * @param targetSource The target source
 * @param replaceTargetEntity replaceTargetEntity true to replace the target entity with the proxy,otherwise replace all entities connecting to it with one proxy
 * @param portTypes Map of ports and their resolved types
 * @exception IllegalActionException If the actor cannot be containedby the proposed container.
 * @exception NameDuplicationException If the container already has anactor with this name.
 * @exception CloneNotSupportedException If port cloning is not supported
 * @see RemoteActor
 */
public RemoteSource(CompositeEntity container,ComponentEntity targetSource,boolean replaceTargetEntity,HashMap<String,Type> portTypes) throws IllegalActionException, NameDuplicationException, CloneNotSupportedException {
  super(container,targetSource,replaceTargetEntity,portTypes);
}

Fixed version (ground truth):
/** 
 * Replace the targetSource with the RemoteSource instance.
 * @param container The container
 * @param targetSource The target source
 * @param replaceTargetEntity replaceTargetEntity true to replace the target entity with the proxy,otherwise replace all entities connecting to it with one proxy
 * @param portTypes Map of ports and their resolved types
 * @exception IllegalActionException If the actor cannot be containedby the proposed container.
 * @exception NameDuplicationException If the container already has anactor with this name.
 * @exception CloneNotSupportedException If port cloning is not supported
 * @see RemoteActor
 */
public RemoteSource(CompositeEntity container,ComponentEntity targetSource,boolean replaceTargetEntity,HashMap<String,String> portTypes) throws IllegalActionException, NameDuplicationException, CloneNotSupportedException {
  super(container,targetSource,replaceTargetEntity,portTypes);
}
Program: 73310
Project: 73310
Buggy source:
/** 
 * Create a new instance of the RemoteSink either by replacing the targetEntity or by replacing all entities connected to it.
 * @param targetEntity The target entity to be processed
 * @param replaceTargetEntity replaceTargetEntity true to replacethe target entity with the proxy, otherwise replace all entities connecting to it with one proxy
 * @param portTypes The map of ports and their resolved types
 * @exception IllegalActionException If the actor cannot be containedby the proposed container.
 * @exception NameDuplicationException If the container already has anactor with this name.
 * @exception CloneNotSupportedException If port cloning is not supported
 * @see ptserver.actor.RemoteSink
 */
private void _createSink(ComponentEntity targetEntity,boolean replaceTargetEntity,HashMap<String,Type> portTypes) throws IllegalActionException, NameDuplicationException, CloneNotSupportedException {
  RemoteSink remoteSink=new RemoteSink((CompositeEntity)targetEntity.getContainer(),targetEntity,replaceTargetEntity,portTypes);
  remoteSink.setTokenPublisher(_tokenPublisher);
  _remoteSinkMap.put(remoteSink.getTargetEntityName(),remoteSink);
}

Fixed version (ground truth):
/** 
 * Create a new instance of the RemoteSink either by replacing the targetEntity or by replacing all entities connected to it.
 * @param targetEntity The target entity to be processed
 * @param replaceTargetEntity replaceTargetEntity true to replacethe target entity with the proxy, otherwise replace all entities connecting to it with one proxy
 * @param portTypes The map of ports and their resolved types
 * @exception IllegalActionException If the actor cannot be containedby the proposed container.
 * @exception NameDuplicationException If the container already has anactor with this name.
 * @exception CloneNotSupportedException If port cloning is not supported
 * @see ptserver.actor.RemoteSink
 */
private void _createSink(ComponentEntity targetEntity,boolean replaceTargetEntity,HashMap<String,String> portTypes) throws IllegalActionException, NameDuplicationException, CloneNotSupportedException {
  RemoteSink remoteSink=new RemoteSink((CompositeEntity)targetEntity.getContainer(),targetEntity,replaceTargetEntity,portTypes);
  remoteSink.setTokenPublisher(_tokenPublisher);
  _remoteSinkMap.put(remoteSink.getTargetEntityName(),remoteSink);
}
Program: 73311
Project: 73311
Buggy source:
/** 
 * Capture inferred types of the entities.
 * @param entities The entities whose inferred types are captured
 * @param portTypes The mapping that stores the types
 * @exception IllegalActionException If there is a probleminferring type of Typeable.
 */
private void _captureModelTypes(HashSet<ComponentEntity> entities,HashMap<String,Type> portTypes) throws IllegalActionException {
  for (  ComponentEntity entity : entities) {
    for (    Object portObject : entity.portList()) {
      Port port=(Port)portObject;
      if (port instanceof IOPort) {
        if (port instanceof TypedIOPort) {
          portTypes.put(port.getFullName(),((TypedIOPort)port).getType());
        }
        IOPort ioPort=(IOPort)port;
        for (        Object relationObject : ioPort.linkedRelationList()) {
          Relation relation=(Relation)relationObject;
          List<Port> portList=relation.linkedPortList(port);
          for (          Port connectingPort : portList) {
            if (connectingPort instanceof TypedIOPort) {
              portTypes.put(connectingPort.getFullName(),((TypedIOPort)connectingPort).getType());
            }
          }
        }
      }
    }
    for (    Typeable attribute : entity.attributeList(Typeable.class)) {
      portTypes.put(((Nameable)attribute).getFullName(),attribute.getType());
    }
  }
}

Fixed version (ground truth):
/** 
 * Capture inferred types of the entities.
 * @param entities The entities whose inferred types are captured
 * @param portTypes The mapping that stores the types
 * @exception IllegalActionException If there is a probleminferring type of Typeable.
 */
private void _captureModelTypes(HashSet<ComponentEntity> entities,HashMap<String,String> portTypes) throws IllegalActionException {
  for (  ComponentEntity entity : entities) {
    for (    Object portObject : entity.portList()) {
      Port port=(Port)portObject;
      if (port instanceof IOPort) {
        if (port instanceof TypedIOPort) {
          portTypes.put(port.getFullName(),((TypedIOPort)port).getType().toString());
        }
        IOPort ioPort=(IOPort)port;
        for (        Object relationObject : ioPort.linkedRelationList()) {
          Relation relation=(Relation)relationObject;
          List<Port> portList=relation.linkedPortList(port);
          for (          Port connectingPort : portList) {
            if (connectingPort instanceof TypedIOPort) {
              portTypes.put(connectingPort.getFullName(),((TypedIOPort)connectingPort).getType().toString());
            }
          }
        }
      }
    }
    for (    Typeable attribute : entity.attributeList(Typeable.class)) {
      portTypes.put(((Nameable)attribute).getFullName(),attribute.getType().toString());
    }
  }
}
Program: 73313
Project: 73313
Buggy source:
/** 
 * Create a new instance of the RemoteSource either by replacing the targetEntity or by replacing all entities connected to it.
 * @param targetEntity The target entity to be processed
 * @param replaceTargetEntity replaceTargetEntity true to replacethe target entity with the proxy, otherwise replace all entities connecting to it with one proxy
 * @param portTypes The map of ports and their resolved types
 * @exception IllegalActionException If the actor cannot be containedby the proposed container.
 * @exception NameDuplicationException If the container already has anactor with this name.
 * @exception CloneNotSupportedException If port cloning is not supported
 * @see ptserver.actor.RemoteSource
 */
private void _createSource(ComponentEntity targetEntity,boolean replaceTargetEntity,HashMap<String,Type> portTypes) throws IllegalActionException, NameDuplicationException, CloneNotSupportedException {
  RemoteSource remoteSource=new RemoteSource((CompositeEntity)targetEntity.getContainer(),targetEntity,replaceTargetEntity,portTypes);
  RemoteSourceData data=new RemoteSourceData(remoteSource,this);
  getRemoteSourceMap().put(remoteSource.getTargetEntityName(),data);
}

Fixed version (ground truth):
/** 
 * Create a new instance of the RemoteSource either by replacing the targetEntity or by replacing all entities connected to it.
 * @param targetEntity The target entity to be processed
 * @param replaceTargetEntity replaceTargetEntity true to replacethe target entity with the proxy, otherwise replace all entities connecting to it with one proxy
 * @param portTypes The map of ports and their resolved types
 * @exception IllegalActionException If the actor cannot be containedby the proposed container.
 * @exception NameDuplicationException If the container already has anactor with this name.
 * @exception CloneNotSupportedException If port cloning is not supported
 * @see ptserver.actor.RemoteSource
 */
private void _createSource(ComponentEntity targetEntity,boolean replaceTargetEntity,HashMap<String,String> portTypes) throws IllegalActionException, NameDuplicationException, CloneNotSupportedException {
  RemoteSource remoteSource=new RemoteSource((CompositeEntity)targetEntity.getContainer(),targetEntity,replaceTargetEntity,portTypes);
  RemoteSourceData data=new RemoteSourceData(remoteSource,this);
  getRemoteSourceMap().put(remoteSource.getTargetEntityName(),data);
}
Program: 73314
Project: 73314
Buggy source:
/** 
 * Get the map from the Typeable's full name to its type.
 * @return The map from the Typeable's full name to its type.
 * @see #setResolvedTypes(HashMap)
 */
public HashMap<String,Type> getResolvedTypes(){
  return _resolvedTypes;
}

Fixed version (ground truth):
/** 
 * Get the map from the Typeable's full name to its type.
 * @return The map from the Typeable's full name to its type.
 * @see #setResolvedTypes(HashMap)
 */
public HashMap<String,String> getResolvedTypes(){
  return _resolvedTypes;
}
Program: 73315
Project: 73315
Buggy source:
/** 
 * Get the map from the model's Typeable objects to its inferred type. <p>This map contains only types for the sinks and sources intended to run on Android.</p>
 * @return the map from the Typeable to its inferred type.
 * @see #setModelTypes(HashMap)
 */
public HashMap<String,Type> getModelTypes(){
  return _modelTypes;
}

Fixed version (ground truth):
/** 
 * Get the map from the model's Typeable objects to its inferred type. <p>This map contains only types for the sinks and sources intended to run on Android.</p>
 * @return the map from the Typeable to its inferred type.
 * @see #setModelTypes(HashMap)
 */
public HashMap<String,String> getModelTypes(){
  return _modelTypes;
}
Program: 73316
Project: 73316
Buggy source:
/** 
 * Set the map from the model's Typeable objects to its inferred type.
 * @param modelTypes The map from the Typeable to its inferred type.
 * @see #getModelTypes()
 */
public void setModelTypes(HashMap<String,Type> modelTypes){
  _modelTypes=modelTypes;
}

Fixed version (ground truth):
/** 
 * Set the map from the model's Typeable objects to its inferred type.
 * @param modelTypes The map from the Typeable to its inferred type.
 * @see #getModelTypes()
 */
public void setModelTypes(HashMap<String,String> modelTypes){
  _modelTypes=modelTypes;
}
Program: 73319
Project: 73319
Buggy source:
/** 
 * <p>This private constructor loads mappings from a token class to its TokenHandler from TokenHandlers.properties file which is located in ptserver/data directory.</p> <p>This constructor is private because the TokenParser is singleton which makes it easy to locate the instance without passing it around.</p>
 * @exception IllegalActionException if there is a problem loading the mapping from TokenHandlers.properties file.
 */
private TokenParser() throws IllegalActionException {
  Enumeration<String> keys=_tokenHandlersBundle.getKeys();
  while (keys.hasMoreElements()) {
    String key=keys.nextElement();
    String value=_tokenHandlersBundle.getString(key);
    try {
      ClassLoader classLoader=getClass().getClassLoader();
      Class<Token> tokenClass=(Class<Token>)classLoader.loadClass(key);
      TokenHandler<Token> tokenHandler=(TokenHandler<Token>)classLoader.loadClass(value).newInstance();
      HandlerData<Token> data=new HandlerData<Token>(tokenHandler,tokenClass,(short)_handlerList.size());
      _handlerMap.put(tokenClass,data);
      _handlerList.add(data);
    }
 catch (    ClassNotFoundException e) {
      throw new IllegalActionException(null,e,"String_Node_Str" + key + "String_Node_Str"+ value);
    }
catch (    InstantiationException e) {
      throw new IllegalActionException(null,e,"String_Node_Str" + value);
    }
catch (    IllegalAccessException e) {
      throw new IllegalActionException(null,e,"String_Node_Str" + value);
    }
  }
}

Fixed version (ground truth):
/** 
 * <p>This private constructor loads mappings from a token class to its TokenHandler from TokenHandlers.properties file which is located in ptserver/data directory.</p> <p>This constructor is private because the TokenParser is singleton which makes it easy to locate the instance without passing it around.</p>
 * @exception IllegalActionException if there is a problem loading the mapping from TokenHandlers.properties file.
 */
private TokenParser() throws IllegalActionException {
  LinkedHashMap<String,String> tokenHandlerMap=new LinkedHashMap<String,String>();
  Enumeration<String> keys=_tokenHandlersBundle.getKeys();
  while (keys.hasMoreElements()) {
    String key=keys.nextElement();
    tokenHandlerMap.put(key,_tokenHandlersBundle.getString(key));
  }
  setTokenHandlers(tokenHandlerMap);
}
Program: 73320
Project: 73320
Buggy source:
/** 
 * Entry point to the Ptolemy MQTT Client which is used for testing purposes.
 * @param args The first argument is file path to the model
 */
public static void main(String[] args){
  try {
    RemoteModel model=new RemoteModel(RemoteModelType.CLIENT);
    URL resource=PtolemyTestClient.class.getResource("String_Node_Str");
    model.loadModel(resource);
    Manager manager=model.setUpInfrastructure(Ticket.generateTicket(null,null),"String_Node_Str");
    CompositeActor topLevelActor=model.getTopLevelActor();
    topLevelActor.getDirector().setContainer(null);
    topLevelActor.setDirector(new PNDirector(topLevelActor,"String_Node_Str"));
    System.out.println(topLevelActor.exportMoML());
    manager.execute();
  }
 catch (  Throwable throwable) {
    throwable.printStackTrace();
  }
}

Fixed version (ground truth):
/** 
 * Entry point to the Ptolemy MQTT Client which is used for testing purposes.
 * @param args The first argument is file path to the model
 */
public static void main(String[] args){
  try {
    RemoteModel model=new RemoteModel(RemoteModelType.CLIENT);
    URL resource=PtolemyTestClient.class.getResource("String_Node_Str");
    model.loadModel(resource);
    CompositeActor topLevelActor=model.getTopLevelActor();
    System.out.println(topLevelActor.exportMoML());
  }
 catch (  Throwable throwable) {
    throwable.printStackTrace();
  }
}
Program: 73325
Project: 73325
Buggy source:
/** 
 * Convert the Ping or Pong token to the by stream.
 * @param token the token to be converted
 * @param outputStream the outputStream holding stream of bytes
 * @see ptserver.data.handler.TokenHandler#convertToBytes(ptolemy.data.Token,java.io.DataOutputStream)
 * @exception IOException if there is a problem with the outputStream
 * @exception IllegalActionException if there is the state becomes inconsistent
 */
public void convertToBytes(Token token,DataOutputStream outputStream) throws IOException, IllegalActionException {
  if (token.getClass() == PingToken.class) {
    outputStream.writeLong(((PingToken)token).getTimestamp());
  }
 else   if (token.getClass() == PongToken.class) {
    outputStream.writeLong(((PongToken)token).getTimestamp());
  }
 else {
    throw new IllegalStateException("String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Convert the Ping or Pong token to the by stream.
 * @param token the token to be converted
 * @param outputStream the outputStream holding stream of bytes
 * @see ptserver.data.handler.TokenHandler#convertToBytes(ptolemy.data.Token,java.io.DataOutputStream)
 * @exception IOException if there is a problem with the outputStream
 * @exception IllegalActionException if there is the state becomes inconsistent
 */
public void convertToBytes(Token token,DataOutputStream outputStream) throws IOException, IllegalActionException {
  if (token instanceof PingToken) {
    outputStream.writeLong(((PingToken)token).getTimestamp());
  }
 else   if (token instanceof PongToken) {
    outputStream.writeLong(((PongToken)token).getTimestamp());
  }
 else {
    throw new IllegalStateException("String_Node_Str");
  }
}
Program: 73326
Project: 73326
Buggy source:
/** 
 * Create and return a file dialog for the "Save As" command. This overrides the base class to add options to the dialog. If   {@link ptolemy.gui.PtGUIUtilities#useFileDialog()} returns truethen  {@link ptolemy.gui.Top#_saveAs()} uses this method.  Otherwise, {@link #_saveAsJFileChooserComponent()} is used.
 * @return A file dialog for save as.
 */
protected FileDialog _saveAsFileDialogComponent(){
  FileDialog fileDialog=super._saveAsFileDialogComponent();
  if ((_model != null) && (_model.getContainer() != null)) {
    _query=new Query();
    _query.addCheckBox("String_Node_Str","String_Node_Str",false);
    new ComponentDialog(this,"String_Node_Str",_query);
  }
  return fileDialog;
}

Fixed version (ground truth):
/** 
 * Create and return a file dialog for the "Save As" command. This overrides the base class to add options to the dialog. If   {@link ptolemy.gui.PtGUIUtilities#useFileDialog()} returns truethen  {@link ptolemy.gui.Top#_saveAs()} uses this method.  Otherwise, {@link #_saveAsJFileChooserComponent()} is used.
 * @return A file dialog for save as.
 */
protected FileDialog _saveAsFileDialogComponent(){
  FileDialog fileDialog=super._saveAsFileDialogComponent();
  if ((_model != null) && (_model.getContainer() != null)) {
    _query=new Query();
    _query.addCheckBox("String_Node_Str","String_Node_Str",false);
    ComponentDialog dialog=new ComponentDialog(this,"String_Node_Str",_query);
    String button=dialog.buttonPressed();
    if (button.equals("String_Node_Str")) {
      return null;
    }
  }
  return fileDialog;
}
Program: 73328
Project: 73328
Buggy source:
/** 
 * Query the user for a filename and save the model to that file.
 * @return True if the save succeeds.
 */
private boolean _saveAsFileDialogImplementation(){
  FileDialog fileDialog=_saveAsFileDialogComponent();
  fileDialog.show();
  _directory=new File(fileDialog.getDirectory());
  _file=new File(_directory,fileDialog.getFile());
  if (_file.exists()) {
    String query="String_Node_Str" + _file.getName() + "String_Node_Str";
    int selected=JOptionPane.showOptionDialog(this,query,"String_Node_Str",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE,null,null,null);
    if (selected == 1) {
      return false;
    }
  }
  setTitle(StringUtilities.abbreviate(_getName()));
  return _save();
}

Fixed version (ground truth):
/** 
 * Query the user for a filename and save the model to that file.
 * @return True if the save succeeds.
 */
private boolean _saveAsFileDialogImplementation(){
  FileDialog fileDialog=_saveAsFileDialogComponent();
  if (fileDialog == null) {
    return false;
  }
  fileDialog.show();
  _directory=new File(fileDialog.getDirectory());
  _file=new File(_directory,fileDialog.getFile());
  if (_file.exists()) {
    String query="String_Node_Str" + _file.getName() + "String_Node_Str";
    int selected=JOptionPane.showOptionDialog(this,query,"String_Node_Str",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE,null,null,null);
    if (selected == 1) {
      return false;
    }
  }
  setTitle(StringUtilities.abbreviate(_getName()));
  return _save();
}
Program: 73329
Project: 73329
Buggy source:
/** 
 * Resume the execution of the selected simulation.
 * @param ticket  The ticket reference to the simulation request.
 * @exception IllegalActionException  If the server was unable to resume the execution of thesimulation.
 */
public void resume(Ticket ticket) throws IllegalActionException {
  try {
    if ((ticket == null) || (!_requests.containsKey(ticket))) {
      throw new Exception("String_Node_Str" + ticket.getTicketID());
    }
    _requests.get(ticket).getManager().resume();
  }
 catch (  Exception e) {
    _handleException(ticket.getTicketID() + "String_Node_Str" + e.getMessage(),e);
  }
}

Fixed version (ground truth):
/** 
 * Resume the execution of the selected simulation.
 * @param ticket  The ticket reference to the simulation request.
 * @exception IllegalActionException  If the server was unable to resume the execution of thesimulation.
 */
public void resume(Ticket ticket) throws IllegalActionException {
  try {
    if (ticket == null) {
      throw new IllegalStateException("String_Node_Str" + null);
    }
    if (!_requests.containsKey(ticket)) {
      throw new IllegalStateException("String_Node_Str" + ticket.getTicketID());
    }
    _requests.get(ticket).getManager().resume();
  }
 catch (  Exception e) {
    _handleException((ticket != null ? ticket.getTicketID() : null) + "String_Node_Str" + e.getMessage(),e);
  }
}
Program: 73330
Project: 73330
Buggy source:
/** 
 * Start the execution of the selected simulation.
 * @param ticket  The ticket reference to the simulation request.
 * @exception IllegalActionException If the server was unable to start the simulation.
 */
public void start(Ticket ticket) throws IllegalActionException {
  try {
    if ((ticket == null) || (!_requests.containsKey(ticket))) {
      throw new Exception("String_Node_Str" + ticket.getTicketID());
    }
    _executor.execute(_requests.get(ticket));
  }
 catch (  Exception e) {
    _handleException(ticket.getTicketID() + "String_Node_Str" + e.getMessage(),e);
  }
}

Fixed version (ground truth):
/** 
 * Start the execution of the selected simulation.
 * @param ticket  The ticket reference to the simulation request.
 * @exception IllegalActionException If the server was unable to start the simulation.
 */
public void start(Ticket ticket) throws IllegalActionException {
  try {
    if (ticket == null) {
      throw new IllegalStateException("String_Node_Str" + null);
    }
    if (!_requests.containsKey(ticket)) {
      throw new IllegalStateException("String_Node_Str" + ticket.getTicketID());
    }
    _executor.execute(_requests.get(ticket));
  }
 catch (  Exception e) {
    _handleException((ticket != null ? ticket.getTicketID() : null) + "String_Node_Str" + e.getMessage(),e);
  }
}
Program: 73332
Project: 73332
Buggy source:
/** 
 * Pause the execution of the selected simulation.
 * @param ticket  The ticket reference to the simulation request.
 * @exception IllegalActionException If the server was unable to pause the running simulation.
 */
public void pause(Ticket ticket) throws IllegalActionException {
  try {
    if ((ticket == null) || (!_requests.containsKey(ticket))) {
      throw new Exception("String_Node_Str" + ticket.getTicketID());
    }
    _requests.get(ticket).getManager().pause();
  }
 catch (  Exception e) {
    _handleException(ticket.getTicketID() + "String_Node_Str" + e.getMessage(),e);
  }
}

Fixed version (ground truth):
/** 
 * Pause the execution of the selected simulation.
 * @param ticket  The ticket reference to the simulation request.
 * @exception IllegalActionException If the server was unable to pause the running simulation.
 */
public void pause(Ticket ticket) throws IllegalActionException {
  try {
    if (ticket == null) {
      throw new IllegalStateException("String_Node_Str" + null);
    }
    if (!_requests.containsKey(ticket)) {
      throw new IllegalStateException("String_Node_Str" + ticket.getTicketID());
    }
    _requests.get(ticket).getManager().pause();
  }
 catch (  Exception e) {
    _handleException((ticket != null ? ticket.getTicketID() : null) + "String_Node_Str" + e.getMessage(),e);
  }
}
Program: 73333
Project: 73333
Buggy source:
/** 
 * Stop the execution of the selected simulation.
 * @param ticket  The ticket reference to the simulation request.
 * @exception IllegalActionException If the server was unable to stop the simulation.
 */
public void stop(Ticket ticket) throws IllegalActionException {
  try {
    if ((ticket == null) || (!_requests.containsKey(ticket))) {
      throw new Exception("String_Node_Str" + ticket.getTicketID());
    }
    _requests.get(ticket).getManager().stop();
  }
 catch (  Exception e) {
    _handleException(ticket.getTicketID() + "String_Node_Str" + e.getMessage(),e);
  }
}

Fixed version (ground truth):
/** 
 * Stop the execution of the selected simulation.
 * @param ticket  The ticket reference to the simulation request.
 * @exception IllegalActionException If the server was unable to stop the simulation.
 */
public void stop(Ticket ticket) throws IllegalActionException {
  try {
    if (ticket == null) {
      throw new IllegalStateException("String_Node_Str" + null);
    }
    if (!_requests.containsKey(ticket)) {
      throw new IllegalStateException("String_Node_Str" + ticket.getTicketID());
    }
    _requests.get(ticket).getManager().stop();
  }
 catch (  Exception e) {
    _handleException((ticket != null ? ticket.getTicketID() : null) + "String_Node_Str" + e.getMessage(),e);
  }
}
Program: 73334
Project: 73334
Buggy source:
/** 
 * Shut down the thread associated with the user's ticket.
 * @param ticket  Ticket reference to the simulation request.
 * @exception IllegalActionException If the server was unable to destroy the simulation thread.
 */
public void close(Ticket ticket) throws IllegalActionException {
  try {
    if ((ticket == null) || (!_requests.containsKey(ticket))) {
      throw new Exception("String_Node_Str" + ticket.getTicketID());
    }
    _requests.get(ticket).getManager().finish();
    _requests.remove(ticket);
  }
 catch (  Exception e) {
    _handleException(ticket.getTicketID() + "String_Node_Str" + e.getMessage(),e);
  }
}

Fixed version (ground truth):
/** 
 * Shut down the thread associated with the user's ticket.
 * @param ticket  Ticket reference to the simulation request.
 * @exception IllegalActionException If the server was unable to destroy the simulation thread.
 */
public void close(Ticket ticket) throws IllegalActionException {
  try {
    if (ticket == null) {
      throw new IllegalStateException("String_Node_Str" + null);
    }
    if (!_requests.containsKey(ticket)) {
      throw new IllegalStateException("String_Node_Str" + ticket.getTicketID());
    }
    _requests.get(ticket).getManager().finish();
    _requests.remove(ticket);
  }
 catch (  Exception e) {
    _handleException((ticket != null ? ticket.getTicketID() : null) + "String_Node_Str" + e.getMessage(),e);
  }
}
Program: 73335
Project: 73335
Buggy source:
/** 
 * Open a model with the provided model URL and wait for the user to request the execution of the simulation.
 * @param url  The path to the model file
 * @exception IllegalActionException  If the model fails to load from the provided URL.
 * @return The user's reference to the simulation task
 */
public RemoteModelResponse open(String url) throws IllegalActionException {
  Ticket ticket=null;
  try {
    ticket=Ticket.generateTicket(url);
    while (_requests.contains(ticket)) {
      ticket=Ticket.generateTicket(url);
    }
    SimulationTask simulationTask=new SimulationTask(ticket);
    RemoteModel clientModel=new RemoteModel(null,null,RemoteModelType.CLIENT);
    clientModel.loadModel(new URL(url));
    RemoteModelResponse response=new RemoteModelResponse();
    response.setTicket(ticket);
    response.setModelTypes(clientModel.getResolvedTypes());
    response.setModelXML(clientModel.getTopLevelActor().exportMoML());
    _requests.put(ticket,simulationTask);
    return response;
  }
 catch (  Exception e) {
    _handleException(ticket.getTicketID() + "String_Node_Str" + e.getMessage(),e);
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Open a model with the provided model URL and wait for the user to request the execution of the simulation.
 * @param url  The path to the model file
 * @exception IllegalActionException  If the model fails to load from the provided URL.
 * @return The user's reference to the simulation task
 */
public RemoteModelResponse open(String url) throws IllegalActionException {
  Ticket ticket=null;
  try {
    ticket=Ticket.generateTicket(url);
    while (_requests.contains(ticket)) {
      ticket=Ticket.generateTicket(url);
    }
    SimulationTask simulationTask=new SimulationTask(ticket);
    RemoteModel clientModel=new RemoteModel(null,null,RemoteModelType.CLIENT);
    clientModel.loadModel(new URL(url));
    RemoteModelResponse response=new RemoteModelResponse();
    response.setTicket(ticket);
    response.setModelTypes(clientModel.getResolvedTypes());
    response.setModelXML(clientModel.getTopLevelActor().exportMoML());
    _requests.put(ticket,simulationTask);
    return response;
  }
 catch (  Exception e) {
    _handleException((ticket != null ? ticket.getTicketID() : null) + "String_Node_Str" + e.getMessage(),e);
  }
  return null;
}
Program: 73336
Project: 73336
Buggy source:
@Override public void getToken(Token token){
  if (counter < 10) {
    assertEquals(((IntToken)token).intValue() / 2,counter);
    counter++;
  }
 else {
    isWaiting=false;
  }
}

Fixed version (ground truth):
public void getToken(Token token){
  if (counter < 10) {
    assertEquals(((IntToken)token).intValue() / 2,counter);
    counter++;
  }
 else {
    isWaiting=false;
  }
}
Program: 73338
Project: 73338
Buggy source:
/** 
 * Set the token publisher that would be used to send AttributeChange tokens.
 * @param tokenPublisher the token publisher used to send attribute change messages.
 * @see #getTokenPublisher()
 */
public void setTokenPublisher(TokenPublisher tokenPublisher){
  tokenPublisher=tokenPublisher;
}

Fixed version (ground truth):
/** 
 * Set the token publisher that would be used to send AttributeChange tokens.
 * @param tokenPublisher the token publisher used to send attribute change messages.
 * @see #getTokenPublisher()
 */
public void setTokenPublisher(TokenPublisher tokenPublisher){
  _tokenPublisher=tokenPublisher;
}
Program: 73339
Project: 73339
Buggy source:
/** 
 * Return TokenPublisher that would be used to publish AttributeChange tokens produced by this actor on value change.
 * @return TokenPublisher the token publisher
 * @see #setTokenPublisher(TokenPublisher)
 */
public TokenPublisher getTokenPublisher(){
  return tokenPublisher;
}

Fixed version (ground truth):
/** 
 * Return TokenPublisher that would be used to publish AttributeChange tokens produced by this actor on value change.
 * @return TokenPublisher the token publisher
 * @see #setTokenPublisher(TokenPublisher)
 */
public TokenPublisher getTokenPublisher(){
  return _tokenPublisher;
}
Program: 73340
Project: 73340
Buggy source:
/** 
 * Open a model with the provided model URL and wait for the user to request the execution of the simulation.
 * @param url The path to the model file
 * @exception IllegalActionException If the model fails to loadfrom the provided URL.
 * @return The user's reference to the simulation task
 */
public Ticket open(String url) throws IllegalActionException {
  Ticket ticket=null;
  try {
    ticket=Ticket.generateTicket(url);
    while (_requests.contains(ticket)) {
      ticket=Ticket.generateTicket(url);
    }
    _requests.put(ticket,new SimulationTask(ticket));
  }
 catch (  Exception e) {
    _handleException(ticket.getTicketID() + "String_Node_Str" + e.getMessage(),e);
  }
  return ticket;
}

Fixed version (ground truth):
/** 
 * Open a model with the provided model URL and wait for the user to request the execution of the simulation.
 * @param url The path to the model file
 * @exception IllegalActionException If the model fails to loadfrom the provided URL.
 * @return The user's reference to the simulation task
 */
public RemoteModelResponse open(String url) throws IllegalActionException {
  Ticket ticket=null;
  try {
    ticket=Ticket.generateTicket(url);
    while (_requests.contains(ticket)) {
      ticket=Ticket.generateTicket(url);
    }
    SimulationTask simulationTask=new SimulationTask(ticket);
    RemoteModel clientModel=new RemoteModel(null,null,RemoteModelType.CLIENT);
    clientModel.loadModel(new URL(url));
    RemoteModelResponse response=new RemoteModelResponse();
    response.setTicket(ticket);
    response.setPortTypes(clientModel.getResolvedTypes());
    response.setModelXML(clientModel.getTopLevelActor().exportMoML());
    _requests.put(ticket,simulationTask);
    return response;
  }
 catch (  Exception e) {
    _handleException(ticket.getTicketID() + "String_Node_Str" + e.getMessage(),e);
  }
  return null;
}
Program: 73341
Project: 73341
Buggy source:
/** 
 * Create an instance of the simulation task to be run by the Ptolemy server application.
 * @param ticket Reference to the simulation request.
 * @exception Exception If the simulation encounters a problem settingthe director or getting workspace access.
 */
public SimulationTask(Ticket ticket) throws Exception {
  _owner=PtolemyServer.getInstance();
  _ticket=ticket;
  _remoteModel=new RemoteModel(_ticket.getTicketID() + "String_Node_Str",_ticket.getTicketID() + "String_Node_Str",RemoteModelType.SERVER);
  IMqttClient mqttClient=MqttClient.createMqttClient("String_Node_Str" + Integer.toString(_owner.getBrokerPort()),null);
  mqttClient.connect(_ticket.getTicketID(),true,(short)10);
  if (mqttClient != null) {
    _remoteModel.setMqttClient(mqttClient);
  }
  _remoteModel.loadModel(new URL(_ticket.getUrl()));
}

Fixed version (ground truth):
/** 
 * Create an instance of the simulation task to be run by the Ptolemy server application.
 * @param ticket Reference to the simulation request.
 * @exception Exception If the simulation encounters a problem settingthe director or getting workspace access.
 */
public SimulationTask(Ticket ticket) throws Exception {
  _owner=PtolemyServer.getInstance();
  _ticket=ticket;
  _remoteModel=new RemoteModel(_ticket.getTicketID() + "String_Node_Str",_ticket.getTicketID() + "String_Node_Str",RemoteModelType.SERVER);
  IMqttClient mqttClient=MqttClient.createMqttClient("String_Node_Str" + Integer.toString(_owner.getBrokerPort()),null);
  mqttClient.connect(_ticket.getTicketID(),true,(short)10);
  if (mqttClient != null) {
    _remoteModel.setMqttClient(mqttClient);
  }
  _remoteModel.loadModel(new URL(_ticket.getUrl()));
  _remoteModel.setUpInfrastructure();
}