nus-yam/ex-repair huggingface dataset:
Program: 75210
Project: 75210
Buggy source:
/** 
 * Get the input ports on which the given output port is dependent.
 * @param outputPort The given output port.
 * @return A set of input ports on which the output port is dependent.The elements of the set are all instances of IOPort.
 */
public Set getInputPortsDependentOn(IOPort outputPort){
  _validate();
  if (!outputPort.getContainer().equals(_container)) {
    throw new InternalErrorException("String_Node_Str" + outputPort.getName() + "String_Node_Str"+ "String_Node_Str"+ _container.getName());
  }
  Collection backwardReachableInputs=_dependencyGraph.backwardReachableNodes(_dependencyGraph.node(outputPort));
  Set dependentInputPorts=new HashSet();
  Iterator inputs=backwardReachableInputs.iterator();
  while (inputs.hasNext()) {
    Node node=(Node)inputs.next();
    dependentInputPorts.add(node.getWeight());
  }
  return dependentInputPorts;
}

Fixed version (ground truth):
/** 
 * Get the input ports on which the given output port is dependent.
 * @param outputPort The given output port.
 * @return A set of input ports on which the output port is dependent.The elements of the set are all instances of IOPort.
 */
public Set getInputPortsDependentOn(IOPort outputPort){
  _validate();
  if (!outputPort.getContainer().equals(getContainer())) {
    throw new InternalErrorException("String_Node_Str" + outputPort.getName() + "String_Node_Str"+ "String_Node_Str"+ getContainer().getName());
  }
  Collection backwardReachableInputs=_dependencyGraph.backwardReachableNodes(_dependencyGraph.node(outputPort));
  Set dependentInputPorts=new HashSet();
  Iterator inputs=backwardReachableInputs.iterator();
  while (inputs.hasNext()) {
    Node node=(Node)inputs.next();
    dependentInputPorts.add(node.getWeight());
  }
  return dependentInputPorts;
}
Program: 75211
Project: 75211
Buggy source:
/** 
 * Construct a FunctionDependency object for the given actor.
 * @param container The container.
 * @param name The name of this attribute.
 * @exception IllegalActionException If the name has a period in it, orthe attribute is not compatible with the specified container.
 * @exception NameDuplicationException If the container already containsan entity with the specified name.
 */
public FunctionDependency(Entity container,String name) throws IllegalActionException, NameDuplicationException {
  super(container,name);
  setPersistent(false);
  _container=container;
}

Fixed version (ground truth):
/** 
 * Construct a FunctionDependency object for the given actor.
 * @param container The container.
 * @param name The name of this attribute.
 * @exception IllegalActionException If the name has a period in it, orthe attribute is not compatible with the specified container.
 * @exception NameDuplicationException If the container already containsan entity with the specified name.
 */
public FunctionDependency(Entity container,String name) throws IllegalActionException, NameDuplicationException {
  super(container,name);
  setPersistent(false);
}
Program: 75212
Project: 75212
Buggy source:
/** 
 * Construct a complete dependency graph with all the ports of the associated actor as nodes and edges going from  each input port node to each output port node. This is provided as a convenience for subclasses that override _constructDependencyGraph() to build a starting point.
 * @return A complete dependency graph. 
 */
protected final DirectedGraph _constructConnectedDependencyGraph(){
  DirectedGraph dependencyGraph=_constructDisconnectedDependencyGraph();
  Iterator inputs=((Actor)_container).inputPortList().listIterator();
  while (inputs.hasNext()) {
    IOPort inputPort=(IOPort)inputs.next();
    Iterator outputs=((Actor)_container).outputPortList().listIterator();
    while (outputs.hasNext()) {
      dependencyGraph.addEdge(inputPort,outputs.next());
    }
  }
  return dependencyGraph;
}

Fixed version (ground truth):
/** 
 * Construct a complete dependency graph with all the ports of the associated actor as nodes and edges going from  each input port node to each output port node. This is provided as a convenience for subclasses that override _constructDependencyGraph() to build a starting point.
 * @return A complete dependency graph. 
 */
protected final DirectedGraph _constructConnectedDependencyGraph(){
  DirectedGraph dependencyGraph=_constructDisconnectedDependencyGraph();
  Iterator inputs=((Actor)getContainer()).inputPortList().listIterator();
  while (inputs.hasNext()) {
    IOPort inputPort=(IOPort)inputs.next();
    Iterator outputs=((Actor)getContainer()).outputPortList().listIterator();
    while (outputs.hasNext()) {
      dependencyGraph.addEdge(inputPort,outputs.next());
    }
  }
  return dependencyGraph;
}
Program: 75213
Project: 75213
Buggy source:
/** 
 * Get the output ports that depend on the given input port.
 * @param inputPort The given input port.
 * @return A set of output ports that depend on the input port.The elements of the set are all instances of IOPort.
 */
public Set getDependentOutputPorts(IOPort inputPort){
  _validate();
  if (!inputPort.getContainer().equals(_container)) {
    throw new InternalErrorException("String_Node_Str" + inputPort.getName() + "String_Node_Str"+ "String_Node_Str"+ _container.getName());
  }
  Collection reachableOutputs=_dependencyGraph.reachableNodes(_dependencyGraph.node(inputPort));
  Set dependentOutputPorts=new HashSet();
  Iterator outputs=reachableOutputs.iterator();
  while (outputs.hasNext()) {
    Node node=(Node)outputs.next();
    dependentOutputPorts.add(node.getWeight());
  }
  return dependentOutputPorts;
}

Fixed version (ground truth):
/** 
 * Get the output ports that depend on the given input port.
 * @param inputPort The given input port.
 * @return A set of output ports that depend on the input port.The elements of the set are all instances of IOPort.
 */
public Set getDependentOutputPorts(IOPort inputPort){
  _validate();
  if (!inputPort.getContainer().equals(getContainer())) {
    throw new InternalErrorException("String_Node_Str" + inputPort.getName() + "String_Node_Str"+ "String_Node_Str"+ getContainer().getName());
  }
  Collection reachableOutputs=_dependencyGraph.reachableNodes(_dependencyGraph.node(inputPort));
  Set dependentOutputPorts=new HashSet();
  Iterator outputs=reachableOutputs.iterator();
  while (outputs.hasNext()) {
    Node node=(Node)outputs.next();
    dependentOutputPorts.add(node.getWeight());
  }
  return dependentOutputPorts;
}
Program: 75214
Project: 75214
Buggy source:
/** 
 * Update the FunctionDependency object. If it has not been previously constructed, then construct it. If the topology has been changed since it was last constructed (as indicated by the getVersion() method of the workspace of the associated actor), then reconstruct it. Otherwise, do nothing.
 * @see ptolemy.kernel.util.Workspace#getVersion()
 */
protected final void _validate(){
  Workspace workspace=_container.workspace();
  long workspaceVersion=workspace.getVersion();
  if (_functionDependencyVersion != workspaceVersion) {
    try {
      workspace.getReadAccess();
      _constructDependencyGraph();
      _functionDependencyVersion=workspaceVersion;
    }
  finally {
      workspace.doneReading();
    }
  }
}

Fixed version (ground truth):
/** 
 * Update the FunctionDependency object. If it has not been previously constructed, then construct it. If the topology has been changed since it was last constructed (as indicated by the getVersion() method of the workspace of the associated actor), then reconstruct it. Otherwise, do nothing.
 * @see ptolemy.kernel.util.Workspace#getVersion()
 */
protected final void _validate(){
  Workspace workspace=getContainer().workspace();
  long workspaceVersion=workspace.getVersion();
  if (_functionDependencyVersion != workspaceVersion) {
    try {
      workspace.getReadAccess();
      _constructDependencyGraph();
      _functionDependencyVersion=workspaceVersion;
    }
  finally {
      workspace.doneReading();
    }
  }
}
Program: 75215
Project: 75215
Buggy source:
/** 
 * Construct and return a dependency graph containing all the ports of the associated actor as nodes and no edges. This is provided as a convenience for subclasses that override _constructDependencyGraph() to build a starting point.
 * @return A dependency graph with nodes for ports but no edges.
 */
protected final DirectedGraph _constructDisconnectedDependencyGraph(){
  DirectedGraph dependencyGraph=new DirectedGraph();
  Iterator inputs=((Actor)_container).inputPortList().listIterator();
  while (inputs.hasNext()) {
    IOPort input=(IOPort)inputs.next();
    dependencyGraph.addNodeWeight(input);
  }
  Iterator outputs=((Actor)_container).outputPortList().listIterator();
  while (outputs.hasNext()) {
    IOPort output=(IOPort)outputs.next();
    dependencyGraph.addNodeWeight(output);
  }
  return dependencyGraph;
}

Fixed version (ground truth):
/** 
 * Construct and return a dependency graph containing all the ports of the associated actor as nodes and no edges. This is provided as a convenience for subclasses that override _constructDependencyGraph() to build a starting point.
 * @return A dependency graph with nodes for ports but no edges.
 */
protected final DirectedGraph _constructDisconnectedDependencyGraph(){
  DirectedGraph dependencyGraph=new DirectedGraph();
  Iterator inputs=((Actor)getContainer()).inputPortList().listIterator();
  while (inputs.hasNext()) {
    IOPort input=(IOPort)inputs.next();
    dependencyGraph.addNodeWeight(input);
  }
  Iterator outputs=((Actor)getContainer()).outputPortList().listIterator();
  while (outputs.hasNext()) {
    IOPort output=(IOPort)outputs.next();
    dependencyGraph.addNodeWeight(output);
  }
  return dependencyGraph;
}
Program: 75217
Project: 75217
Buggy source:
/** 
 * Given a collection of nodes, get the connected subgraph.
 * @return A 
 * @param nodes
 * @param graph
 */
public void connectedSubGraph(Collection nodes,DirectedGraph graph){
  Collection dummyCollection=new LinkedList();
  Iterator nodesIterator=nodes.iterator();
  while (nodesIterator.hasNext()) {
    Node node=(Node)nodesIterator.next();
    _connectedSubGraph(node,graph,dummyCollection);
  }
}

Fixed version (ground truth):
/** 
 * Given a collection of nodes, get the connected subgraph.
 * @return A 
 * @param nodes
 * @param graph
 */
public DirectedGraph connectedSubGraph(Collection nodes){
  DirectedGraph graph=new DirectedGraph();
  Collection dummyCollection=new LinkedList();
  Iterator nodesIterator=nodes.iterator();
  while (nodesIterator.hasNext()) {
    Node node=(Node)nodesIterator.next();
    _connectedSubGraph(node,graph,dummyCollection);
  }
  return graph;
}
Program: 75218
Project: 75218
Buggy source:
/** 
 * Close the file. If it has not been opened using openForReading() or openForWriting(), then do nothing.  Also, if the file is System.in or System.out, then do not close it (it does not make sense to close these files).
 * @exception IllegalActionException If the file or URL cannot beclosed.
 */
public void close() throws IllegalActionException {
  if (_reader != null) {
    if (_reader != _stdIn) {
      try {
        _reader.close();
      }
 catch (      IOException ex) {
      }
    }
  }
  if (_writer != null) {
    try {
      _writer.flush();
      if (_writer != _stdOut) {
        _writer.close();
      }
    }
 catch (    IOException ex) {
    }
  }
}

Fixed version (ground truth):
/** 
 * Close the file. If it has not been opened using openForReading() or openForWriting(), then do nothing.  Also, if the file is System.in or System.out, then do not close it (it does not make sense to close these files).
 * @exception IllegalActionException If the file or URL cannot beclosed.
 */
public void close() throws IllegalActionException {
  if (_reader != null) {
    if (_reader != FileUtilities.STD_IN) {
      try {
        _reader.close();
      }
 catch (      IOException ex) {
      }
    }
  }
  if (_writer != null) {
    try {
      _writer.flush();
      if (_writer != FileUtilities.STD_OUT) {
        _writer.close();
      }
    }
 catch (    IOException ex) {
    }
  }
}
Program: 75219
Project: 75219
Buggy source:
/** 
 * Close the file. If it has not been opened using openForReading() or openForWriting(), then do nothing.  Also, if the file is System.in or System.out, then do not close it (it does not make sense to close these files).
 * @exception IllegalActionException If the file or URL cannot beclosed.
 */
public void close() throws IllegalActionException {
  if (_reader != null) {
    if (_reader != _stdIn) {
      try {
        _reader.close();
      }
 catch (      IOException ex) {
      }
    }
  }
  if (_writer != null) {
    try {
      _writer.flush();
      if (_writer != _stdOut) {
        _writer.close();
      }
    }
 catch (    IOException ex) {
    }
  }
}

Fixed version (ground truth):
/** 
 * Close the file. If it has not been opened using openForReading() or openForWriting(), then do nothing.  Also, if the file is System.in or System.out, then do not close it (it does not make sense to close these files).
 * @exception IllegalActionException If the file or URL cannot beclosed.
 */
public void close() throws IllegalActionException {
  if (_reader != null) {
    if (_reader != FileUtilities.STD_IN) {
      try {
        _reader.close();
      }
 catch (      IOException ex) {
      }
    }
  }
  if (_writer != null) {
    try {
      _writer.flush();
      if (_writer != FileUtilities.STD_OUT) {
        _writer.close();
      }
    }
 catch (    IOException ex) {
    }
  }
}
Program: 75220
Project: 75220
Buggy source:
/** 
 * Return a list of disconnected subgraphs of this subgraph. 
 */
public LinkedList subgraphs(){
  LinkedList subgraphList=new LinkedList();
  LinkedList remainingNodes=(LinkedList)nodes();
  while (!remainingNodes.isEmpty()) {
    DirectedGraph subgraph=new DirectedGraph();
    Node node=(Node)remainingNodes.getFirst();
    _connectedSubGraph(node,subgraph,remainingNodes);
    subgraphList.add(subgraph);
  }
  return subgraphList;
}

Fixed version (ground truth):
/** 
 * Return a list of disconnected subgraphs of this subgraph. 
 */
public LinkedList subgraphs(){
  LinkedList subgraphList=new LinkedList();
  LinkedList remainingNodes=new LinkedList(nodes());
  while (!remainingNodes.isEmpty()) {
    DirectedGraph subgraph=new DirectedGraph();
    Node node=(Node)remainingNodes.remove(0);
    _connectedSubGraph(node,subgraph,remainingNodes);
    subgraphList.add(subgraph);
  }
  return subgraphList;
}
Program: 75221
Project: 75221
Buggy source:
/** 
 * Given a node, get all the edges and nodes that are connected to it directly and/or indirectly. Add them in the given graph. Remove the nodes from the remainning nodes. FIXME: Hidden edges not considered.
 * @param node The given node.
 * @param graph The given graph.
 * @param remainingNodes Set of nodes that haven't been reached.
 */
protected void _connectedSubGraph(Node node,DirectedGraph graph,Collection remainingNodes){
  if (!graph.containsNode(node)) {
    graph.addNode(node);
    remainingNodes.remove(node);
  }
  Iterator inputEdges=inputEdges(node).iterator();
  while (inputEdges.hasNext()) {
    Edge inputEdge=(Edge)inputEdges.next();
    if (!graph.containsEdge(inputEdge)) {
      Node sourceNode=inputEdge.source();
      if (!graph.containsNode(sourceNode)) {
        graph.addNode(sourceNode);
        _connectedSubGraph(sourceNode,graph,remainingNodes);
        remainingNodes.remove(sourceNode);
      }
      if (!graph.containsEdge(inputEdge)) {
        graph.addEdge(sourceNode,node);
      }
    }
  }
  Iterator outputEdges=outputEdges(node).iterator();
  while (outputEdges.hasNext()) {
    Edge outputEdge=(Edge)outputEdges.next();
    if (!graph.containsEdge(outputEdge)) {
      Node sinkNode=outputEdge.source();
      if (!graph.containsNode(sinkNode)) {
        graph.addNode(sinkNode);
        _connectedSubGraph(sinkNode,graph,remainingNodes);
        remainingNodes.remove(sinkNode);
      }
      if (!graph.containsEdge(outputEdge)) {
        graph.addEdge(node,sinkNode);
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Given a node, get all the edges and nodes that are connected to it directly and/or indirectly. Add them in the given graph. Remove the nodes from the remainning nodes. FIXME: Hidden edges not considered.
 * @param node The given node.
 * @param graph The given graph.
 * @param remainingNodes Set of nodes that haven't been reached.
 */
protected void _connectedSubGraph(Node node,DirectedGraph graph,Collection remainingNodes){
  if (!graph.containsNode(node)) {
    graph.addNode(node);
    remainingNodes.remove(node);
  }
  Iterator inputEdges=inputEdges(node).iterator();
  while (inputEdges.hasNext()) {
    Edge inputEdge=(Edge)inputEdges.next();
    if (!graph.containsEdge(inputEdge)) {
      Node sourceNode=inputEdge.source();
      if (!graph.containsNode(sourceNode)) {
        graph.addNode(sourceNode);
        _connectedSubGraph(sourceNode,graph,remainingNodes);
        remainingNodes.remove(sourceNode);
      }
      if (!graph.containsEdge(inputEdge)) {
        graph.addEdge(sourceNode,node);
      }
    }
  }
  Iterator outputEdges=outputEdges(node).iterator();
  while (outputEdges.hasNext()) {
    Edge outputEdge=(Edge)outputEdges.next();
    if (!graph.containsEdge(outputEdge)) {
      Node sinkNode=outputEdge.sink();
      if (!graph.containsNode(sinkNode)) {
        graph.addNode(sinkNode);
        _connectedSubGraph(sinkNode,graph,remainingNodes);
        remainingNodes.remove(sinkNode);
      }
      if (!graph.containsEdge(outputEdge)) {
        graph.addEdge(node,sinkNode);
      }
    }
  }
}
Program: 75222
Project: 75222
Buggy source:
/** 
 * If there are delayed inputs that are not processed and the timer  is not busy. Begin processing the earliest input and schedule  a future firing to produce it.
 * @exception IllegalActionException If there is no director or can notschedule future firings to handle delayed input events.
 */
public boolean postfire() throws IllegalActionException {
  Time currentTime=getDirector().getModelTime();
  if (_currentOutput != null) {
    _delayedTokens.remove(currentTime);
  }
  if (_delayedInputTokensList.size() != 0 && _delayedTokens.isEmpty()) {
    DoubleToken delayToken=(DoubleToken)_delayedInputTokensList.removeFirst();
    double delay=delayToken.doubleValue();
    _nextTimeFree=currentTime.add(delay);
    _delayedTokens.put(_nextTimeFree,delayToken);
    getDirector().fireAt(this,_nextTimeFree);
  }
  return !_stopRequested;
}

Fixed version (ground truth):
/** 
 * If there are delayed inputs that are not processed and the timer  is not busy. Begin processing the earliest input and schedule  a future firing to produce it.
 * @exception IllegalActionException If there is no director or can notschedule future firings to handle delayed input events.
 */
public boolean postfire() throws IllegalActionException {
  Time currentTime=getDirector().getModelTime();
  if (_currentOutput != null) {
    _delayedOutputTokens.take();
  }
  if (_delayedInputTokensList.size() != 0 && _delayedOutputTokens.isEmpty()) {
    DoubleToken delayToken=(DoubleToken)_delayedInputTokensList.removeFirst();
    double delay=delayToken.doubleValue();
    _nextTimeFree=currentTime.add(delay);
    _delayedOutputTokens.put(new TimedEvent(_nextTimeFree,delayToken));
    getDirector().fireAt(this,_nextTimeFree);
  }
  return !_stopRequested;
}
Program: 75224
Project: 75224
Buggy source:
/** 
 * If there are delayed input events that are not processed and the server is ready, begin process the earliest input event and schedule  future firings to produce them.
 * @exception IllegalActionException If there is no director or can notschedule future firings to handle delayed input events.
 */
public boolean postfire() throws IllegalActionException {
  Time currentTime=getDirector().getModelTime();
  if (_currentOutput != null) {
    _delayedTokens.remove(currentTime);
  }
  if (_delayedInputTokensList.size() != 0 && _delayedTokens.isEmpty()) {
    _nextTimeFree=currentTime.add(_delay);
    _delayedTokens.put(_nextTimeFree,_delayedInputTokensList.removeFirst());
    getDirector().fireAt(this,_nextTimeFree);
  }
  return !_stopRequested;
}

Fixed version (ground truth):
/** 
 * If there are delayed input events that are not processed and the server is ready, begin process the earliest input event and schedule  future firings to produce them.
 * @exception IllegalActionException If there is no director or can notschedule future firings to handle delayed input events.
 * @return True if the stop is not requested.
 */
public boolean postfire() throws IllegalActionException {
  Time currentTime=getDirector().getModelTime();
  if (_currentOutput != null) {
    _delayedOutputTokens.take();
  }
  if (_delayedInputTokensList.size() != 0 && _delayedOutputTokens.isEmpty()) {
    _nextTimeFree=currentTime.add(_delay);
    _delayedOutputTokens.put(new TimedEvent(_nextTimeFree,_delayedInputTokensList.removeFirst()));
    getDirector().fireAt(this,_nextTimeFree);
  }
  return !_stopRequested;
}
Program: 75225
Project: 75225
Buggy source:
/** 
 * Read the available input token. If the server is not busy,  begin servicing it. If the delay is 0, output is immediately availabe. Otherwise, the output available time is delayed by the amount of the  <i>newServiceTime></i> parameter. If the server is busy, check whether the current service finishes. If so, generate output. Otherwise, do nothing. 
 * @exception IllegalActionException If can not update the serviceTimeparameter, read inputs, or send outputs.
 */
public void fire() throws IllegalActionException {
  delay.update();
  _delay=((DoubleToken)delay.getToken()).doubleValue();
  Time currentTime=getDirector().getModelTime();
  if (input.hasToken(0)) {
    _currentInput=input.get(0);
    _delayedInputTokensList.addLast(_currentInput);
  }
 else {
    _currentInput=null;
  }
  if (_delayedTokens.size() > 0) {
    if (currentTime.compareTo(_nextTimeFree) == 0) {
      _currentOutput=(Token)_delayedTokens.get(currentTime);
      if (_currentOutput == null) {
        throw new InternalErrorException("String_Node_Str" + "String_Node_Str");
      }
      output.send(0,_currentOutput);
    }
 else {
    }
  }
 else   if (_delay == 0 && _delayedInputTokensList.size() > 0) {
    output.send(0,(Token)_delayedInputTokensList.removeFirst());
  }
}

Fixed version (ground truth):
/** 
 * Read the available input token. If the server is not busy,  begin servicing it. If the delay is 0, output is immediately availabe. Otherwise, the output available time is delayed by the amount of the  <i>newServiceTime></i> parameter. If the server is busy, check whether the current service finishes. If so, generate output. Otherwise, do nothing. 
 * @exception IllegalActionException If can not update the serviceTimeparameter, read inputs, or send outputs.
 */
public void fire() throws IllegalActionException {
  delay.update();
  _delay=((DoubleToken)delay.getToken()).doubleValue();
  Time currentTime=getDirector().getModelTime();
  if (input.hasToken(0)) {
    _currentInput=input.get(0);
    _delayedInputTokensList.addLast(_currentInput);
  }
 else {
    _currentInput=null;
  }
  _currentOutput=null;
  if (_delayedOutputTokens.size() > 0) {
    if (currentTime.compareTo(_nextTimeFree) == 0) {
      TimedEvent earliestEvent=(TimedEvent)_delayedOutputTokens.get();
      Time eventTime=earliestEvent.timeStamp;
      if (!eventTime.equals(currentTime)) {
        throw new InternalErrorException("String_Node_Str" + "String_Node_Str");
      }
      _currentOutput=(Token)earliestEvent.contents;
      output.send(0,_currentOutput);
    }
 else {
    }
  }
 else   if (_delay == 0 && _delayedInputTokensList.size() > 0) {
    output.send(0,(Token)_delayedInputTokensList.removeFirst());
  }
}
Program: 75226
Project: 75226
Buggy source:
/** 
 * If the current input is scheduled to produce in a future time, schedule a refiring of this actor at that time.
 * @exception IllegalActionException If scheduling to refire cannotbe performed or the superclass throws it.
 */
public boolean postfire() throws IllegalActionException {
  Time currentTime=getDirector().getModelTime();
  Time delayToTime=currentTime.add(_delay);
  if (_delayedTokens.size() > 0 && _currentOutput != null) {
    _delayedTokens.remove(currentTime);
  }
  if (_currentInput != null) {
    _delayedTokens.put(delayToTime,_currentInput);
    getDirector().fireAt(this,delayToTime);
  }
  return super.postfire();
}

Fixed version (ground truth):
/** 
 * If the current input is scheduled to produce in a future time, schedule a refiring of this actor at that time.
 * @exception IllegalActionException If scheduling to refire cannotbe performed or the superclass throws it.
 */
public boolean postfire() throws IllegalActionException {
  Time currentTime=getDirector().getModelTime();
  Time delayToTime=currentTime.add(_delay);
  if (_delayedOutputTokens.size() > 0) {
    if (_currentOutput != null) {
      _delayedOutputTokens.take();
    }
  }
  if (_delayedOutputTokens.size() > 0) {
    TimedEvent earliestEvent=(TimedEvent)_delayedOutputTokens.get();
    Time eventTime=earliestEvent.timeStamp;
    if (eventTime.equals(currentTime)) {
      getDirector().fireAt(this,currentTime);
    }
  }
  if (_currentInput != null) {
    _delayedOutputTokens.put(new TimedEvent(delayToTime,_currentInput));
    getDirector().fireAt(this,delayToTime);
  }
  return super.postfire();
}
Program: 75227
Project: 75227
Buggy source:
/** 
 * Read one token from the input and send one output that is scheduled to produce at the current time. 
 * @exception IllegalActionException If there is no director, or theinput can not be read, or the output can not be sent.
 */
public void fire() throws IllegalActionException {
  if (input.hasToken(0)) {
    _currentInput=input.get(0);
  }
 else {
    _currentInput=null;
  }
  Time currentTime=getDirector().getModelTime();
  _currentOutput=null;
  if (_delayedTokens.size() > 0) {
    _currentOutput=(Token)_delayedTokens.get(currentTime);
    if (_currentOutput != null) {
      output.send(0,_currentOutput);
      return;
    }
 else {
    }
  }
  if (_delay == 0 && _currentInput != null) {
    output.send(0,_currentInput);
    _currentInput=null;
  }
}

Fixed version (ground truth):
/** 
 * Read one token from the input and send one output that is scheduled to produce at the current time. 
 * @exception IllegalActionException If there is no director, or theinput can not be read, or the output can not be sent.
 */
public void fire() throws IllegalActionException {
  if (input.hasToken(0)) {
    _currentInput=input.get(0);
  }
 else {
    _currentInput=null;
  }
  Time currentTime=getDirector().getModelTime();
  _currentOutput=null;
  if (_delayedOutputTokens.size() > 0) {
    TimedEvent earliestEvent=(TimedEvent)_delayedOutputTokens.get();
    Time eventTime=earliestEvent.timeStamp;
    if (eventTime.equals(currentTime)) {
      _currentOutput=(Token)earliestEvent.contents;
      output.send(0,_currentOutput);
      return;
    }
 else {
    }
  }
  if (_delay == 0 && _currentInput != null) {
    output.send(0,_currentInput);
    _currentInput=null;
  }
}
Program: 75228
Project: 75228
Buggy source:
/** 
 * Initialize the states of this actor.
 * @exception IllegalActionException If a derived class throws it.
 */
public void initialize() throws IllegalActionException {
  super.initialize();
  _currentInput=null;
  _currentOutput=null;
  _delayedTokens=new HashMap();
}

Fixed version (ground truth):
/** 
 * Initialize the states of this actor.
 * @exception IllegalActionException If a derived class throws it.
 */
public void initialize() throws IllegalActionException {
  super.initialize();
  _currentInput=null;
  _currentOutput=null;
  _delayedOutputTokens=new CalendarQueue(new TimedEvent.TimeComparator(this.getDirector()));
}
Program: 75229
Project: 75229
Buggy source:
/** 
 * Update the internal states of this actor. If the current input  is not processed in the fire method, schedule a refiring of this actor to produce an output in a future time,  (the current model time + delay specified by the input value).  
 * @exception IllegalActionException If scheduling to refire cannotbe performed or the superclass throws it.
 */
public boolean postfire() throws IllegalActionException {
  Time currentTime=getDirector().getModelTime();
  Time delayToTime=currentTime.add(_delay);
  if (_delayedTokens.size() > 0 && _currentOutput != null) {
    _delayedTokens.remove(currentTime);
  }
  if (_currentInput != null) {
    _delayedTokens.put(delayToTime,_currentInput);
    getDirector().fireAt(this,delayToTime);
  }
  return super.postfire();
}

Fixed version (ground truth):
/** 
 * Update the internal states of this actor. If the current input  is not processed in the fire method, schedule a refiring of this actor to produce an output in a future time,  (the current model time + delay specified by the input value).  
 * @exception IllegalActionException If scheduling to refire cannotbe performed or the superclass throws it.
 */
public boolean postfire() throws IllegalActionException {
  Time currentTime=getDirector().getModelTime();
  Time delayToTime=currentTime.add(_delay);
  if (_delayedOutputTokens.size() > 0) {
    if (_currentOutput != null) {
      _delayedOutputTokens.take();
    }
  }
  if (_delayedOutputTokens.size() > 0) {
    TimedEvent earliestEvent=(TimedEvent)_delayedOutputTokens.get();
    Time eventTime=earliestEvent.timeStamp;
    if (eventTime.equals(currentTime)) {
      getDirector().fireAt(this,currentTime);
    }
  }
  if (_currentInput != null) {
    _delayedOutputTokens.put(new TimedEvent(delayToTime,_currentInput));
    getDirector().fireAt(this,delayToTime);
  }
  return super.postfire();
}
Program: 75230
Project: 75230
Buggy source:
/** 
 * Read one token from the input. If the value of the input is bigger than 0.0, save the input to be processed in the postfire method. Otherwise,  check whether there is any output scheduled to be produced at the  current time. If there is one, send out that output and save the  current input for future processing in the postfire method. If there  is no output to produce and the input value is 0.0, send an output  immediately and reset the current input to null, indicating no further  processing of the current input is necessary.
 * @exception IllegalActionException If there is no director, or can notsend or get tokens from ports.
 */
public void fire() throws IllegalActionException {
  _delay=-1.0;
  if (input.hasToken(0)) {
    _currentInput=input.get(0);
    double delayValue=((DoubleToken)_currentInput).doubleValue();
    if (delayValue < 0) {
      throw new IllegalActionException("String_Node_Str");
    }
 else {
      _delay=delayValue;
    }
  }
 else {
    _currentInput=null;
  }
  Time currentTime=getDirector().getModelTime();
  _currentOutput=null;
  if (_delayedTokens.size() > 0) {
    _currentOutput=(Token)_delayedTokens.get(currentTime);
    if (_currentOutput != null) {
      output.send(0,value.getToken());
      return;
    }
 else {
    }
  }
  if (_delay == 0.0) {
    output.send(0,value.getToken());
    _currentInput=null;
  }
}

Fixed version (ground truth):
/** 
 * Read one token from the input. If the value of the input is bigger than 0.0, save the input to be processed in the postfire method. Otherwise,  check whether there is any output scheduled to be produced at the  current time. If there is one, send out that output and save the  current input for future processing in the postfire method. If there  is no output to produce and the input value is 0.0, send an output  immediately and reset the current input to null, indicating no further  processing of the current input is necessary.
 * @exception IllegalActionException If there is no director, or can notsend or get tokens from ports.
 */
public void fire() throws IllegalActionException {
  _delay=-1.0;
  if (input.hasToken(0)) {
    _currentInput=input.get(0);
    double delayValue=((DoubleToken)_currentInput).doubleValue();
    if (delayValue < 0) {
      throw new IllegalActionException("String_Node_Str");
    }
 else {
      _delay=delayValue;
    }
  }
 else {
    _currentInput=null;
  }
  Time currentTime=getDirector().getModelTime();
  _currentOutput=null;
  if (_delayedOutputTokens.size() > 0) {
    TimedEvent earliestEvent=(TimedEvent)_delayedOutputTokens.get();
    Time eventTime=earliestEvent.timeStamp;
    if (eventTime.equals(currentTime)) {
      _currentOutput=(Token)earliestEvent.contents;
      output.send(0,value.getToken());
      return;
    }
 else {
    }
  }
  if (_delay == 0.0) {
    output.send(0,value.getToken());
    _currentInput=null;
  }
}
Program: 75231
Project: 75231
Buggy source:
/** 
 * Initialize the internal states of this actor.
 * @exception IllegalActionException If a derived class throws it.
 */
public void initialize() throws IllegalActionException {
  super.initialize();
  _currentInput=null;
  _currentOutput=null;
  _delayedTokens=new HashMap();
}

Fixed version (ground truth):
/** 
 * Initialize the internal states of this actor.
 * @exception IllegalActionException If a derived class throws it.
 */
public void initialize() throws IllegalActionException {
  super.initialize();
  _currentInput=null;
  _currentOutput=null;
  _delayedOutputTokens=new CalendarQueue(new TimedEvent.TimeComparator(this.getDirector()));
}
Program: 75232
Project: 75232
Buggy source:
/** 
 * If there are delayed inputs that are not processed and the timer  is not busy. Begin processing the earliest input and schedule  a future firing to produce it.
 * @exception IllegalActionException If there is no director or can notschedule future firings to handle delayed input events.
 */
public boolean postfire() throws IllegalActionException {
  Time currentTime=getDirector().getModelTime();
  if (_currentOutput != null) {
    _delayedOutputTokens.take();
  }
  if (_delayedInputTokensList.size() != 0 && _delayedOutputTokens.isEmpty()) {
    DoubleToken delayToken=(DoubleToken)_delayedInputTokensList.removeFirst();
    double delay=delayToken.doubleValue();
    _nextTimeFree=currentTime.add(delay);
    _delayedOutputTokens.put(new TimedEvent(_nextTimeFree,delayToken));
    getDirector().fireAt(this,_nextTimeFree);
  }
  return !_stopRequested;
}

Fixed version (ground truth):
/** 
 * If there are delayed inputs that are not processed and the timer  is not busy. Begin processing the earliest input and schedule  a future firing to produce it.
 * @exception IllegalActionException If there is no director or can notschedule future firings to handle delayed input events.
 */
public boolean postfire() throws IllegalActionException {
  Time currentTime=getDirector().getModelTime();
  if (_currentOutput != null) {
    _delayedOutputTokens.take();
  }
  if (_delayedInputTokensList.size() != 0 && _delayedOutputTokens.isEmpty()) {
    DoubleToken delayToken=(DoubleToken)_delayedInputTokensList.removeFirst();
    double delay=delayToken.doubleValue();
    _nextTimeFree=currentTime.add(delay);
    _delayedOutputTokens.put(new TimedEvent(_nextTimeFree,value.getToken()));
    getDirector().fireAt(this,_nextTimeFree);
  }
  return !_stopRequested;
}
Program: 75233
Project: 75233
Buggy source:
/** 
 * Update the internal states of this actor. If the current input  is not processed in the fire method, schedule a refiring of this actor to produce an output in a future time,  (the current model time + delay specified by the input value).  
 * @exception IllegalActionException If scheduling to refire cannotbe performed or the superclass throws it.
 */
public boolean postfire() throws IllegalActionException {
  Time currentTime=getDirector().getModelTime();
  Time delayToTime=currentTime.add(_delay);
  if (_delayedOutputTokens.size() > 0) {
    if (_currentOutput != null) {
      _delayedOutputTokens.take();
    }
  }
  if (_delayedOutputTokens.size() > 0) {
    TimedEvent earliestEvent=(TimedEvent)_delayedOutputTokens.get();
    Time eventTime=earliestEvent.timeStamp;
    if (eventTime.equals(currentTime)) {
      getDirector().fireAt(this,currentTime);
    }
  }
  if (_currentInput != null) {
    _delayedOutputTokens.put(new TimedEvent(delayToTime,_currentInput));
    getDirector().fireAt(this,delayToTime);
  }
  return super.postfire();
}

Fixed version (ground truth):
/** 
 * Update the internal states of this actor. If the current input  is not processed in the fire method, schedule a refiring of this actor to produce an output in a future time,  (the current model time + delay specified by the input value).  
 * @exception IllegalActionException If scheduling to refire cannotbe performed or the superclass throws it.
 */
public boolean postfire() throws IllegalActionException {
  Time currentTime=getDirector().getModelTime();
  Time delayToTime=currentTime.add(_delay);
  if (_delayedOutputTokens.size() > 0) {
    if (_currentOutput != null) {
      _delayedOutputTokens.take();
    }
  }
  if (_delayedOutputTokens.size() > 0) {
    TimedEvent earliestEvent=(TimedEvent)_delayedOutputTokens.get();
    Time eventTime=earliestEvent.timeStamp;
    if (eventTime.equals(currentTime)) {
      getDirector().fireAt(this,currentTime);
    }
  }
  if (_currentInput != null) {
    _delayedOutputTokens.put(new TimedEvent(delayToTime,value.getToken()));
    getDirector().fireAt(this,delayToTime);
  }
  return super.postfire();
}
Program: 75234
Project: 75234
Buggy source:
/** 
 * If there are delayed input events that are not processed and the timer is ready, begin process the earliest input event and schedule  future firings to produce them.
 * @exception IllegalActionException If there is no director or can notschedule future firings to handle delayed input events.
 */
public boolean postfire() throws IllegalActionException {
  Time currentTime=getDirector().getModelTime();
  if (_currentOutput != null) {
    _delayedTokens.remove(currentTime);
  }
  if (_delayedInputTokensList.size() != 0 && _delayedTokens.isEmpty()) {
    DoubleToken delayToken=(DoubleToken)_delayedInputTokensList.removeFirst();
    double delay=delayToken.doubleValue();
    _nextTimeFree=currentTime.add(delay);
    _delayedTokens.put(_nextTimeFree,delayToken);
    getDirector().fireAt(this,_nextTimeFree);
  }
  return !_stopRequested;
}

Fixed version (ground truth):
/** 
 * If there are delayed input events that are not processed and the timer is ready, begin processing the earliest input event and schedule  a future firing to produce it.
 * @exception IllegalActionException If there is no director or can notschedule future firings to handle delayed input events.
 */
public boolean postfire() throws IllegalActionException {
  Time currentTime=getDirector().getModelTime();
  if (_currentOutput != null) {
    _delayedTokens.remove(currentTime);
  }
  if (_delayedInputTokensList.size() != 0 && _delayedTokens.isEmpty()) {
    DoubleToken delayToken=(DoubleToken)_delayedInputTokensList.removeFirst();
    double delay=delayToken.doubleValue();
    _nextTimeFree=currentTime.add(delay);
    _delayedTokens.put(_nextTimeFree,delayToken);
    getDirector().fireAt(this,_nextTimeFree);
  }
  return !_stopRequested;
}
Program: 75235
Project: 75235
Buggy source:
/** 
 * Clone the actor into the specified workspace. This calls the base class and then links the type of the <i>value</i> parameter to the output.
 * @param workspace The workspace for the new object.
 * @return A new actor.
 * @exception CloneNotSupportedException If a derived class hashas an attribute that cannot be cloned.
 */
public Object clone(Workspace workspace) throws CloneNotSupportedException {
  Timer newObject=(Timer)super.clone(workspace);
  newObject.output.setTypeSameAs(value);
  return newObject;
}

Fixed version (ground truth):
/** 
 * Clone the actor into the specified workspace. This calls the base class and then links the type of the <i>value</i> parameter to the output.
 * @param workspace The workspace for the new object.
 * @return A new actor.
 * @exception CloneNotSupportedException If a derived class hashas an attribute that cannot be cloned.
 */
public Object clone(Workspace workspace) throws CloneNotSupportedException {
  NonInterruptibleTimer newObject=(NonInterruptibleTimer)super.clone(workspace);
  newObject.output.setTypeSameAs(value);
  return newObject;
}
Program: 75236
Project: 75236
Buggy source:
/** 
 * Examine the non-preemptive transitions from the given state. If there is more than one transition enabled, an exception is thrown. If there is exactly one non-preemptive transition enabled, then it is chosen and the choice actions contained by transition are executed. Return the destination state. If no transition is enabled, return the current state.
 * @return The destination state, or the current state if notransition is enabled.
 */
public State chooseStateTransition(State state) throws IllegalActionException {
  FSMActor controller=getController();
  State destinationState;
  Transition transition=_chooseTransition(state.nonpreemptiveTransitionList());
  if (transition != null) {
    destinationState=transition.destinationState();
    TypedActor[] trRefinements=(transition.getRefinement());
    Actor[] actors=transition.getRefinement();
    if (actors != null) {
      for (int i=0; i < actors.length; ++i) {
        if (_stopRequested)         break;
        if (actors[i].prefire()) {
          if (_debugging) {
            _debug(getFullName(),"String_Node_Str",((ptolemy.kernel.util.NamedObj)actors[i]).getName());
          }
          actors[i].fire();
          actors[i].postfire();
        }
      }
    }
    _readOutputsFromRefinement();
    Iterator actions=transition.choiceActionList().iterator();
    while (actions.hasNext()) {
      Action action=(Action)actions.next();
      action.execute();
    }
    _readOutputsFromRefinement();
  }
 else {
    destinationState=state;
  }
  return destinationState;
}

Fixed version (ground truth):
/** 
 * Examine the non-preemptive transitions from the given state. If there is more than one transition enabled, an exception is thrown. If there is exactly one non-preemptive transition enabled, then it is chosen and the choice actions contained by transition are executed. Return the destination state. If no transition is enabled, return the current state.
 * @return The destination state, or the current state if notransition is enabled.
 */
public State chooseStateTransition(State state) throws IllegalActionException {
  FSMActor controller=getController();
  State destinationState;
  Transition transition=_chooseTransition(state.nonpreemptiveTransitionList());
  if (transition != null) {
    destinationState=transition.destinationState();
    TypedActor[] trRefinements=(transition.getRefinement());
    Actor[] actors=transition.getRefinement();
    if (actors != null) {
      for (int i=0; i < actors.length; ++i) {
        if (_stopRequested)         break;
        if (actors[i].prefire()) {
          if (_debugging) {
            _debug(getFullName(),"String_Node_Str",((ptolemy.kernel.util.NamedObj)actors[i]).getName());
          }
          actors[i].fire();
          actors[i].postfire();
        }
      }
      _readOutputsFromRefinement();
      Iterator actions=transition.choiceActionList().iterator();
      while (actions.hasNext()) {
        Action action=(Action)actions.next();
        action.execute();
      }
      _readOutputsFromRefinement();
    }
  }
 else {
    destinationState=state;
  }
  return destinationState;
}
Program: 75237
Project: 75237
Buggy source:
public void fireDynamicActors() throws IllegalActionException {
  _debug(getFullName() + "String_Node_Str");
  CTDirector dir=(CTDirector)getContainer();
  if (dir == null) {
    throw new IllegalActionException(this,"String_Node_Str");
  }
  CTScheduler scheduler=(CTScheduler)dir.getScheduler();
  if (scheduler == null) {
    throw new IllegalActionException(dir,"String_Node_Str");
  }
  CTSchedule schedule=(CTSchedule)scheduler.getSchedule();
  Iterator actors=schedule.get(CTSchedule.DYNAMIC_ACTORS).actorIterator();
  while (actors.hasNext()) {
    CTDynamicActor next=(CTDynamicActor)actors.next();
    _debug(getFullName(),"String_Node_Str",((Nameable)next).getName());
    next.fire();
  }
  if (getRoundCount() == 0) {
    dir.setModelTime(dir.getModelTime().add(dir.getCurrentStepSize()));
  }
}

Fixed version (ground truth):
public void fireDynamicActors() throws IllegalActionException {
  _setConverged(true);
  _debug(getFullName() + "String_Node_Str");
  CTDirector dir=(CTDirector)getContainer();
  if (dir == null) {
    throw new IllegalActionException(this,"String_Node_Str");
  }
  CTScheduler scheduler=(CTScheduler)dir.getScheduler();
  if (scheduler == null) {
    throw new IllegalActionException(dir,"String_Node_Str");
  }
  CTSchedule schedule=(CTSchedule)scheduler.getSchedule();
  Iterator actors=schedule.get(CTSchedule.DYNAMIC_ACTORS).actorIterator();
  while (actors.hasNext()) {
    CTDynamicActor next=(CTDynamicActor)actors.next();
    _debug(getFullName(),"String_Node_Str",((Nameable)next).getName());
    next.fire();
  }
  if (getRoundCount() == 0) {
    dir.setModelTime(dir.getModelTime().add(dir.getCurrentStepSize()));
  }
}
Program: 75238
Project: 75238
Buggy source:
/** 
 * If a token was read in the fire() method, then produce it on the output and schedule a firing to occur when the service time elapses. The output is produced with a time offset equal to the value of the <i>newServiceTime</i> parameter.
 * @exception IllegalActionException If there is no director.
 */
public boolean postfire() throws IllegalActionException {
  Time currentTime=getDirector().getModelTime();
  if (_currentOutput != null) {
    _delayedTokens.remove(new Double(currentTime.getDoubleValue()));
  }
  if (_delayedTokensList.size() != 0 && _delayedTokens.isEmpty()) {
    _nextTimeFree=currentTime.add(_delay);
    _delayedTokens.put(new Double(_nextTimeFree.getDoubleValue()),_delayedTokensList.removeFirst());
    getDirector().fireAt(this,_nextTimeFree);
  }
  return !_stopRequested;
}

Fixed version (ground truth):
/** 
 * If there are delayed input events that are not processed and the server is not busy, schedule future firings to process them.
 * @exception IllegalActionException If there is no director or can notschedule future firings to handle delayed input events.
 */
public boolean postfire() throws IllegalActionException {
  Time currentTime=getDirector().getModelTime();
  if (_currentOutput != null) {
    _delayedTokens.remove(currentTime);
  }
  if (_delayedInputTokensList.size() != 0 && _delayedTokens.isEmpty()) {
    _nextTimeFree=currentTime.add(_delay);
    _delayedTokens.put(_nextTimeFree,_delayedInputTokensList.removeFirst());
    getDirector().fireAt(this,_nextTimeFree);
  }
  return !_stopRequested;
}