nus-yam/ex-repair huggingface dataset:
Program: 72618
Project: 72618
Buggy source:
/** 
 * Clone the attribute.
 * @param workspace The workspace in which to place the cloned attribute.
 * @exception CloneNotSupportedException Not thrown in this base class.
 * @see java.lang.Object#clone()
 * @return The cloned attribute.
 */
@Override public Object clone(Workspace workspace) throws CloneNotSupportedException {
  WebServer newObject=(WebServer)super.clone(workspace);
  newObject._appInfo=null;
  newObject._dynamicPortSelection=false;
  newObject._serverManager=WebServerManager.getInstance();
  return newObject;
}

Fixed version (ground truth):
/** 
 * Clone the attribute.
 * @param workspace The workspace in which to place the cloned attribute.
 * @exception CloneNotSupportedException Not thrown in this base class.
 * @see java.lang.Object#clone()
 * @return The cloned attribute.
 */
@Override public Object clone(Workspace workspace) throws CloneNotSupportedException {
  WebServer newObject=(WebServer)super.clone(workspace);
  newObject._appInfo=null;
  newObject._dynamicPortSelection=false;
  newObject._serverManager=null;
  return newObject;
}
Program: 72620
Project: 72620
Buggy source:
/** 
 * Create an instance of the actor.
 * @param container The container
 * @param name The name.
 * @exception IllegalActionException If the superclass throws it.
 * @exception NameDuplicationException If the superclass throws it.
 */
public WebSocketReader(CompositeEntity container,String name) throws IllegalActionException, NameDuplicationException {
  super(container,name);
  path=new StringParameter(this,"String_Node_Str");
  path.setExpression("String_Node_Str");
  client=new Parameter(this,"String_Node_Str");
  client.setToken("String_Node_Str");
  client.setVisibility(Settable.NOT_EDITABLE);
  output=new TypedIOPort(this,"String_Node_Str",false,true);
  output.setTypeEquals(BaseType.STRING);
  _endpointManager=WebSocketEndpointManager.getInstance();
}

Fixed version (ground truth):
/** 
 * Create an instance of the actor.
 * @param container The container
 * @param name The name.
 * @exception IllegalActionException If the superclass throws it.
 * @exception NameDuplicationException If the superclass throws it.
 */
public WebSocketReader(CompositeEntity container,String name) throws IllegalActionException, NameDuplicationException {
  super(container,name);
  path=new StringParameter(this,"String_Node_Str");
  path.setExpression("String_Node_Str");
  client=new Parameter(this,"String_Node_Str");
  client.setToken("String_Node_Str");
  client.setVisibility(Settable.NOT_EDITABLE);
  output=new TypedIOPort(this,"String_Node_Str",false,true);
  output.setTypeEquals(BaseType.STRING);
}
Program: 72621
Project: 72621
Buggy source:
/** 
 * Remember the time at which this actor was initialized in order to request firings at a particular time. Subscribe this service to the  appropriate endpoint.
 * @exception IllegalActionException If the parent throws it.
 */
@Override public void initialize() throws IllegalActionException {
  super.initialize();
  _initializeModelTime=getDirector().getModelTime();
  _initializeRealTime=System.currentTimeMillis() - 100;
  if (!(!WebSocketEndpointManager.isRemoteURI(_URIpath) && isClient())) {
    _endpointManager.subscribe(this,_URIpath.toString());
  }
}

Fixed version (ground truth):
/** 
 * Remember the time at which this actor was initialized in order to request firings at a particular time. Subscribe this service to the  appropriate endpoint.
 * @exception IllegalActionException If the parent throws it.
 */
@Override public void initialize() throws IllegalActionException {
  super.initialize();
  if (_endpointManager == null) {
    _endpointManager=WebSocketEndpointManager.getInstance();
  }
  _initializeModelTime=getDirector().getModelTime();
  _initializeRealTime=System.currentTimeMillis() - 100;
  if (!(!WebSocketEndpointManager.isRemoteURI(_URIpath) && isClient())) {
    _endpointManager.subscribe(this,_URIpath.toString());
  }
}
Program: 72622
Project: 72622
Buggy source:
/** 
 * Subscribe this service to the appropriate endpoint.
 * @exception IllegalActionException If the parent throws it.
 */
@Override public void initialize() throws IllegalActionException {
  super.initialize();
  if (!(!WebSocketEndpointManager.isRemoteURI(_URIpath) && isClient())) {
    _endpointManager.subscribe(this,_URIpath.toString());
  }
}

Fixed version (ground truth):
/** 
 * Subscribe this service to the appropriate endpoint.
 * @exception IllegalActionException If the parent throws it.
 */
@Override public void initialize() throws IllegalActionException {
  super.initialize();
  if (_endpointManager == null) {
    _endpointManager=WebSocketEndpointManager.getInstance();
  }
  if (!(!WebSocketEndpointManager.isRemoteURI(_URIpath) && isClient())) {
    _endpointManager.subscribe(this,_URIpath.toString());
  }
}
Program: 72623
Project: 72623
Buggy source:
/** 
 * Create an instance of the actor.
 * @param container The container
 * @param name The name.
 * @exception IllegalActionException If the superclass throws it.
 * @exception NameDuplicationException If the superclass throws it.
 */
public WebSocketWriter(CompositeEntity container,String name) throws IllegalActionException, NameDuplicationException {
  super(container,name);
  path=new StringParameter(this,"String_Node_Str");
  path.setExpression("String_Node_Str");
  client=new Parameter(this,"String_Node_Str");
  client.setToken("String_Node_Str");
  client.setVisibility(Settable.NOT_EDITABLE);
  input=new TypedIOPort(this,"String_Node_Str",true,false);
  input.setTypeEquals(BaseType.STRING);
  _endpointManager=WebSocketEndpointManager.getInstance();
}

Fixed version (ground truth):
/** 
 * Create an instance of the actor.
 * @param container The container
 * @param name The name.
 * @exception IllegalActionException If the superclass throws it.
 * @exception NameDuplicationException If the superclass throws it.
 */
public WebSocketWriter(CompositeEntity container,String name) throws IllegalActionException, NameDuplicationException {
  super(container,name);
  path=new StringParameter(this,"String_Node_Str");
  path.setExpression("String_Node_Str");
  client=new Parameter(this,"String_Node_Str");
  client.setToken("String_Node_Str");
  client.setVisibility(Settable.NOT_EDITABLE);
  input=new TypedIOPort(this,"String_Node_Str",true,false);
  input.setTypeEquals(BaseType.STRING);
}
Program: 72624
Project: 72624
Buggy source:
/** 
 * Create a new icon with the given name in the given container.
 * @param container The container.
 * @param name The name of the attribute.
 * @exception IllegalActionException If the attribute is not of anacceptable class for the container.
 * @exception NameDuplicationException If the name coincides withan attribute already in the container.
 */
public PDFIcon(NamedObj container,String name) throws IllegalActionException, NameDuplicationException {
  super(container,name);
}

Fixed version (ground truth):
/** 
 * Create a new icon with the given name in the given container.
 * @param container The container.
 * @param name The name of the attribute.
 * @exception IllegalActionException If the attribute is not of anacceptable class for the container.
 * @exception NameDuplicationException If the name coincides withan attribute already in the container.
 */
public PDFIcon(NamedObj container,String name) throws IllegalActionException, NameDuplicationException {
  super(container,name);
  try {
    Class.forName("String_Node_Str");
    Class.forName("String_Node_Str");
    Class.forName("String_Node_Str");
  }
 catch (  Throwable throwable) {
    throw new IllegalActionException(this,throwable,"String_Node_Str");
  }
}
Program: 72626
Project: 72626
Buggy source:
/** 
 * Wrap up, close web socket if open, stop vertx.
 */
@Override public synchronized void wrapup() throws IllegalActionException {
  super.wrapup();
  _websocket.close();
  _client.close();
  _vertx.stop();
}

Fixed version (ground truth):
/** 
 * Wrap up, close web socket if open, stop vertx.
 */
@Override public synchronized void wrapup() throws IllegalActionException {
  super.wrapup();
  if (_websocket != null) {
    _websocket.close();
  }
  if (_client != null) {
    _client.close();
  }
  _vertx.stop();
}
Program: 72627
Project: 72627
Buggy source:
/** 
 * If there is a token on the input, convert the token to a json object and publish that to the event bus.
 */
@Override public void fire() throws IllegalActionException {
  for (int i=0; i < publish.getWidth(); i++) {
    if (publish.hasToken(i)) {
      StringToken token=(StringToken)publish.get(i);
      String tokenString=token.stringValue();
      JsonObject msg=new JsonObject().putString("String_Node_Str","String_Node_Str").putString("String_Node_Str",_address).putString("String_Node_Str",tokenString);
synchronized (workspace()) {
        while ((_websocket == null) && !_stopRequested) {
          try {
            workspace().wait(1);
          }
 catch (          InterruptedException e) {
            throw new IllegalActionException(this,e.getCause(),e.getMessage());
          }
        }
        _websocket.writeTextFrame(msg.encode());
      }
    }
  }
  if (_buffer != null && _buffer.size() > 0) {
    List<StringToken> _bufferCopy=new ArrayList<StringToken>();
synchronized (_buffer) {
      _bufferCopy.addAll(_buffer);
      _buffer.clear();
    }
    for (int i=0; i < _bufferCopy.size(); i++) {
      subscribe.send(0,_bufferCopy.get(i));
    }
  }
}

Fixed version (ground truth):
/** 
 * If there is a token on the input, convert the token to a json object and publish that to the event bus.
 */
@Override public void fire() throws IllegalActionException {
  if (_exception != null) {
    throw new IllegalActionException(this,_exception,_exception.getMessage());
  }
  for (int i=0; i < publish.getWidth(); i++) {
    if (publish.hasToken(i)) {
      StringToken token=(StringToken)publish.get(i);
      String tokenString=token.stringValue();
      JsonObject msg=new JsonObject().putString("String_Node_Str","String_Node_Str").putString("String_Node_Str",_address).putString("String_Node_Str",tokenString);
      _sendTextFrame(msg);
    }
  }
  if (_buffer != null) {
    List<StringToken> _bufferCopy=new ArrayList<StringToken>();
synchronized (_buffer) {
      if (_buffer.size() > 0) {
        _bufferCopy.addAll(_buffer);
        _buffer.clear();
      }
    }
    for (int i=0; i < _bufferCopy.size(); i++) {
      subscribe.send(0,_bufferCopy.get(i));
    }
  }
}
Program: 72628
Project: 72628
Buggy source:
/** 
 * Open a web socket that serves as a connection to the event bus.
 */
private synchronized void _openWebSocket(){
  if (!_stopRequested) {
    MultiMap map=new CaseInsensitiveMultiMap();
    map.add("String_Node_Str","String_Node_Str");
    _client.setConnectTimeout(100000000);
    _client.connectWebsocket("String_Node_Str",WebSocketVersion.RFC6455,map,new Handler<WebSocket>(){
      @Override public void handle(      WebSocket websocket){
        JsonObject msg=new JsonObject().putString("String_Node_Str","String_Node_Str").putString("String_Node_Str",_address);
        websocket.writeTextFrame(msg.encode());
        _websocket=websocket;
        websocket.dataHandler(new Handler<Buffer>(){
          @Override public void handle(          Buffer buff){
            String msg=buff.toString();
            JsonObject received=new JsonObject(msg);
            if (_buffer == null) {
              _buffer=new ArrayList<StringToken>();
            }
synchronized (_buffer) {
              _buffer.add(new StringToken(received.getField("String_Node_Str").toString()));
            }
            try {
              getDirector().fireAtCurrentRealTime((Actor)subscribe.getContainer());
            }
 catch (            IllegalActionException e) {
              e.printStackTrace();
            }
          }
        }
);
        websocket.closeHandler(new Handler<Void>(){
          @Override public void handle(          final Void event){
          }
        }
);
      }
    }
);
  }
}

Fixed version (ground truth):
/** 
 * Open a web socket that serves as a connection to the event bus.
 */
private synchronized void _openWebSocket(){
  if (!_stopRequested) {
    _client.connectWebsocket("String_Node_Str",new Handler<WebSocket>(){
      @Override public void handle(      WebSocket websocket){
        JsonObject msg=new JsonObject().putString("String_Node_Str","String_Node_Str").putString("String_Node_Str",_address);
        websocket.writeTextFrame(msg.encode());
        _websocket=websocket;
        websocket.dataHandler(new Handler<Buffer>(){
          @Override public void handle(          Buffer buff){
            String msg=buff.toString();
            JsonObject received=new JsonObject(msg);
            if (_buffer == null) {
              _buffer=new ArrayList<StringToken>();
            }
synchronized (_buffer) {
              _buffer.add(new StringToken(received.getField("String_Node_Str").toString()));
            }
            try {
              getDirector().fireAtCurrentRealTime((Actor)subscribe.getContainer());
            }
 catch (            IllegalActionException e) {
              e.printStackTrace();
            }
          }
        }
);
      }
    }
);
    _client.exceptionHandler(new Handler<Throwable>(){
      @Override public void handle(      Throwable event){
        _exception=event;
        _vertx.cancelTimer(_periodicPing);
      }
    }
);
  }
}
Program: 72629
Project: 72629
Buggy source:
@Override public void handle(final Void event){
}

Fixed version (ground truth):
@Override public void handle(Throwable event){
  _exception=event;
  _vertx.cancelTimer(_periodicPing);
}
Program: 72630
Project: 72630
Buggy source:
/** 
 * Initialize verticle, create http client and open web socket to connect to event bus.
 */
@Override public void initialize(){
  _vertx=VertxFactory.newVertx();
  _client=_vertx.createHttpClient().setHost(_host).setPort(_port);
  _openWebSocket();
  _vertx.setPeriodic(1000,new Handler<Long>(){
    @Override public void handle(    Long timerID){
      JsonObject json=new JsonObject().putString("String_Node_Str","String_Node_Str");
      _websocket.writeTextFrame(json.encode());
    }
  }
);
}

Fixed version (ground truth):
/** 
 * Initialize verticle, create http client and open web socket to connect to event bus.
 * @throws IllegalActionException 
 */
@Override public void initialize() throws IllegalActionException {
  _exception=null;
  _vertx=VertxFactory.newVertx();
  _client=_vertx.createHttpClient().setHost(_host).setPort(_port);
  _openWebSocket();
  _periodicPing=_vertx.setPeriodic(1000,new Handler<Long>(){
    @Override public void handle(    Long timerID){
      JsonObject json=new JsonObject().putString("String_Node_Str","String_Node_Str");
      try {
        _sendTextFrame(json);
      }
 catch (      IllegalActionException e) {
        e.printStackTrace();
      }
    }
  }
);
}
Program: 72632
Project: 72632
Buggy source:
@Override public void fire() throws IllegalActionException {
  super.fire();
  for (int i=0; i < input.getWidth(); i++) {
    if (input.hasToken(i)) {
      input.get(i);
    }
    long time=(long)(_director.getModelTime().getDoubleValue() / _director.localClock.getTimeResolution()) + _director.getRealStartTimeMillis();
    output.send(0,new DateToken(time));
  }
}

Fixed version (ground truth):
/** 
 * Output a DateToken with a date that corresponds to the current model time.
 * @exception IllegalActionException Not thrown here. 
 */
@Override public void fire() throws IllegalActionException {
  super.fire();
  for (int channel=0; channel < input.getWidth(); channel++) {
    if (input.hasToken(channel)) {
      input.get(channel);
    }
    double modelTimeSinceStart=_director.getModelTime().getDoubleValue() - _director.getModelStartTime().getDoubleValue();
    long time=(long)(modelTimeSinceStart / _director.localClock.getTimeResolution()) + _director.getRealStartTimeMillis();
    output.send(channel,new DateToken(time));
  }
}
Program: 72635
Project: 72635
Buggy source:
/** 
 * Output all elements of a date if input has a date token.
 * @exception IllegalActionException If there is no director.
 */
@Override public void fire() throws IllegalActionException {
  super.fire();
  if (input.hasToken(0)) {
    Token token=input.get(0);
    if (token instanceof DateToken) {
      DateToken dateToken=(DateToken)token;
      year.send(0,new IntToken(dateToken.getYear()));
      month.send(0,new IntToken(dateToken.getMonth()));
      day.send(0,new IntToken(dateToken.getDay()));
      hour.send(0,new IntToken(dateToken.getHour()));
      minute.send(0,new IntToken(dateToken.getMinute()));
      second.send(0,new IntToken(dateToken.getSecond()));
      millisecond.send(0,new IntToken(dateToken.getMillisecond()));
      microsecond.send(0,new IntToken(dateToken.getMicrosecond()));
      nanosecond.send(0,new IntToken(dateToken.getNanosecond()));
      timezone.send(0,new StringToken(dateToken.getTimezoneID()));
      timeInMillis.send(0,new LongToken(dateToken.getCalendarInstance().getTimeInMillis()));
    }
  }
}

Fixed version (ground truth):
/** 
 * Output all elements of a date if input has a date token.
 * @exception IllegalActionException If there is no director.
 */
@Override public void fire() throws IllegalActionException {
  super.fire();
  if (input.hasToken(0)) {
    Token token=input.get(0);
    if (token instanceof DateToken) {
      DateToken dateToken=(DateToken)token;
      year.send(0,new IntToken(dateToken.getYear()));
      month.send(0,new IntToken(dateToken.getMonth()));
      day.send(0,new IntToken(dateToken.getDay()));
      hour.send(0,new IntToken(dateToken.getHour()));
      minute.send(0,new IntToken(dateToken.getMinute()));
      second.send(0,new IntToken(dateToken.getSecond()));
      millisecond.send(0,new IntToken(dateToken.getMillisecond()));
      microsecond.send(0,new IntToken(dateToken.getMicrosecond()));
      nanosecond.send(0,new IntToken(dateToken.getNanosecond()));
      SimpleDateFormat sdf=new SimpleDateFormat("String_Node_Str");
      sdf.setTimeZone(dateToken.getTimeZone());
      timezone.send(0,new StringToken(sdf.format(dateToken.getCalendarInstance().getTime())));
      timeInMillis.send(0,new LongToken(dateToken.getCalendarInstance().getTimeInMillis()));
    }
  }
}
Program: 72637
Project: 72637
Buggy source:
/** 
 * Wrap up, close web socket if open, stop vertx.
 */
@Override public synchronized void wrapup() throws IllegalActionException {
  super.wrapup();
  if (_websocket != null) {
    _websocket.close();
  }
  if (_client != null) {
    _client.close();
  }
  _vertx.stop();
}

Fixed version (ground truth):
/** 
 * Wrap up, close web socket if open, stop vertx.
 */
@Override public synchronized void wrapup() throws IllegalActionException {
  super.wrapup();
  _vertx.cancelTimer(_periodicPing);
  _vertx.stop();
}
Program: 72638
Project: 72638
Buggy source:
/** 
 * Initialize verticle, create http client and open web socket to connect to event bus.
 * @throws IllegalActionException 
 */
@Override public void initialize() throws IllegalActionException {
  _exception=null;
  _vertx=VertxFactory.newVertx();
  _client=_vertx.createHttpClient().setHost(_host).setPort(_port);
  _openWebSocket();
  _periodicPing=_vertx.setPeriodic(1000,new Handler<Long>(){
    @Override public void handle(    Long timerID){
      JsonObject json=new JsonObject().putString("String_Node_Str","String_Node_Str");
      try {
        _sendTextFrame(json);
      }
 catch (      IllegalActionException e) {
        e.printStackTrace();
      }
    }
  }
);
}

Fixed version (ground truth):
/** 
 * Initialize verticle, create http client and open web socket to connect to event bus.
 * @throws IllegalActionException 
 */
@Override public void initialize() throws IllegalActionException {
  _exception=null;
  _vertx=VertxFactory.newVertx();
  _client=_vertx.createHttpClient().setHost(_host).setPort(_port);
  _openWebSocket();
  _periodicPing=_vertx.setPeriodic(1000,new Handler<Long>(){
    @Override public void handle(    Long timerID){
      JsonObject json=new JsonObject().putString("String_Node_Str","String_Node_Str");
      try {
        _sendTextFrame(json);
      }
 catch (      IllegalActionException e) {
        _exception=e;
      }
    }
  }
);
}
Program: 72640
Project: 72640
Buggy source:
/** 
 * Clone the actor.
 * @param workspace The workspace in which to place the cloned attribute.
 * @return The cloned attribute.
 * @exception CloneNotSupportedException Not thrown in this base class.
 * @see java.lang.Object#clone()
 */
@Override public Object clone(Workspace workspace) throws CloneNotSupportedException {
  WebSocketReader newObject=(WebSocketReader)super.clone(workspace);
  newObject._connection=null;
  newObject._connectionManager=_connectionManager;
  newObject._initializeModelTime=null;
  newObject._initializeRealTime=0L;
  newObject._isLocal=false;
  newObject._isShared=true;
  newObject._message=null;
  newObject._URIpath=null;
  return newObject;
}

Fixed version (ground truth):
/** 
 * Clone the actor.
 * @param workspace The workspace in which to place the cloned attribute.
 * @return The cloned attribute.
 * @exception CloneNotSupportedException Not thrown in this base class.
 * @see java.lang.Object#clone()
 */
@Override public Object clone(Workspace workspace) throws CloneNotSupportedException {
  WebSocketReader newObject=(WebSocketReader)super.clone(workspace);
  newObject._connection=null;
  newObject._connectionManager=WebSocketConnectionManager.getInstance();
  newObject._initializeModelTime=null;
  newObject._initializeRealTime=0L;
  newObject._isLocal=false;
  newObject._isShared=true;
  newObject._message=null;
  newObject._URIpath=null;
  return newObject;
}
Program: 72641
Project: 72641
Buggy source:
/** 
 * Clone the actor.
 * @param workspace The workspace in which to place the cloned attribute.
 * @return The cloned attribute.
 * @exception CloneNotSupportedException Not thrown in this base class.
 * @see java.lang.Object#clone()
 */
@Override public Object clone(Workspace workspace) throws CloneNotSupportedException {
  WebSocketWriter newObject=(WebSocketWriter)super.clone(workspace);
  newObject._connection=null;
  newObject._connectionManager=_connectionManager;
  newObject._connectionMonitor=new Object();
  newObject._connectionTimeout=5000;
  newObject._isLocal=false;
  newObject._isShared=true;
  newObject._URIpath=null;
  return newObject;
}

Fixed version (ground truth):
/** 
 * Clone the actor.
 * @param workspace The workspace in which to place the cloned attribute.
 * @return The cloned attribute.
 * @exception CloneNotSupportedException Not thrown in this base class.
 * @see java.lang.Object#clone()
 */
@Override public Object clone(Workspace workspace) throws CloneNotSupportedException {
  WebSocketWriter newObject=(WebSocketWriter)super.clone(workspace);
  newObject._connection=null;
  newObject._connectionManager=WebSocketConnectionManager.getInstance();
  newObject._connectionMonitor=new Object();
  newObject._connectionTimeout=5000;
  newObject._isLocal=false;
  newObject._isShared=true;
  newObject._URIpath=null;
  return newObject;
}
Program: 72643
Project: 72643
Buggy source:
/** 
 * Create a Factor Oracle to be used within the hierarchical FO that is used for generation of improvised jazz "licks".
 * @param trainingSequence the training sequence
 * @param repetitionFactor the repetition factor on the forward links
 * @param pitch boolean indicating a pitch oracle
 * @param validate boolean indicating whether the pitches should be validated
 * @return A controller to be used in the top level hierarchical FO
 * @throws IllegalActionException If the modal model isincompatible with the controller.
 * @throws NameDuplicationException If the name of the controllercollides with a name already in the container.
 */
protected FactorOracle _createController(Object[] trainingSequence,double repetitionFactor,boolean pitch,boolean validate) throws IllegalActionException, NameDuplicationException {
  return new FactorOracle(this,"String_Node_Str",trainingSequence,repetitionFactor,pitch,validate);
}

Fixed version (ground truth):
/** 
 * Create a Factor Oracle to be used within the hierarchical FO that is used for generation of improvised jazz "licks".
 * @param trainingSequence the training sequence
 * @param repetitionFactor the repetition factor on the forward links
 * @param pitch boolean indicating a pitch oracle
 * @param validate boolean indicating whether the pitches should be validated
 * @return A controller to be used in the top level hierarchical FO
 * @exception IllegalActionException If the modal model isincompatible with the controller.
 * @exception NameDuplicationException If the name of the controllercollides with a name already in the container.
 */
protected FactorOracle _createController(Object[] trainingSequence,double repetitionFactor,boolean pitch,boolean validate) throws IllegalActionException, NameDuplicationException {
  return new FactorOracle(this,"String_Node_Str",trainingSequence,repetitionFactor,pitch,validate);
}
Program: 72644
Project: 72644
Buggy source:
/** 
 * Constructs a FactorOracleTop object.
 * @param workspace         The workspace.
 * @param trainingSequence  The training sequence as an Object array.
 * @param repetitionFactor  a double indicating the repetition factor on the forward links.
 * @param pitch             a boolean -- true if music pitch specifications are being used.
 * @param validate          a boolean -- true if pitches are subject to validation.
 * @throws NameDuplicationException ...
 * @throws IllegalActionException ...
 */
public FactorOracleTop(Workspace workspace,Object[] trainingSequence,double repetitionFactor,boolean pitch,boolean validate) throws NameDuplicationException, IllegalActionException {
  super(workspace);
  _init(trainingSequence,repetitionFactor,pitch,validate);
}

Fixed version (ground truth):
/** 
 * Constructs a FactorOracleTop object.
 * @param workspace         The workspace.
 * @param trainingSequence  The training sequence as an Object array.
 * @param repetitionFactor  a double indicating the repetition factor on the forward links.
 * @param pitch             a boolean -- true if music pitch specifications are being used.
 * @param validate          a boolean -- true if pitches are subject to validation.
 * @exception NameDuplicationException ...
 * @exception IllegalActionException ...
 */
public FactorOracleTop(Workspace workspace,Object[] trainingSequence,double repetitionFactor,boolean pitch,boolean validate) throws NameDuplicationException, IllegalActionException {
  super(workspace);
  _init(trainingSequence,repetitionFactor,pitch,validate);
}
Program: 72645
Project: 72645
Buggy source:
/** 
 * Construct an actor with the given container and name.
 * @param container The container.
 * @param name The name of this actor
 * @throws NameDuplicationException
 * @throws IllegalActionException
 */
public NoteParser(CompositeEntity container,String name) throws NameDuplicationException, IllegalActionException {
  super(container,name);
  freq=new TypedIOPort(this,"String_Node_Str",true,false);
  freq.setTypeEquals(BaseType.DOUBLE);
  dur=new TypedIOPort(this,"String_Node_Str",true,false);
  dur.setTypeEquals(BaseType.DOUBLE);
  timestamp=new TypedIOPort(this,"String_Node_Str",true,false);
  timestamp.setTypeEquals(BaseType.INT);
  resetFO=new TypedIOPort(this,"String_Node_Str",true,false);
  resetFO.setTypeEquals(BaseType.DOUBLE);
  notes=new TypedIOPort(this,"String_Node_Str",false,true);
  notes.setTypeEquals(BaseType.OBJECT);
  replicationProbability=new TypedIOPort(this,"String_Node_Str",false,true);
  replicationProbability.setTypeEquals(BaseType.DOUBLE);
  bars=new TypedIOPort(this,"String_Node_Str",false,true);
  bars.setTypeEquals(BaseType.DOUBLE);
  StringAttribute cardinality=new StringAttribute(bars,"String_Node_Str");
  cardinality.setExpression("String_Node_Str");
  endTraining=new TypedIOPort(this,"String_Node_Str",true,false);
  endTraining.setTypeEquals(BaseType.INT);
  _durations=new LinkedList<Double>();
  _orderedNotes=new HashMap<Integer,Note>();
  _notes=new LinkedList<Double>();
  _timestamps=new LinkedList<Integer>();
  _terminate=false;
  _terminateLength=0;
}

Fixed version (ground truth):
/** 
 * Construct an actor with the given container and name.
 * @param container The container.
 * @param name The name of this actor
 * @exception NameDuplicationException
 * @exception IllegalActionException
 */
public NoteParser(CompositeEntity container,String name) throws NameDuplicationException, IllegalActionException {
  super(container,name);
  freq=new TypedIOPort(this,"String_Node_Str",true,false);
  freq.setTypeEquals(BaseType.DOUBLE);
  dur=new TypedIOPort(this,"String_Node_Str",true,false);
  dur.setTypeEquals(BaseType.DOUBLE);
  timestamp=new TypedIOPort(this,"String_Node_Str",true,false);
  timestamp.setTypeEquals(BaseType.INT);
  resetFO=new TypedIOPort(this,"String_Node_Str",true,false);
  resetFO.setTypeEquals(BaseType.DOUBLE);
  notes=new TypedIOPort(this,"String_Node_Str",false,true);
  notes.setTypeEquals(BaseType.OBJECT);
  replicationProbability=new TypedIOPort(this,"String_Node_Str",false,true);
  replicationProbability.setTypeEquals(BaseType.DOUBLE);
  bars=new TypedIOPort(this,"String_Node_Str",false,true);
  bars.setTypeEquals(BaseType.DOUBLE);
  StringAttribute cardinality=new StringAttribute(bars,"String_Node_Str");
  cardinality.setExpression("String_Node_Str");
  endTraining=new TypedIOPort(this,"String_Node_Str",true,false);
  endTraining.setTypeEquals(BaseType.INT);
  _durations=new LinkedList<Double>();
  _orderedNotes=new HashMap<Integer,Note>();
  _notes=new LinkedList<Double>();
  _timestamps=new LinkedList<Integer>();
  _terminate=false;
  _terminateLength=0;
}
Program: 72646
Project: 72646
Buggy source:
/** 
 * Create a Factor Oracle controller
 * @param trainingSequence
 * @param repetitionFactor
 * @param pitch
 * @param validate
 * @return
 * @throws IllegalActionException
 * @throws NameDuplicationException
 */
protected FactorOracle _createController(Object[] trainingSequence,double repetitionFactor,boolean pitch,boolean validate) throws IllegalActionException, NameDuplicationException {
  return new FactorOracle(this,"String_Node_Str",trainingSequence,repetitionFactor,pitch,validate);
}

Fixed version (ground truth):
/** 
 * Create a Factor Oracle controller
 * @param trainingSequence
 * @param repetitionFactor
 * @param pitch
 * @param validate
 * @return
 * @exception IllegalActionException
 * @exception NameDuplicationException
 */
protected FactorOracle _createController(Object[] trainingSequence,double repetitionFactor,boolean pitch,boolean validate) throws IllegalActionException, NameDuplicationException {
  return new FactorOracle(this,"String_Node_Str",trainingSequence,repetitionFactor,pitch,validate);
}
Program: 72647
Project: 72647
Buggy source:
/** 
 * Return the probability mass function P(x=k) ~ Poisson(mean) value at k, for the poisson distribution with parameter mean
 * @param k The value at which the probability mass function will be computed
 * @param mean The mean (lambda) of the poisson distribution
 * @return The PMF value at k.
 * @throws IllegalActionException
 * @exception Exception If k < 0
 */
public static double poissonPmf(int k,double mean,double logFactorial) throws IllegalActionException {
  if (k < 0) {
    throw new IllegalActionException("String_Node_Str");
  }
  double logTerm=-mean + k * Math.log(mean) - logFactorial;
  return Math.exp(logTerm);
}

Fixed version (ground truth):
/** 
 * Return the probability mass function P(x=k) ~ Poisson(mean) value at k, for the poisson distribution with parameter mean
 * @param k The value at which the probability mass function will be computed
 * @param mean The mean (lambda) of the poisson distribution
 * @return The PMF value at k.
 * @exception IllegalActionException
 * @exception Exception If k < 0
 */
public static double poissonPmf(int k,double mean,double logFactorial) throws IllegalActionException {
  if (k < 0) {
    throw new IllegalActionException("String_Node_Str");
  }
  double logTerm=-mean + k * Math.log(mean) - logFactorial;
  return Math.exp(logTerm);
}
Program: 72648
Project: 72648
Buggy source:
/** 
 * Initialize arrays to be used in parameter estimation
 * @throws IllegalActionException
 */
protected void _initializeArrays() throws IllegalActionException {
  _likelihood=0.0;
  _nStates=((IntToken)nStates.getToken()).intValue();
  _transitionMatrix=new double[_nStates][_nStates];
  _A0=new double[_nStates][_nStates];
  _priors=new double[_nStates];
}

Fixed version (ground truth):
/** 
 * Initialize arrays to be used in parameter estimation
 * @exception IllegalActionException
 */
protected void _initializeArrays() throws IllegalActionException {
  _likelihood=0.0;
  _nStates=((IntToken)nStates.getToken()).intValue();
  _transitionMatrix=new double[_nStates][_nStates];
  _A0=new double[_nStates][_nStates];
  _priors=new double[_nStates];
}
Program: 72649
Project: 72649
Buggy source:
/** 
 * Expectation-Maximization, which internally executes a gradient-descent algorithm for parameter estimation.
 * @return whether parameter estimation has succeded
 * @throws IllegalActionException
 */
protected boolean _EMParameterEstimation() throws IllegalActionException {
  boolean success=false;
  _initializeEMParameters();
  for (int iterations=0; iterations < _nIterations; iterations++) {
    _iterateEM();
    success=_checkForConvergence(iterations);
    if (!_randomize && !success) {
      break;
    }
    _updateEstimates();
    if (Math.abs(likelihood - _likelihood) < _likelihoodThreshold) {
      break;
    }
 else {
      _likelihood=likelihood;
    }
  }
  return success;
}

Fixed version (ground truth):
/** 
 * Expectation-Maximization, which internally executes a gradient-descent algorithm for parameter estimation.
 * @return whether parameter estimation has succeded
 * @exception IllegalActionException
 */
protected boolean _EMParameterEstimation() throws IllegalActionException {
  boolean success=false;
  _initializeEMParameters();
  for (int iterations=0; iterations < _nIterations; iterations++) {
    _iterateEM();
    success=_checkForConvergence(iterations);
    if (!_randomize && !success) {
      break;
    }
    _updateEstimates();
    if (Math.abs(likelihood - _likelihood) < _likelihoodThreshold) {
      break;
    }
 else {
      _likelihood=likelihood;
    }
  }
  return success;
}
Program: 72650
Project: 72650
Buggy source:
/** 
 * Check whether the gradient-descent algorithm has converged
 * @param i Current iteration index
 * @return boolean indicating whether algorithm has converged
 * @throws IllegalActionException
 */
protected abstract boolean _checkForConvergence(int i) throws IllegalActionException ;

Fixed version (ground truth):
/** 
 * Check whether the gradient-descent algorithm has converged
 * @param i Current iteration index
 * @return boolean indicating whether algorithm has converged
 * @exception IllegalActionException
 */
protected abstract boolean _checkForConvergence(int i) throws IllegalActionException ;
Program: 72651
Project: 72651
Buggy source:
/** 
 * Constructs a MutualInformationCalculator object.
 * @param workspace The workspace
 * @throws IllegalActionException
 * @throws NameDuplicationException
 */
public MutualInformationCalculator(Workspace workspace) throws IllegalActionException, NameDuplicationException {
  super(workspace);
  _init();
}

Fixed version (ground truth):
/** 
 * Constructs a MutualInformationCalculator object.
 * @param workspace The workspace
 * @exception IllegalActionException
 * @exception NameDuplicationException
 */
public MutualInformationCalculator(Workspace workspace) throws IllegalActionException, NameDuplicationException {
  super(workspace);
  _init();
}
Program: 72652
Project: 72652
Buggy source:
@Override public int getTypeHash(){
  return 15;
}

Fixed version (ground truth):
@Override public int getTypeHash(){
  return 16;
}
Program: 72653
Project: 72653
Buggy source:
/** 
 * Open a web socket that serves as a connection to the event bus.
 */
private void _openWebSocket(){
  MultiMap map=new CaseInsensitiveMultiMap();
  map.add("String_Node_Str","String_Node_Str");
  _client.connectWebsocket("String_Node_Str",WebSocketVersion.RFC6455,map,new Handler<WebSocket>(){
    @Override public void handle(    WebSocket websocket){
      JsonObject msg=new JsonObject().putString("String_Node_Str","String_Node_Str").putString("String_Node_Str",_address);
      websocket.writeTextFrame(msg.encode());
      _websocket=websocket;
      websocket.dataHandler(new Handler<Buffer>(){
        @Override public void handle(        Buffer buff){
          String msg=buff.toString();
          JsonObject received=new JsonObject(msg);
          try {
            subscribe.send(0,new StringToken(received.getField("String_Node_Str")));
          }
 catch (          NoRoomException e) {
            e.printStackTrace();
          }
catch (          IllegalActionException e) {
            e.printStackTrace();
          }
        }
      }
);
      _websocket.closeHandler(new Handler<Void>(){
        @Override public void handle(        final Void event){
          _openWebSocket();
        }
      }
);
    }
  }
);
}

Fixed version (ground truth):
/** 
 * Open a web socket that serves as a connection to the event bus.
 */
private void _openWebSocket(){
  MultiMap map=new CaseInsensitiveMultiMap();
  map.add("String_Node_Str","String_Node_Str");
  _client.connectWebsocket("String_Node_Str",WebSocketVersion.RFC6455,map,new Handler<WebSocket>(){
    @Override public void handle(    WebSocket websocket){
      JsonObject msg=new JsonObject().putString("String_Node_Str","String_Node_Str").putString("String_Node_Str",_address);
      websocket.writeTextFrame(msg.encode());
      _websocket=websocket;
      websocket.dataHandler(new Handler<Buffer>(){
        @Override public void handle(        Buffer buff){
          String msg=buff.toString();
          JsonObject received=new JsonObject(msg);
          try {
            subscribe.send(0,new StringToken(received.getField("String_Node_Str").toString()));
          }
 catch (          NoRoomException e) {
            e.printStackTrace();
          }
catch (          IllegalActionException e) {
            e.printStackTrace();
          }
        }
      }
);
      _websocket.closeHandler(new Handler<Void>(){
        @Override public void handle(        final Void event){
          _openWebSocket();
        }
      }
);
    }
  }
);
}
Program: 72656
Project: 72656
Buggy source:
@Override public void fire() throws IllegalActionException {
  super.fire();
  if (particles.hasToken(0)) {
    ArrayToken incoming=(ArrayToken)particles.get(0);
    N=incoming.length();
    if (_px.length == 0) {
      _px=new double[N];
      _py=new double[N];
      _weights=new double[incoming.length()];
    }
    for (int i=0; i < incoming.length(); i++) {
      RecordToken token=(RecordToken)incoming.getElement(i);
      for (int k=0; k < _labels.length; k++) {
        if (_labels[k].equals("String_Node_Str")) {
          _weights[i]=((DoubleToken)token.get(_labels[k])).doubleValue();
        }
      }
      _px[i]=((DoubleToken)token.get(_labels[0])).doubleValue();
      _py[i]=((DoubleToken)token.get(_labels[1])).doubleValue();
    }
    double wsum=0;
    for (int i=0; i < N; i++) {
      wsum+=_weights[i];
    }
    for (int i=0; i < N; i++) {
      _weights[i]/=wsum;
    }
  }
  if (locations.hasToken(0)) {
    ArrayToken robotLocations=(ArrayToken)locations.get(0);
    _nRobots=robotLocations.length();
    _robotLocations.clear();
    for (int i=0; i < _nRobots; i++) {
      RecordToken robotLocation=(RecordToken)robotLocations.getElement(i);
      _robotLocations.add(robotLocation);
    }
  }
  if (xValue.hasToken(0)) {
    ArrayToken xArray=((ArrayToken)xValue.get(0));
    _xValue=new double[xArray.length()];
    for (int i=0; i < xArray.length(); i++) {
      _xValue[i]=((DoubleToken)xArray.getElement(i)).doubleValue();
    }
  }
  output.send(0,new DoubleToken(Hz(_xValue)));
}

Fixed version (ground truth):
@Override public void fire() throws IllegalActionException {
  super.fire();
  if (particles.hasToken(0)) {
    ArrayToken incoming=(ArrayToken)particles.get(0);
    N=incoming.length();
    _weights=new double[N];
    if (_px.length == 0) {
      _px=new double[N];
      _py=new double[N];
      _weights=new double[N];
    }
    for (int i=0; i < N; i++) {
      RecordToken token=(RecordToken)incoming.getElement(i);
      for (int k=0; k < _labels.length; k++) {
        if (_labels[k].equals("String_Node_Str")) {
          _weights[i]=((DoubleToken)token.get(_labels[k])).doubleValue();
        }
      }
      _px[i]=((DoubleToken)token.get(_labels[0])).doubleValue();
      _py[i]=((DoubleToken)token.get(_labels[1])).doubleValue();
    }
    double wsum=0;
    for (int i=0; i < N; i++) {
      wsum+=_weights[i];
    }
    for (int i=0; i < N; i++) {
      _weights[i]/=wsum;
    }
  }
  if (locations.hasToken(0)) {
    ArrayToken robotLocations=(ArrayToken)locations.get(0);
    _nRobots=robotLocations.length();
    _robotLocations.clear();
    for (int i=0; i < _nRobots; i++) {
      RecordToken robotLocation=(RecordToken)robotLocations.getElement(i);
      _robotLocations.add(robotLocation);
    }
  }
  if (xValue.hasToken(0)) {
    ArrayToken xArray=((ArrayToken)xValue.get(0));
    _xValue=new double[xArray.length()];
    for (int i=0; i < xArray.length(); i++) {
      _xValue[i]=((DoubleToken)xArray.getElement(i)).doubleValue();
    }
  }
  output.send(0,new DoubleToken(Hz(_xValue)));
}
Program: 72657
Project: 72657
Buggy source:
public MutualInformationCalculator(CompositeEntity container,String name) throws IllegalActionException, NameDuplicationException {
  super(container,name);
  optIndex=new Parameter(this,"String_Node_Str");
  optIndex.setExpression("String_Node_Str");
  optIndex.setTypeEquals(BaseType.INT);
  _optIndex=-1;
  timeHorizon=new Parameter(this,"String_Node_Str");
  timeHorizon.setExpression("String_Node_Str");
  timeHorizon.setTypeEquals(BaseType.INT);
  xValue=new TypedIOPort(this,"String_Node_Str",true,false);
  xValue.setTypeEquals(new ArrayType(BaseType.DOUBLE));
  particles=new TypedIOPort(this,"String_Node_Str",true,false);
  ArrayToken names=new ArrayToken("String_Node_Str");
  String stateName;
  _labels=new String[names.length() + 1];
  _types=new Type[names.length() + 1];
  try {
    for (int i=0; i < names.length(); i++) {
      stateName=((StringToken)names.getElement(i)).stringValue();
      if (this.getAttribute(stateName) == null && stateName.length() != 0) {
        Parameter y=new Parameter(this,stateName);
        y.setExpression("String_Node_Str");
        y.setVisibility(Settable.EXPERT);
      }
      _labels[i]=stateName;
    }
    _labels[names.length()]="String_Node_Str";
    _types[names.length()]=BaseType.DOUBLE;
    particles.setTypeEquals(new ArrayType(new RecordType(_labels,_types)));
  }
 catch (  NameDuplicationException e) {
    System.err.println("String_Node_Str" + this.getName());
  }
  _px=new double[0];
  _py=new double[0];
  _weights=new double[0];
  locations=new TypedIOPort(this,"String_Node_Str",true,false);
  _robotLocations=new LinkedList<RecordToken>();
  output=new TypedIOPort(this,"String_Node_Str",false,true);
  output.setTypeEquals(BaseType.DOUBLE);
  _covariance=2.0;
}

Fixed version (ground truth):
/** 
 * Constructs a MutualInformationCalculator object.
 * @param workspace The workspace
 * @throws IllegalActionException 
 * @throws NameDuplicationException 
 */
public MutualInformationCalculator(Workspace workspace) throws IllegalActionException, NameDuplicationException {
  super(workspace);
  _init();
}
Program: 72660
Project: 72660
Buggy source:
private void _processMessage(Object[] message,String address){
synchronized (_receivedTokens) {
    String[] addressBits=address.split("String_Node_Str");
    if (addressBits != null) {
      String identifier=addressBits[addressBits.length - 1];
      if (identifier.length() > 0) {
        List<Object> tokenList;
        if (_receivedTokens.containsKey(identifier)) {
          tokenList=_receivedTokens.get(identifier);
        }
 else {
          tokenList=new LinkedList<Object>();
        }
        for (int i=0; i < message.length; i++) {
          Object b=message[i];
          if (b instanceof Double) {
            tokenList.add((Double)b);
          }
 else           if (b instanceof Integer) {
            tokenList.add((Integer)b);
          }
 else           if (b instanceof String) {
            tokenList.add((String)b);
          }
 else           if (b instanceof Float) {
            tokenList.add((Float)b);
          }
 else {
            tokenList.add(b);
          }
        }
        _receivedTokens.put(identifier,tokenList);
      }
    }
  }
}

Fixed version (ground truth):
private void _processMessage(Object[] message,String address){
  String[] addressBits=address.split("String_Node_Str");
  if (addressBits != null) {
    String identifier=addressBits[addressBits.length - 1];
    if (identifier.length() > 0) {
      List<Object> tokenList;
      if (_receivedTokens.containsKey(identifier)) {
        tokenList=_receivedTokens.get(identifier);
      }
 else {
        tokenList=new LinkedList<Object>();
      }
      for (int i=0; i < message.length; i++) {
        Object b=message[i];
        if (b instanceof Double) {
          tokenList.add((Double)b);
        }
 else         if (b instanceof Integer) {
          tokenList.add((Integer)b);
        }
 else         if (b instanceof String) {
          tokenList.add((String)b);
        }
 else         if (b instanceof Float) {
          tokenList.add((Float)b);
        }
 else {
          tokenList.add(b);
        }
      }
      _receivedTokens.put(identifier,tokenList);
    }
  }
}
Program: 72662
Project: 72662
Buggy source:
public void oscEvent(OscMessage theMessage){
synchronized (this) {
    try {
      Object[] receivedData=theMessage.arguments();
      String addressPattern=theMessage.addrPattern();
      _processMessage(receivedData,addressPattern);
      getDirector().fireAtCurrentTime(this);
    }
 catch (    IllegalActionException e) {
      System.err.println("String_Node_Str" + theMessage.toString());
    }
  }
}

Fixed version (ground truth):
public void oscEvent(OscMessage theMessage){
  try {
    Object[] receivedData=theMessage.arguments();
    String addressPattern=theMessage.addrPattern();
    _processMessage(receivedData,addressPattern);
    getDirector().fireAtCurrentTime(this);
  }
 catch (  IllegalActionException e) {
    System.err.println("String_Node_Str" + theMessage.toString());
  }
}
Program: 72663
Project: 72663
Buggy source:
private void _sendOscPackets(HashMap<String,Object> tokenMap) throws IllegalActionException {
  myRemoteLocation=new NetAddress(_host,_remotePort);
  OscBundle bundle=new OscBundle();
  String prefix=((StringToken)tagPrefix.getToken()).stringValue();
  if (!prefix.equals("String_Node_Str") && !prefix.startsWith("String_Node_Str")) {
    prefix="String_Node_Str" + prefix;
  }
  for (  String label : tokenMap.keySet()) {
    OscMessage m=new OscMessage(prefix + "String_Node_Str" + label);
    Object o=tokenMap.get(label);
    if (o instanceof Double) {
      m.add((Double)o);
    }
 else     if (o instanceof Integer) {
      m.add((Integer)o);
    }
 else     if (o instanceof String) {
      m.add((String)o);
    }
 else {
      throw new IllegalActionException("String_Node_Str" + "String_Node_Str");
    }
    bundle.add(m);
    m.print();
  }
  oscP5.send(bundle,myRemoteLocation);
  tokenMap.clear();
}

Fixed version (ground truth):
private void _sendOscPackets(HashMap<String,Object> tokenMap) throws IllegalActionException {
  myRemoteLocation=new NetAddress(_host,_remotePort);
  OscBundle bundle=new OscBundle();
  String prefix=((StringToken)tagPrefix.getToken()).stringValue();
  if (!prefix.equals("String_Node_Str") && !prefix.startsWith("String_Node_Str")) {
    prefix="String_Node_Str" + prefix;
  }
  for (  Map.Entry<String,Object> entry : tokenMap.entrySet()) {
    String label=entry.getKey();
    Object o=entry.getValue();
    OscMessage m=new OscMessage(prefix + "String_Node_Str" + label);
    if (o instanceof Double) {
      m.add((Double)o);
    }
 else     if (o instanceof Integer) {
      m.add((Integer)o);
    }
 else     if (o instanceof String) {
      m.add((String)o);
    }
 else {
      throw new IllegalActionException("String_Node_Str" + "String_Node_Str");
    }
    bundle.add(m);
  }
  oscP5.send(bundle,myRemoteLocation);
  tokenMap.clear();
}