nus-yam/ex-repair huggingface dataset:
Program: 73250
Project: 73250
Buggy source:
/** 
 * Return the current state if it has a refinement. Otherwise, make state transitions until a state with a refinement is found. Set that non-transient state to be the current state and return it.
 * @return The non-transient state.
 * @exception IllegalActionException If a transient state is reachedwhile no further transition is enabled.
 */
private State _getNonTransientState() throws IllegalActionException {
  FSMActor controller=getController();
  State currentState=controller.currentState();
  TypedActor[] currentRefinements=currentState.getRefinement();
  while (currentRefinements == null) {
    chooseTransition(currentState);
    controller._commitLastChosenTransition();
    currentState=controller.currentState();
    Map<State,Transition> lastChosenTransitions=_getLastChosenTransition();
    controller._lastChosenTransition.clear();
    if (lastChosenTransitions.size() == 0) {
      throw new IllegalActionException(currentState,"String_Node_Str" + "String_Node_Str");
    }
    currentRefinements=currentState.getRefinement();
  }
  return currentState;
}

Fixed version (ground truth):
/** 
 * Return the current state if it has a refinement. Otherwise, make state transitions until a state with a refinement is found. Set that non-transient state to be the current state and return it.
 * @return The non-transient state.
 * @exception IllegalActionException If a transient state is reachedwhile no further transition is enabled.
 */
private State _getNonTransientState() throws IllegalActionException {
  FSMActor controller=getController();
  State currentState=controller.currentState();
  TypedActor[] currentRefinements=currentState.getRefinement();
  while (currentRefinements == null) {
    chooseTransition(currentState);
    controller._commitLastChosenTransition();
    currentState=controller.currentState();
    Map<State,Transition> lastChosenTransitions=_getLastChosenTransition();
    controller._lastChosenTransitions.clear();
    if (lastChosenTransitions.size() == 0) {
      throw new IllegalActionException(currentState,"String_Node_Str" + "String_Node_Str");
    }
    currentRefinements=currentState.getRefinement();
  }
  return currentState;
}
Program: 73251
Project: 73251
Buggy source:
/** 
 * Close the model along with all its connection.
 */
public void close(){
  _pingPongExecutor.shutdownNow();
  if (_pingPongFuture != null) {
    _pingPongFuture.cancel(true);
  }
  _tokenPublisher.cancel();
  _executor.shutdownNow();
  if (_mqttClient != null) {
    try {
      _mqttClient.disconnect();
    }
 catch (    MqttException e) {
      fireModelException(null,e);
    }
 finally {
      _mqttClient.terminate();
    }
  }
}

Fixed version (ground truth):
/** 
 * Close the model along with all its connection.
 */
public void close(){
  _pingPongExecutor.shutdownNow();
  if (_pingPongFuture != null) {
    _pingPongFuture.cancel(true);
  }
  _executor.shutdownNow();
  _tokenPublisher.cancel();
  if (_mqttClient != null) {
    try {
      _mqttClient.disconnect();
    }
 catch (    MqttException e) {
      fireModelException(null,e);
    }
 finally {
      _mqttClient.terminate();
    }
  }
}
Program: 73252
Project: 73252
Buggy source:
/** 
 * Cancel the publisher's timer used for sending batch of tokens.
 */
public void cancel(){
  if (_executor != null) {
    _executor.shutdownNow();
    if (_publisherFuture != null) {
      _publisherFuture.cancel(true);
    }
  }
}

Fixed version (ground truth):
/** 
 * Cancel the publisher's timer used for sending batch of tokens.
 */
public synchronized void cancel(){
  try {
    if (_tokenCount != 0) {
      _sendBatch();
      Thread.sleep(_period);
    }
  }
 catch (  Throwable e) {
    _proxyModelInfrastructure.fireModelException("String_Node_Str",e);
  }
  if (_executor != null) {
    _executor.shutdownNow();
    if (_publisherFuture != null) {
      _publisherFuture.cancel(true);
    }
  }
}
Program: 73253
Project: 73253
Buggy source:
/** 
 * React to the remote connection expiring.
 * @param remoteModel The remote model whose connection has expired.
 */
public void modelConnectionExpired(ProxyModelInfrastructure remoteModel){
  LOGGER.info("String_Node_Str" + remoteModel.getTicket());
  LOGGER.info("String_Node_Str" + remoteModel.getPingPongLatency() + "String_Node_Str");
  try {
    close(remoteModel.getTicket());
  }
 catch (  Throwable e) {
    String message="String_Node_Str" + remoteModel.getTicket().getTicketID() + "String_Node_Str";
    PtolemyServer.LOGGER.log(Level.SEVERE,message,e);
  }
}

Fixed version (ground truth):
/** 
 * React to the remote connection expiring.
 * @param remoteModel The remote model whose connection has expired.
 */
public void modelConnectionExpired(ProxyModelInfrastructure remoteModel){
  LOGGER.severe("String_Node_Str" + remoteModel.getTicket());
  LOGGER.severe("String_Node_Str" + remoteModel.getPingPongLatency() + "String_Node_Str");
  try {
    close(remoteModel.getTicket());
  }
 catch (  Throwable e) {
    String message="String_Node_Str" + remoteModel.getTicket().getTicketID() + "String_Node_Str";
    PtolemyServer.LOGGER.log(Level.SEVERE,message,e);
  }
}
Program: 73254
Project: 73254
Buggy source:
public void modelException(ProxyModelInfrastructure proxyModelInfrastructure,String message,Throwable exception){
  PtolemyServer.LOGGER.log(Level.INFO,"String_Node_Str" + proxyModelInfrastructure.getTicket().getTicketID() + "String_Node_Str",exception);
  try {
    proxyModelInfrastructure.getTokenPublisher().sendToken(new RemoteEventToken(message,exception),null);
  }
 catch (  Throwable e) {
    PtolemyServer.LOGGER.log(Level.SEVERE,"String_Node_Str" + proxyModelInfrastructure.getTicket().getTicketID(),exception);
  }
 finally {
    try {
      PtolemyServer.getInstance().close(proxyModelInfrastructure.getTicket());
    }
 catch (    Throwable e) {
      PtolemyServer.LOGGER.log(Level.SEVERE,"String_Node_Str" + proxyModelInfrastructure.getTicket().getTicketID(),exception);
    }
  }
}

Fixed version (ground truth):
public void modelException(ProxyModelInfrastructure proxyModelInfrastructure,String message,Throwable exception){
  PtolemyServer.LOGGER.log(Level.SEVERE,"String_Node_Str" + proxyModelInfrastructure.getTicket().getTicketID() + "String_Node_Str",exception);
  try {
    proxyModelInfrastructure.getTokenPublisher().sendToken(new RemoteEventToken(message,exception),null);
  }
 catch (  Throwable e) {
    PtolemyServer.LOGGER.log(Level.SEVERE,"String_Node_Str" + proxyModelInfrastructure.getTicket().getTicketID(),exception);
  }
 finally {
    try {
      PtolemyServer.getInstance().close(proxyModelInfrastructure.getTicket());
    }
 catch (    Throwable e) {
      PtolemyServer.LOGGER.log(Level.SEVERE,"String_Node_Str" + proxyModelInfrastructure.getTicket().getTicketID(),exception);
    }
  }
}
Program: 73256
Project: 73256
Buggy source:
/** 
 * Save the layout file.
 * @param layoutFile The target file for the "Save As" operation.
 */
public void saveLayoutAs(File layoutFile){
  LayoutFileOperations.saveAs(this,layoutFile);
}

Fixed version (ground truth):
/** 
 * Save the layout file.
 * @param layoutFile The target file for the "Save As" operation.
 */
public void saveLayoutAs(File layoutFile){
  try {
    _layoutURL=layoutFile.toURL();
  }
 catch (  MalformedURLException e) {
    MessageHandler.error(e.getMessage(),e);
  }
  LayoutFileOperations.saveAs(this,layoutFile);
}
Program: 73257
Project: 73257
Buggy source:
/** 
 * Get the current layout file URL.
 * @return The current layout file URL.
 */
public URL getLayoutURL(){
  if (_layoutURL == null) {
    return null;
  }
  try {
    if (!new File(_layoutURL.toURI()).canRead()) {
      return null;
    }
    return _layoutURL;
  }
 catch (  URISyntaxException e) {
    return null;
  }
}

Fixed version (ground truth):
/** 
 * Get the current layout file URL.
 * @return The current layout file URL.
 */
public URL getLayoutURL(){
  if (_layoutURL == null) {
    return null;
  }
  if (_layoutURL.getFile().equals("String_Node_Str")) {
    return null;
  }
  return _layoutURL;
}
Program: 73258
Project: 73258
Buggy source:
/** 
 * Process action on the save menu.
 * @param e The action event.
 */
private void _saveMenuActionPerformed(ActionEvent e){
  URL layoutURL=_mainFrame.getLayoutURL();
  if (layoutURL != null) {
    try {
      _mainFrame.saveLayoutAs(new File(layoutURL.toURI()));
    }
 catch (    URISyntaxException ex) {
      return;
    }
  }
 else {
    _saveAsMenuActionPerformed(e);
  }
}

Fixed version (ground truth):
/** 
 * Process action on the save menu.
 * @param e The action event.
 */
private void _saveMenuActionPerformed(ActionEvent e){
  URL layoutURL=_mainFrame.getLayoutURL();
  if (layoutURL != null) {
    _mainFrame.saveLayoutAs(new File(layoutURL.getPath()));
  }
 else {
    _saveAsMenuActionPerformed(e);
  }
}
Program: 73259
Project: 73259
Buggy source:
/** 
 * Return the PtolemyInjector.  Note that   {@link #createInjector(PtolemyModule)} must be called prior to using this method.
 * @return the PtolemyInjector that was created with the supplied modules.
 */
public static Injector getInjector(){
  return _instance;
}

Fixed version (ground truth):
/** 
 * Return the PtolemyInjector.  Note that   {@link #createInjector(PtolemyModule)} must be called prior to using this method.
 * @return the PtolemyInjector that was created with the supplied modules.
 */
public static Injector getInjector(){
  if (_instance == null) {
    ActorModuleInitializer.initializeInjector();
  }
  return _instance;
}
Program: 73260
Project: 73260
Buggy source:
/** 
 * Get the attributes with positions defined in the layout file.
 * @return All the attributes with locations parsed.
 * @exception IllegalActionException If the location information is invalidfor any of the attributes, or if the attribute is not Settable.
 */
public ArrayList<AttributeElement> getPositionableAttributes() throws IllegalActionException {
  ArrayList<AttributeElement> attributeDefinitions=new ArrayList<AttributeElement>();
  for (  EntityElement element : getPositionableEntities()) {
    _initPositionableAttributes(element.getElement(),attributeDefinitions);
  }
  _initPositionableAttributes(_topLevelActor,attributeDefinitions);
  return attributeDefinitions;
}

Fixed version (ground truth):
/** 
 * Get the attributes with positions defined in the layout file.
 * @return All the attributes with locations parsed.
 * @exception IllegalActionException If the location information is invalidfor any of the attributes, or if the attribute is not Settable.
 */
public ArrayList<AttributeElement> getPositionableAttributes() throws IllegalActionException {
  ArrayList<AttributeElement> attributeDefinitions=new ArrayList<AttributeElement>();
  List<ComponentEntity> entities=_topLevelActor.deepEntityList();
  for (  ComponentEntity entity : entities) {
    _initPositionableAttributes(entity,attributeDefinitions);
  }
  _initPositionableAttributes(_topLevelActor,attributeDefinitions);
  return attributeDefinitions;
}
Program: 73261
Project: 73261
Buggy source:
/** 
 * Set up model monitoring infrastructure.
 */
private void _setUpMonitoring(){
  setLastPongToken(new PongToken(System.currentTimeMillis()));
  _pingPongExecutor=Executors.newSingleThreadScheduledExecutor();
  _pingPongExecutor.scheduleAtFixedRate(new Runnable(){
    public void run(){
      try {
        long msTime=System.currentTimeMillis();
        _tokenPublisher.sendToken(new PingToken(msTime),null);
        _LOGGER.info("String_Node_Str");
        long latency=msTime - _getLastPongToken().getTimestamp();
        if (latency > _PING_PERIOD * 2) {
          _pingPonglatency=latency;
        }
        if (_timeoutPeriod > 0) {
          if (latency > _timeoutPeriod) {
            fireModelConnectionExpired();
          }
        }
      }
 catch (      Throwable e) {
        fireModelException("String_Node_Str",e);
      }
    }
  }
,0,_PING_PERIOD,TimeUnit.MILLISECONDS);
}

Fixed version (ground truth):
/** 
 * Set up model monitoring infrastructure.
 */
private void _setUpMonitoring(){
  setLastPongToken(new PongToken(System.currentTimeMillis()));
  _pingPongExecutor=Executors.newSingleThreadScheduledExecutor();
  _pingPongFuture=_pingPongExecutor.scheduleAtFixedRate(new Runnable(){
    public void run(){
      try {
        long msTime=System.currentTimeMillis();
        _tokenPublisher.sendToken(new PingToken(msTime),null);
        _LOGGER.info("String_Node_Str");
        long latency=msTime - _getLastPongToken().getTimestamp();
        if (latency > _PING_PERIOD * 2) {
          _pingPonglatency=latency;
        }
        if (_timeoutPeriod > 0) {
          if (latency > _timeoutPeriod) {
            fireModelConnectionExpired();
          }
        }
      }
 catch (      Throwable e) {
        fireModelException("String_Node_Str",e);
      }
    }
  }
,0,_PING_PERIOD,TimeUnit.MILLISECONDS);
}
Program: 73262
Project: 73262
Buggy source:
/** 
 * Close the model along with all its connection.
 */
public void close(){
  _pingPongExecutor.shutdown();
  _tokenPublisher.cancelTimer();
  _executor.shutdown();
  try {
    _mqttClient.disconnect();
  }
 catch (  MqttException e) {
    fireModelException(null,e);
  }
}

Fixed version (ground truth):
/** 
 * Close the model along with all its connection.
 */
public void close(){
  _pingPongExecutor.shutdownNow();
  if (_pingPongFuture != null) {
    _pingPongFuture.cancel(true);
  }
  _tokenPublisher.cancel();
  _executor.shutdownNow();
  if (_mqttClient != null) {
    try {
      _mqttClient.disconnect();
    }
 catch (    MqttException e) {
      fireModelException(null,e);
    }
 finally {
      _mqttClient.terminate();
    }
  }
}
Program: 73264
Project: 73264
Buggy source:
/** 
 * Start the timer that sends token batches.
 * @param ticket Ticket on which to start the publishing timer.
 */
public void startTimer(Ticket ticket){
  _executor=Executors.newSingleThreadScheduledExecutor();
  _executor.scheduleAtFixedRate(new Runnable(){
    public void run(){
      try {
        _sendBatch();
      }
 catch (      Throwable e) {
        _proxyModelInfrastructure.fireModelException("String_Node_Str",e);
      }
    }
  }
,0,_period,TimeUnit.MILLISECONDS);
}

Fixed version (ground truth):
/** 
 * Start the timer that sends token batches.
 * @param ticket Ticket on which to start the publishing timer.
 */
public void startTimer(Ticket ticket){
  _executor=Executors.newSingleThreadScheduledExecutor();
  _publisherFuture=_executor.scheduleAtFixedRate(new Runnable(){
    public void run(){
      try {
        _sendBatch();
      }
 catch (      Throwable e) {
        _proxyModelInfrastructure.fireModelException("String_Node_Str",e);
      }
    }
  }
,0,_period,TimeUnit.MILLISECONDS);
}
Program: 73269
Project: 73269
Buggy source:
/** 
 * Create a dummy edge for an attribute that is relative locatable. The edge will only be used to indicate the association between the attribute and its reference object.
 * @param source the source locatable node
 * @param target the target locatable node
 */
private void _createKEdgeForAttribute(Locatable source,Locatable target){
  KNode sourceNode=_kieler2ptolemyDivaNodes.inverse().get(source);
  KNode targetNode=_kieler2ptolemyDivaNodes.inverse().get(target);
  if (sourceNode != null && targetNode != null) {
    KEdge newEdge=KimlUtil.createInitializedEdge();
    newEdge.setSource(sourceNode);
    newEdge.setTarget(targetNode);
    KEdgeLayout edgeLayout=newEdge.getData(KEdgeLayout.class);
    double[] sourcePos=source.getLocation();
    edgeLayout.getSourcePoint().setX((float)sourcePos[0]);
    edgeLayout.getSourcePoint().setY((float)sourcePos[1]);
    double[] targetPos=target.getLocation();
    edgeLayout.getTargetPoint().setX((float)targetPos[0]);
    edgeLayout.getTargetPoint().setY((float)targetPos[1]);
  }
}

Fixed version (ground truth):
/** 
 * Create a dummy edge for an attribute that is relative locatable. The edge will only be used to indicate the association between the attribute and its reference object.
 * @param attribute the attribute for which to create a dummy edge
 */
private void _createKEdgeForAttribute(NamedObj attribute){
  Locatable source=PtolemyModelUtil._getLocation(attribute);
  if (source instanceof RelativeLocation) {
    NamedObj referenceObj=PtolemyModelUtil._getReferencedObj((RelativeLocation)source);
    if (referenceObj != null) {
      Locatable target=PtolemyModelUtil._getLocation(referenceObj);
      KNode sourceNode=_kieler2ptolemyDivaNodes.inverse().get(source);
      KNode targetNode=_kieler2ptolemyDivaNodes.inverse().get(target);
      if (sourceNode != null && targetNode != null) {
        KEdge newEdge=KimlUtil.createInitializedEdge();
        newEdge.setSource(sourceNode);
        newEdge.setTarget(targetNode);
        KEdgeLayout edgeLayout=newEdge.getData(KEdgeLayout.class);
        double[] sourcePos=source.getLocation();
        edgeLayout.getSourcePoint().setX((float)sourcePos[0]);
        edgeLayout.getSourcePoint().setY((float)sourcePos[1]);
        double[] targetPos=target.getLocation();
        edgeLayout.getTargetPoint().setX((float)targetPos[0]);
        edgeLayout.getTargetPoint().setY((float)targetPos[1]);
      }
    }
  }
}
Program: 73270
Project: 73270
Buggy source:
/** 
 * Return the node controller appropriate for the given node.
 */
public NodeController getNodeController(Object object){
  NodeController result=super.getNodeController(object);
  if (result != null) {
    return result;
  }
  if (object instanceof Locatable) {
    Object semanticObject=getGraphModel().getSemanticObject(object);
    if (semanticObject instanceof Entity) {
      return _stateController;
    }
 else     if (semanticObject instanceof Attribute) {
      return _attributeController;
    }
 else     if (semanticObject instanceof Port) {
      return _portController;
    }
  }
  throw new RuntimeException("String_Node_Str" + object);
}

Fixed version (ground truth):
/** 
 * Return the node controller appropriate for the given node.
 */
public NodeController getNodeController(Object object){
  NodeController result=super.getNodeController(object);
  if (result != null) {
    return result;
  }
  if (object instanceof Locatable) {
    Object semanticObject=getGraphModel().getSemanticObject(object);
    if (semanticObject instanceof Entity) {
      return _stateController;
    }
 else     if (semanticObject instanceof Attribute) {
      return _attributeController;
    }
 else     if (semanticObject instanceof Port) {
      return _portController;
    }
 else {
      return _locatableController;
    }
  }
  throw new RuntimeException("String_Node_Str" + object);
}
Program: 73271
Project: 73271
Buggy source:
/** 
 * Create a new controller with default port, state, and transition controllers.
 */
public FSMViewerGraphController(){
  _createControllers();
}

Fixed version (ground truth):
/** 
 * Create a new controller with default port, state, and transition controllers.
 */
public FSMViewerGraphController(){
  _createControllers();
  _locatableController=new LocatableNodeController(this);
}
Program: 73272
Project: 73272
Buggy source:
/** 
 * Get the angle in radians from the origin to the other point.
 * @param origin the original point
 * @param other the other point
 * @return angle in radians
 */
private double _getNormal(Point2D origin,Point2D other){
  Point2D normalPoint=new Point2D.Double(other.getX() - origin.getX(),other.getY() - origin.getY());
  double theta=Math.atan2(-normalPoint.getY(),normalPoint.getX());
  return theta;
}

Fixed version (ground truth):
/** 
 * Get the angle in radians from the origin to the other point.
 * @param origin the original point
 * @param other the other point
 * @return angle in radians
 */
private double _getNormal(Point2D origin,Point2D other){
  double normalX=other.getX() - origin.getX();
  double normalY=other.getY() - origin.getY();
  double theta=Math.atan2(normalY,normalX);
  return theta;
}
Program: 73273
Project: 73273
Buggy source:
/** 
 * Get the center point of a Perimeter Site. Copied the idea from  {@link PerimeterSite#getPoint(double)}.
 * @param site the site
 * @return the center point of the shape that corresponds to the site
 */
private Point2D _getCenterPoint(Site site){
  try {
    Rectangle bounds=site.getFigure().getShape().getBounds();
    return new Point2D.Double(bounds.getCenterX(),bounds.getCenterY());
  }
 catch (  NullPointerException e) {
    return site.getPoint();
  }
}

Fixed version (ground truth):
/** 
 * Get the center point of a Perimeter Site. Copied the idea from  {@link PerimeterSite#getPoint(double)}.
 * @param site the site
 * @return the center point of the shape that corresponds to the site
 */
private Point2D _getCenterPoint(Site site){
  Figure figure=site.getFigure();
  if (figure == null) {
    return site.getPoint();
  }
  if (site instanceof PortConnectSite && figure.getParent() instanceof Figure) {
    figure=(Figure)figure.getParent();
  }
  Rectangle bounds=figure.getShape().getBounds();
  return new Point2D.Double(bounds.getCenterX(),bounds.getCenterY());
}
Program: 73275
Project: 73275
Buggy source:
/** 
 * Get the starting and ending points of a connector. Copied some code from  {@link BasicManhattanRouter#routeManhattan(diva.canvas.connector.ManhattanConnector)}.
 * @param c the corresponding connector
 * @param bendPoints a list of bendpoints to determine the anchor point on the site
 * @return the anchor points at the start and end of theconnection, i.e. a Point2D array of size 2
 */
private Point2D[] _getHeadTailPoints(Connector c,List<Point2D> bendPoints){
  TransformContext currentContext=c.getTransformContext();
  Point2D headPt, tailPt;
  Site headSite=c.getHeadSite();
  Site tailSite=c.getTailSite();
  if (currentContext != null) {
    headPt=_getCenterPoint(headSite);
    tailPt=_getCenterPoint(tailSite);
    Point2D headBend, tailBend;
    if (!bendPoints.isEmpty()) {
      headBend=bendPoints.get(0);
      tailBend=bendPoints.get(bendPoints.size() - 1);
    }
 else {
      headBend=tailPt;
      tailBend=headPt;
    }
    headSite.setNormal(_getNormal(headPt,headBend));
    tailSite.setNormal(_getNormal(tailPt,tailBend));
    headPt=headSite.getPoint(currentContext);
    tailPt=tailSite.getPoint(currentContext);
  }
 else {
    tailPt=tailSite.getPoint();
    headPt=headSite.getPoint();
  }
  Point2D[] result={headPt,tailPt};
  return result;
}

Fixed version (ground truth):
/** 
 * Get the starting and ending points of a connector. Copied some code from  {@link BasicManhattanRouter#routeManhattan(diva.canvas.connector.ManhattanConnector)}.
 * @param bendPoints a list of bendpoints to determine the anchor point on the site
 * @return the anchor points at the start and end of theconnection, i.e. a Point2D array of size 2
 */
private Point2D[] _getHeadTailPoints(List<Point2D> bendPoints){
  TransformContext currentContext=getTransformContext();
  Point2D headPt, tailPt;
  Site headSite=getHeadSite();
  Site tailSite=getTailSite();
  if (currentContext != null) {
    headPt=_getCenterPoint(headSite);
    tailPt=_getCenterPoint(tailSite);
    Point2D headBend, tailBend;
    if (!bendPoints.isEmpty()) {
      headBend=bendPoints.get(0);
      tailBend=bendPoints.get(bendPoints.size() - 1);
    }
 else {
      headBend=tailPt;
      tailBend=headPt;
    }
    headSite.setNormal(_getNormal(headPt,headBend));
    tailSite.setNormal(_getNormal(tailPt,tailBend));
    headPt=headSite.getPoint(currentContext);
    tailPt=tailSite.getPoint(currentContext);
  }
 else {
    tailPt=tailSite.getPoint();
    headPt=headSite.getPoint();
  }
  Point2D[] result={headPt,tailPt};
  return result;
}
Program: 73276
Project: 73276
Buggy source:
/** 
 * Read a token from each input port.  If the token from the <i>control</i> input is true, then output the token consumed from the <i>trueInput</i> port, otherwise output the token from the <i>falseInput</i> port.
 * @exception IllegalActionException If there is no director.
 */
public void fire() throws IllegalActionException {
  super.fire();
  if (_control == null) {
    _control=((BooleanToken)control.get(0));
    _controlUsed=false;
  }
 else {
    if (_control.booleanValue()) {
      for (int i=0; i < trueInput.getWidth(); i++) {
        if (output.getWidth() > i) {
          output.send(i,trueInput.get(i));
        }
      }
    }
 else {
      for (int i=0; i < falseInput.getWidth(); i++) {
        if (output.getWidth() > i) {
          output.send(i,falseInput.get(i));
        }
      }
    }
    _controlUsed=true;
  }
}

Fixed version (ground truth):
/** 
 * Read a token from the control port or from the input designated by the previously read input from the control port.  In the latter case, send to the token read to the output. In the former case, send nothing to the output.
 * @exception IllegalActionException If there is no director.
 */
public void fire() throws IllegalActionException {
  super.fire();
  if (_control == null) {
    _control=((BooleanToken)control.get(0));
    _controlUsed=false;
  }
 else {
    if (_control.booleanValue()) {
      for (int i=0; i < trueInput.getWidth(); i++) {
        if (output.getWidth() > i) {
          output.send(i,trueInput.get(i));
        }
      }
    }
 else {
      for (int i=0; i < falseInput.getWidth(); i++) {
        if (output.getWidth() > i) {
          output.send(i,falseInput.get(i));
        }
      }
    }
    _controlUsed=true;
  }
}
Program: 73277
Project: 73277
Buggy source:
/** 
 * Return 0.0 unless the <i>delay</i> port is connected, in which case, return the value of <i>minimumDelay</i>.
 * @return The minimum delay from the input to the output.
 * @throws IllegalActionException If the <i>minimumDelay</i>parameter cannot be evaluated.
 */
protected double _minimumDelay() throws IllegalActionException {
  double minimumDelayValue=0.0;
  if (delay.getPort().sourcePortList().size() > 0) {
    minimumDelayValue=((DoubleToken)(minimumDelay.getToken())).doubleValue();
  }
  return minimumDelayValue;
}

Fixed version (ground truth):
/** 
 * Return 0.0 unless the <i>delay</i> port is connected, in which case, return the value of <i>minimumDelay</i>.
 * @return The minimum delay from the input to the output.
 * @throws IllegalActionException If the <i>minimumDelay</i>parameter cannot be evaluated.
 */
protected double _minimumDelay() throws IllegalActionException {
  double minimumDelayValue=_minimumDelay;
  if (delay.getPort().sourcePortList().size() > 0) {
    minimumDelayValue=((DoubleToken)(minimumDelay.getToken())).doubleValue();
  }
  return minimumDelayValue;
}
Program: 73278
Project: 73278
Buggy source:
/** 
 * If the attribute is <i>delay</i>, then ensure that the value is non-negative. <p>NOTE: the newDelay may be 0.0, which may change the causality property of the model. We leave the model designers to decide whether the zero delay is really what they want.
 * @param attribute The attribute that changed.
 * @exception IllegalActionException If the delay is negative.
 */
public void attributeChanged(Attribute attribute) throws IllegalActionException {
  if (attribute == delay) {
    double newDelay=((DoubleToken)(delay.getToken())).doubleValue();
    double minimumDelayValue=_minimumDelay();
    if (newDelay < minimumDelayValue) {
      throw new IllegalActionException(this,"String_Node_Str" + minimumDelayValue + "String_Node_Str"+ newDelay);
    }
 else {
      _delay=newDelay;
    }
  }
 else {
    super.attributeChanged(attribute);
  }
}

Fixed version (ground truth):
/** 
 * If the attribute is <i>delay</i>, then ensure that the value is non-negative. <p>NOTE: the newDelay may be 0.0, which may change the causality property of the model. We leave the model designers to decide whether the zero delay is really what they want.
 * @param attribute The attribute that changed.
 * @exception IllegalActionException If the delay is negative.
 */
public void attributeChanged(Attribute attribute) throws IllegalActionException {
  if (attribute == delay) {
    double newDelay=((DoubleToken)(delay.getToken())).doubleValue();
    double minimumDelayValue=_minimumDelay();
    if (newDelay < minimumDelayValue) {
      throw new IllegalActionException(this,"String_Node_Str" + minimumDelayValue + "String_Node_Str"+ newDelay);
    }
 else {
      _delay=newDelay;
    }
  }
 else   if (attribute == minimumDelay) {
    double newMinimumDelay=((DoubleToken)(minimumDelay.getToken())).doubleValue();
    if (newMinimumDelay > _delay) {
      throw new IllegalActionException(this,"String_Node_Str" + _delay + "String_Node_Str");
    }
 else {
      _minimumDelay=newMinimumDelay;
    }
  }
 else {
    super.attributeChanged(attribute);
  }
}
Program: 73279
Project: 73279
Buggy source:
/** 
 * Create an editor for configuring the specified object with the specified parent window.
 * @param object The object to configure.
 * @param parent The parent window, or null if there is none.
 */
public void createEditor(NamedObj object,Frame parent){
  try {
    Configuration configuration=((TableauFrame)parent).getConfiguration();
    NamedObj container=object.getContainer();
    plot=new Plot();
    plot.setTitle("String_Node_Str");
    plot.setButtons(true);
    plot.setMarksStyle("String_Node_Str");
    Effigy effigy=Configuration.findEffigy(toplevel());
    PlotEffigy schedulePlotterEffigy=new PlotEffigy(effigy,container.uniqueName("String_Node_Str"));
    schedulePlotterEffigy.setPlot(plot);
    schedulePlotterEffigy.identifier.setExpression("String_Node_Str");
    configuration.createPrimaryTableau(schedulePlotterEffigy);
    plot.setVisible(true);
  }
 catch (  Throwable throwable) {
    throw new InternalErrorException(object,throwable,"String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Create an editor for configuring the specified object with the specified parent window.
 * @param object The object to configure.
 * @param parent The parent window, or null if there is none.
 */
public void createEditor(NamedObj object,Frame parent){
  try {
    Configuration configuration=((TableauFrame)parent).getConfiguration();
    NamedObj container=object.getContainer();
    plot=new Plot();
    plot.setTitle("String_Node_Str");
    plot.setButtons(true);
    plot.setMarksStyle("String_Node_Str");
    Effigy effigy=Configuration.findEffigy(toplevel());
    PlotEffigy schedulePlotterEffigy=new PlotEffigy(effigy,container.uniqueName("String_Node_Str"));
    schedulePlotterEffigy.setPlot(plot);
    schedulePlotterEffigy.setModel(this.getContainer());
    schedulePlotterEffigy.identifier.setExpression("String_Node_Str");
    configuration.createPrimaryTableau(schedulePlotterEffigy);
    plot.setVisible(true);
  }
 catch (  Throwable throwable) {
    throw new InternalErrorException(object,throwable,"String_Node_Str");
  }
}
Program: 73280
Project: 73280
Buggy source:
/** 
 * Create an editor for configuring the specified object with the specified parent window.
 * @param object The object to configure.
 * @param parent The parent window, or null if there is none.
 */
public void createEditor(NamedObj object,Frame parent){
  try {
    Configuration configuration=((TableauFrame)parent).getConfiguration();
    NamedObj container=object.getContainer();
    plot=new Plot();
    plot.setTitle("String_Node_Str");
    plot.setButtons(true);
    plot.setMarksStyle("String_Node_Str");
    Effigy effigy=Configuration.findEffigy(toplevel());
    PlotEffigy schedulePlotterEffigy=new PlotEffigy(effigy,container.uniqueName("String_Node_Str"));
    schedulePlotterEffigy.setPlot(plot);
    schedulePlotterEffigy.identifier.setExpression("String_Node_Str");
    configuration.createPrimaryTableau(schedulePlotterEffigy);
    plot.setVisible(true);
  }
 catch (  Throwable throwable) {
    throw new InternalErrorException(object,throwable,"String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Create an editor for configuring the specified object with the specified parent window.
 * @param object The object to configure.
 * @param parent The parent window, or null if there is none.
 */
public void createEditor(NamedObj object,Frame parent){
  try {
    Configuration configuration=((TableauFrame)parent).getConfiguration();
    NamedObj container=object.getContainer();
    plot=new Plot();
    plot.setTitle("String_Node_Str");
    plot.setButtons(true);
    plot.setMarksStyle("String_Node_Str");
    Effigy effigy=Configuration.findEffigy(toplevel());
    PlotEffigy schedulePlotterEffigy=new PlotEffigy(effigy,container.uniqueName("String_Node_Str"));
    schedulePlotterEffigy.setPlot(plot);
    schedulePlotterEffigy.setModel(this.getContainer());
    schedulePlotterEffigy.identifier.setExpression("String_Node_Str");
    configuration.createPrimaryTableau(schedulePlotterEffigy);
    plot.setVisible(true);
  }
 catch (  Throwable throwable) {
    throw new InternalErrorException(object,throwable,"String_Node_Str");
  }
}
Program: 73283
Project: 73283
Buggy source:
/** 
 * This method, which is required by the ImageObserver interface, is called if something has changed in a background loading of the image.
 * @param image The image being observed.
 * @param infoflags The bitwise inclusive OR of the following flags:WIDTH, HEIGHT, PROPERTIES, SOMEBITS, FRAMEBITS, ALLBITS, ERROR, ABORT.
 * @param x The x coordinate of the image.
 * @param y The y coordinate of the image.
 * @param width The width of the image.
 * @param height The height of the image.
 * @return False if the infoflags indicate that the image iscompletely loaded; true otherwise.
 */
public boolean imageUpdate(Image image,int infoflags,int x,int y,int width,int height){
  if ((infoflags & (ImageObserver.HEIGHT | ImageObserver.WIDTH)) != 0) {
    _height=height;
    _width=width;
    _image.getWidth(this);
    _image.getHeight(this);
    return true;
  }
  if ((infoflags & ImageObserver.ALLBITS) != 0) {
    scaleImage(_scalePercentage);
    Runnable doRepaint=new Runnable(){
      public void run(){
        Iterator figures=_liveFigureIterator();
        while (figures.hasNext()) {
          Object figure=figures.next();
          ((ImageFigure)figure).repaint();
        }
      }
    }
;
    SwingUtilities.invokeLater(doRepaint);
    return false;
  }
  if ((infoflags & (ImageObserver.ERROR | ImageObserver.ABORT)) != 0) {
    return false;
  }
  _image.getWidth(this);
  _image.getHeight(this);
  return true;
}

Fixed version (ground truth):
/** 
 * This method, which is required by the ImageObserver interface, is called if something has changed in a background loading of the image.
 * @param image The image being observed.
 * @param infoflags The bitwise inclusive OR of the following flags:WIDTH, HEIGHT, PROPERTIES, SOMEBITS, FRAMEBITS, ALLBITS, ERROR, ABORT.
 * @param x The x coordinate of the image.
 * @param y The y coordinate of the image.
 * @param width The width of the image.
 * @param height The height of the image.
 * @return False if the infoflags indicate that the image iscompletely loaded; true otherwise.
 */
public synchronized boolean imageUpdate(Image image,int infoflags,int x,int y,int width,int height){
  if ((infoflags & ImageObserver.ALLBITS) != 0) {
    if (_scalePercentage != 0.0 && _scalePercentage != _scalePercentageImplemented) {
      scaleImage(_scalePercentage);
      return true;
    }
    _updateFigures();
    return false;
  }
  if ((infoflags & (ImageObserver.ERROR | ImageObserver.ABORT)) != 0) {
    URL url=getClass().getResource("String_Node_Str");
    Toolkit tk=Toolkit.getDefaultToolkit();
    Image errorImage=tk.getImage(url);
synchronized (this) {
      _image=errorImage;
      _scaledImage=errorImage;
    }
    if (tk.prepareImage(_image,-1,-1,this)) {
      _updateFigures();
    }
    return true;
  }
  return true;
}
Program: 73284
Project: 73284
Buggy source:
/** 
 * Create a new default background figure, which is the shape set by setShape, if it has been called, or a small box if not. This must be called in the Swing thread, or a concurrent modification exception could occur.
 * @return A figure representing the specified shape.
 */
public Figure createBackgroundFigure(){
  if (_scaledImage == null) {
    try {
      URL url=FileUtilities.nameToURL("String_Node_Str",null,getClass().getClassLoader());
      Toolkit tk=Toolkit.getDefaultToolkit();
      setImage(tk.getImage(url));
    }
 catch (    IOException ex) {
    }
  }
  Figure newFigure=new ImageFigure(_scaledImage);
  _addLiveFigure(newFigure);
  return newFigure;
}

Fixed version (ground truth):
/** 
 * Create a new default background figure, which is scaled image, if it has been set, or a default image if not. This must be called in the Swing thread, or a concurrent modification exception could occur.
 * @return A figure representing the specified shape.
 */
public Figure createBackgroundFigure(){
  Toolkit tk=Toolkit.getDefaultToolkit();
  if (_scaledImage == null) {
    try {
      URL url=FileUtilities.nameToURL("String_Node_Str",null,getClass().getClassLoader());
      _scaledImage=_image=tk.getImage(url);
      setImage(_scaledImage);
      tk.prepareImage(_scaledImage,-1,-1,this);
    }
 catch (    IOException ex) {
    }
  }
  ImageFigure newFigure=null;
  if (_scalePercentage == _scalePercentageImplemented && (tk.checkImage(_scaledImage,43,33,this) & ImageObserver.ALLBITS) != 0) {
    newFigure=new ImageFigure(_scaledImage);
  }
 else {
    newFigure=new ImageFigure(null);
  }
  newFigure.setCentered(false);
  _addLiveFigure(newFigure);
  return newFigure;
}
Program: 73285
Project: 73285
Buggy source:
/** 
 * Clone the object into the specified workspace. The new object is <i>not</i> added to the directory of that workspace (you must do this yourself if you want it there). The result is an object with no container.
 * @param workspace The workspace for the cloned object.
 * @exception CloneNotSupportedException Not thrown in this base class
 * @return The new Attribute.
 */
public Object clone(Workspace workspace) throws CloneNotSupportedException {
  ImageIcon newObject=(ImageIcon)super.clone(workspace);
  newObject._image=null;
  newObject._scaledImage=null;
  return newObject;
}

Fixed version (ground truth):
/** 
 * Clone the object into the specified workspace. The new object is <i>not</i> added to the directory of that workspace (you must do this yourself if you want it there). The result is an object with no container.
 * @param workspace The workspace for the cloned object.
 * @exception CloneNotSupportedException Not thrown in this base class
 * @return The new Attribute.
 */
public Object clone(Workspace workspace) throws CloneNotSupportedException {
  ImageIcon newObject=(ImageIcon)super.clone(workspace);
  newObject._image=null;
  newObject._scaledImage=null;
  newObject._scalePercentage=0.0;
  newObject._scalePercentageImplemented=-1.0;
  return newObject;
}
Program: 73286
Project: 73286
Buggy source:
/** 
 * Specify a scaling for the image as a percentage.
 * @param percentage The scaling percentage.
 */
public void scaleImage(double percentage){
  if (percentage == _scalePercentage) {
    return;
  }
  _scalePercentage=percentage;
  Runnable doScale=new Runnable(){
    public void run(){
      if (_image == null) {
        return;
      }
      int width=_image.getWidth(ImageIcon.this);
      int height=_image.getHeight(ImageIcon.this);
      if ((width < 0) || (height < 0)) {
        width=_width;
        height=_height;
      }
      if ((width > 0) && (height > 0)) {
        int newWidth=(int)Math.round((width * _scalePercentage) / 100.0);
        int newHeight=(int)Math.round((height * _scalePercentage) / 100.0);
        _scaledImage=_image.getScaledInstance(newWidth,newHeight,Image.SCALE_SMOOTH);
        _scaledImage.getWidth(ImageIcon.this);
        _scaledImage.getHeight(ImageIcon.this);
        Iterator figures=_liveFigureIterator();
        while (figures.hasNext()) {
          Object figure=figures.next();
          ((ImageFigure)figure).setCentered(false);
          ((ImageFigure)figure).setImage(_scaledImage);
        }
      }
    }
  }
;
  SwingUtilities.invokeLater(doScale);
}

Fixed version (ground truth):
/** 
 * Specify a scaling for the image as a percentage.
 * @param percentage The scaling percentage.
 */
public synchronized void scaleImage(double percentage){
  _scalePercentage=percentage;
  _scalePercentageImplemented=-1.0;
  if (_image == null) {
    return;
  }
  Runnable doScale=new Runnable(){
    public void run(){
synchronized (ImageIcon.this) {
        Toolkit tk=Toolkit.getDefaultToolkit();
        int width=_image.getWidth(ImageIcon.this);
        int height=_image.getHeight(ImageIcon.this);
        if (width < 0 || height < 0) {
          return;
        }
        int newWidth=(int)Math.round((width * _scalePercentage) / 100.0);
        int newHeight=(int)Math.round((height * _scalePercentage) / 100.0);
        _scaledImage=_image.getScaledInstance(newWidth,newHeight,Image.SCALE_SMOOTH);
        _scalePercentageImplemented=_scalePercentage;
        if (tk.prepareImage(_scaledImage,width,height,ImageIcon.this)) {
          _updateFigures();
        }
      }
    }
  }
;
  SwingUtilities.invokeLater(doScale);
}
Program: 73287
Project: 73287
Buggy source:
public void run(){
  Iterator figures=_liveFigureIterator();
  while (figures.hasNext()) {
    Object figure=figures.next();
    ((ImageFigure)figure).setImage(_scaledImage);
    if (_scalePercentage != 100.0) {
      scaleImage(_scalePercentage);
    }
  }
}

Fixed version (ground truth):
public void run(){
synchronized (ImageIcon.this) {
    Toolkit tk=Toolkit.getDefaultToolkit();
    int width=_image.getWidth(ImageIcon.this);
    int height=_image.getHeight(ImageIcon.this);
    if (width < 0 || height < 0) {
      return;
    }
    int newWidth=(int)Math.round((width * _scalePercentage) / 100.0);
    int newHeight=(int)Math.round((height * _scalePercentage) / 100.0);
    _scaledImage=_image.getScaledInstance(newWidth,newHeight,Image.SCALE_SMOOTH);
    _scalePercentageImplemented=_scalePercentage;
    if (tk.prepareImage(_scaledImage,width,height,ImageIcon.this)) {
      _updateFigures();
    }
  }
}
Program: 73288
Project: 73288
Buggy source:
/** 
 * Specify an image to display.  This is deferred and executed in the Swing thread.
 * @param image The image to display.
 */
public void setImage(Image image){
  _image=image;
  _scaledImage=image;
  _image.getWidth(this);
  _image.getHeight(this);
  Runnable doSet=new Runnable(){
    public void run(){
      Iterator figures=_liveFigureIterator();
      while (figures.hasNext()) {
        Object figure=figures.next();
        ((ImageFigure)figure).setImage(_scaledImage);
        if (_scalePercentage != 100.0) {
          scaleImage(_scalePercentage);
        }
      }
    }
  }
;
  SwingUtilities.invokeLater(doSet);
}

Fixed version (ground truth):
/** 
 * Specify an image to display. Note that this does not actually result in the image displaying. You must call scaleImage().
 * @param image The image to display.
 */
public synchronized void setImage(Image image){
  _image=image;
  _scaledImage=image;
  if (_scalePercentage != _scalePercentageImplemented) {
    scaleImage(_scalePercentage);
    return;
  }
}
Program: 73289
Project: 73289
Buggy source:
/** 
 * Send the token back via the model's publisher.
 * @see java.lang.Runnable#run()
 */
public void run(){
  try {
    _remoteModel.getTokenPublisher().sendToken(_token);
  }
 catch (  IllegalActionException e) {
  }
}

Fixed version (ground truth):
/** 
 * Send the token back via the model's publisher.
 * @see java.lang.Runnable#run()
 */
@Override public void run(){
  try {
    _remoteModel.getTokenPublisher().sendToken(_token);
  }
 catch (  IllegalActionException e) {
  }
}
Program: 73293
Project: 73293
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,String> 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,Type> portTypes) throws IllegalActionException, NameDuplicationException, CloneNotSupportedException {
  super(container,targetSink,replaceTargetEntity,portTypes);
}
Program: 73294
Project: 73294
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,String> 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,Type> portTypes) throws IllegalActionException, NameDuplicationException, CloneNotSupportedException {
  super(container,targetSource,replaceTargetEntity,portTypes);
}