nus-yam/ex-repair huggingface dataset:
Program: 149395
Project: 149395
Buggy source:
@Override public Future<?> disconnect(OfflineCause cause){
  boolean online=isOnline();
  boolean terminateNow=false;
  if (cause instanceof OfflineCause.SimpleOfflineCause && ((OfflineCause.SimpleOfflineCause)cause).description.toString().equals(Messages._Hudson_NodeBeingRemoved().toString())) {
    try {
      LOGGER.info(MessageFormat.format("String_Node_Str",slave.getNodeName(),slave.getInstancePageUrl()));
    }
 catch (    IOException ex) {
      LOGGER.info(MessageFormat.format("String_Node_Str",slave.getNodeName(),ex.getMessage()));
    }
    for (    LabelAtom label : ElasticBoxLabelFinder.INSTANCE.findLabels(slave)) {
      for (      NodeProvisioner.PlannedNode plannedNode : label.nodeProvisioner.getPendingLaunches()) {
        if (plannedNode.displayName.equals(slave.getNodeName())) {
          plannedNode.future.cancel(false);
        }
      }
    }
    if (online) {
      terminateOnOffline=true;
    }
 else {
      terminateNow=true;
    }
  }
  Future<?> future=super.disconnect(cause);
  if (terminateNow) {
    terminate();
  }
  return future;
}

Fixed version (ground truth):
@Override public Future<?> disconnect(OfflineCause cause){
  boolean online=isOnline();
  boolean terminateNow=false;
  if (isSlaveRemoved(cause)) {
    try {
      LOGGER.info(MessageFormat.format("String_Node_Str",slave.getNodeName(),slave.getInstancePageUrl()));
    }
 catch (    IOException ex) {
      LOGGER.info(MessageFormat.format("String_Node_Str",slave.getNodeName(),ex.getMessage()));
    }
    for (    LabelAtom label : ElasticBoxLabelFinder.INSTANCE.findLabels(slave)) {
      for (      NodeProvisioner.PlannedNode plannedNode : label.nodeProvisioner.getPendingLaunches()) {
        if (plannedNode.displayName.equals(slave.getNodeName())) {
          plannedNode.future.cancel(false);
        }
      }
    }
    if (online) {
      terminateOnOffline=true;
    }
 else {
      terminateNow=true;
    }
  }
  Future<?> future=super.disconnect(cause);
  if (terminateNow) {
    terminate();
  }
  return future;
}
Program: 149396
Project: 149396
Buggy source:
private static void tagSlaveInstance(JSONObject instance,ElasticBoxSlave slave) throws IOException {
  if (instance.getJSONArray("String_Node_Str").contains(slave.getNodeName())) {
    return;
  }
  instance.getJSONArray("String_Node_Str").add(slave.getNodeName());
  Client client=ClientCache.getClient(slave.getCloud().name);
  client.updateInstance(instance,null);
  LOGGER.fine(MessageFormat.format("String_Node_Str",Client.getPageUrl(client.getEndpointUrl(),instance),slave.getNodeName()));
}

Fixed version (ground truth):
private static void tagSlaveInstance(JSONObject instance,ElasticBoxSlave slave) throws IOException {
  if (instance.getJSONArray("String_Node_Str").contains(slave.getNodeName())) {
    return;
  }
  instance.getJSONArray("String_Node_Str").add(slave.getNodeName());
  Client client=ClientCache.getClient(slave.getCloud().name);
  client.updateInstance(instance);
  LOGGER.fine(MessageFormat.format("String_Node_Str",Client.getPageUrl(client.getEndpointUrl(),instance),slave.getNodeName()));
}
Program: 149397
Project: 149397
Buggy source:
/** 
 * Collects inactive or invalid slaves that can be removed.
 * @param slavesToRemove a list to be filled with inactive or invalid slaves that can be removed
 * @return a list of slaves to remove
 * @throws IOException 
 */
private static List<ElasticBoxSlave> collectSlavesToRemove(SlaveInstanceManager slaveInstanceManager) throws IOException {
  List<ElasticBoxSlave> slavesToRemove=new ArrayList<ElasticBoxSlave>();
  Collection<ElasticBoxSlave> slaves=slaveInstanceManager.getSlaves();
  for (  ElasticBoxSlave slave : slaves) {
    if (!isSlaveInQueue(slave,incomingQueue) && !slave.isInUse()) {
      slavesToRemove.add(slave);
    }
  }
  for (  JSONObject instance : slaveInstanceManager.getInstances()) {
    String state=instance.getString("String_Node_Str");
    String instanceId=instance.getString("String_Node_Str");
    ElasticBoxSlave slave=slaveInstanceManager.getSlave(instanceId);
    if (Client.InstanceState.DONE.equals(state) && Client.TERMINATE_OPERATIONS.contains(instance.getString("String_Node_Str"))) {
      addToTerminatedQueue(slave);
    }
 else     if (Client.InstanceState.UNAVAILABLE.equals(state)) {
      Logger.getLogger(ElasticBoxSlaveHandler.class.getName()).log(Level.INFO,MessageFormat.format("String_Node_Str",slave.getInstancePageUrl()));
      slavesToRemove.add(slave);
    }
  }
  slavesToRemove.addAll(slaveInstanceManager.getSlavesWithoutInstance());
  return slavesToRemove;
}

Fixed version (ground truth):
/** 
 * Collects inactive or invalid slaves that can be removed.
 * @param slavesToRemove a list to be filled with inactive or invalid slaves that can be removed
 * @return a list of slaves to remove
 * @throws IOException 
 */
private static List<ElasticBoxSlave> collectSlavesToRemove(SlaveInstanceManager slaveInstanceManager) throws IOException {
  List<ElasticBoxSlave> slavesToRemove=new ArrayList<ElasticBoxSlave>();
  Collection<ElasticBoxSlave> slaves=slaveInstanceManager.getSlaves();
  for (  ElasticBoxSlave slave : slaves) {
    if (slave.isDeletable()) {
      slavesToRemove.add(slave);
    }
  }
  for (  JSONObject instance : slaveInstanceManager.getInstances()) {
    String state=instance.getString("String_Node_Str");
    String instanceId=instance.getString("String_Node_Str");
    ElasticBoxSlave slave=slaveInstanceManager.getSlave(instanceId);
    if (Client.InstanceState.DONE.equals(state) && Client.TERMINATE_OPERATIONS.contains(instance.getString("String_Node_Str"))) {
      addToTerminatedQueue(slave);
    }
 else     if (Client.InstanceState.UNAVAILABLE.equals(state)) {
      Logger.getLogger(ElasticBoxSlaveHandler.class.getName()).log(Level.INFO,MessageFormat.format("String_Node_Str",slave.getInstancePageUrl()));
      slavesToRemove.add(slave);
    }
  }
  slavesToRemove.addAll(slaveInstanceManager.getSlavesWithoutInstance());
  return slavesToRemove;
}
Program: 149398
Project: 149398
Buggy source:
private void processSubmittedQueue(TaskListener listener){
  boolean saveNeeded=false;
  for (Iterator<InstanceCreationRequest> iter=submittedQueue.iterator(); iter.hasNext(); ) {
    InstanceCreationRequest request=iter.next();
    try {
      if (request.monitor.isDone()) {
        tagSlaveInstance(request.slave.getInstance(),request.slave);
        if (request.slave.getComputer() != null && request.slave.getComputer().isOnline()) {
          request.slave.setInstanceStatusMessage(MessageFormat.format("String_Node_Str",request.slave.getInstancePageUrl()));
          saveNeeded=true;
          iter.remove();
        }
 else         if ((System.currentTimeMillis() - request.monitor.getCreationTime()) >= TIMEOUT) {
          request.slave.setInUse(false);
          iter.remove();
          log(Level.SEVERE,MessageFormat.format("String_Node_Str",request.slave.getNodeName(),TIMEOUT_MINUTES),null,listener);
        }
      }
    }
 catch (    IProgressMonitor.IncompleteException ex) {
      log(Level.SEVERE,ex.getMessage(),ex,listener);
      iter.remove();
    }
catch (    IOException ex) {
      log(Level.SEVERE,ex.getMessage(),ex,listener);
    }
  }
  if (saveNeeded) {
    try {
      Jenkins.getInstance().save();
    }
 catch (    IOException ex) {
      Logger.getLogger(ElasticBoxSlaveHandler.class.getName()).log(Level.SEVERE,"String_Node_Str",ex);
    }
  }
}

Fixed version (ground truth):
private void processSubmittedQueue(TaskListener listener){
  boolean saveNeeded=false;
  for (Iterator<InstanceCreationRequest> iter=submittedQueue.iterator(); iter.hasNext(); ) {
    InstanceCreationRequest request=iter.next();
    try {
      if (request.monitor.isDone()) {
        tagSlaveInstance(request.slave.getInstance(),request.slave);
        if (request.slave.getComputer() != null && request.slave.getComputer().isOnline()) {
          request.slave.setInstanceStatusMessage(MessageFormat.format("String_Node_Str",request.slave.getInstancePageUrl()));
          saveNeeded=true;
          iter.remove();
        }
 else {
          long launchTime=System.currentTimeMillis() - request.monitor.getCreationTime();
          if (launchTime >= TimeUnit.MINUTES.toMillis(request.slave.getLaunchTimeout())) {
            request.slave.setDeletable(true);
            iter.remove();
            log(Level.SEVERE,MessageFormat.format("String_Node_Str",request.slave.getNodeName(),TimeUnit.MILLISECONDS.toMinutes(launchTime)),null,listener);
          }
        }
      }
    }
 catch (    IProgressMonitor.IncompleteException ex) {
      log(Level.SEVERE,ex.getMessage(),ex,listener);
      iter.remove();
    }
catch (    IOException ex) {
      log(Level.SEVERE,ex.getMessage(),ex,listener);
    }
  }
  if (saveNeeded) {
    try {
      Jenkins.getInstance().save();
    }
 catch (    IOException ex) {
      Logger.getLogger(ElasticBoxSlaveHandler.class.getName()).log(Level.SEVERE,"String_Node_Str",ex);
    }
  }
}
Program: 149400
Project: 149400
Buggy source:
@Override public boolean tearDown(AbstractBuild build,BuildListener listener) throws IOException, InterruptedException {
  ebSlave.setInUse(false);
  if (ebSlave.isSingleUse()) {
    ebSlave.getComputer().setAcceptingTasks(false);
  }
  build.getProject().setAssignedLabel(null);
  return true;
}

Fixed version (ground truth):
@Override public boolean tearDown(AbstractBuild build,BuildListener listener) throws IOException, InterruptedException {
  if (ebSlave.isSingleUse()) {
    ebSlave.getComputer().setAcceptingTasks(false);
  }
  build.getProject().setAssignedLabel(null);
  return true;
}
Program: 149401
Project: 149401
Buggy source:
@Override public Environment setUp(AbstractBuild build,Launcher launcher,BuildListener listener) throws IOException, InterruptedException {
  for (  Node node : build.getProject().getAssignedLabel().getNodes()) {
    if (node instanceof ElasticBoxSlave) {
      ElasticBoxSlave slave=(ElasticBoxSlave)node;
      if (slave.getComputer().getBuilds().contains(build)) {
        ebSlave=slave;
        ebSlave.setInUse(true);
        break;
      }
    }
  }
  return new Environment(){
    @Override public boolean tearDown(    AbstractBuild build,    BuildListener listener) throws IOException, InterruptedException {
      ebSlave.setInUse(false);
      if (ebSlave.isSingleUse()) {
        ebSlave.getComputer().setAcceptingTasks(false);
      }
      build.getProject().setAssignedLabel(null);
      return true;
    }
  }
;
}

Fixed version (ground truth):
@Override public Environment setUp(AbstractBuild build,Launcher launcher,BuildListener listener) throws IOException, InterruptedException {
  for (  Node node : build.getProject().getAssignedLabel().getNodes()) {
    if (node instanceof ElasticBoxSlave) {
      ElasticBoxSlave slave=(ElasticBoxSlave)node;
      if (slave.getComputer().getBuilds().contains(build)) {
        ebSlave=slave;
        break;
      }
    }
  }
  return new Environment(){
    @Override public boolean tearDown(    AbstractBuild build,    BuildListener listener) throws IOException, InterruptedException {
      if (ebSlave.isSingleUse()) {
        ebSlave.getComputer().setAcceptingTasks(false);
      }
      build.getProject().setAssignedLabel(null);
      return true;
    }
  }
;
}
Program: 149403
Project: 149403
Buggy source:
@Override public Future<?> disconnect(OfflineCause cause){
  boolean online=isOnline();
  Future<?> future=super.disconnect(cause);
  if (cause instanceof OfflineCause.SimpleOfflineCause && ((OfflineCause.SimpleOfflineCause)cause).description.toString().equals(Messages._Hudson_NodeBeingRemoved().toString())) {
    for (    LabelAtom label : ElasticBoxLabelFinder.INSTANCE.findLabels(slave)) {
      for (      NodeProvisioner.PlannedNode plannedNode : label.nodeProvisioner.getPendingLaunches()) {
        if (plannedNode.displayName.equals(slave.getNodeName())) {
          plannedNode.future.cancel(false);
        }
      }
    }
    if (online) {
      terminateOnOffline=true;
    }
 else {
      terminate();
    }
  }
  return future;
}

Fixed version (ground truth):
@Override public Future<?> disconnect(OfflineCause cause){
  boolean online=isOnline();
  boolean terminateNow=false;
  if (cause instanceof OfflineCause.SimpleOfflineCause && ((OfflineCause.SimpleOfflineCause)cause).description.toString().equals(Messages._Hudson_NodeBeingRemoved().toString())) {
    for (    LabelAtom label : ElasticBoxLabelFinder.INSTANCE.findLabels(slave)) {
      for (      NodeProvisioner.PlannedNode plannedNode : label.nodeProvisioner.getPendingLaunches()) {
        if (plannedNode.displayName.equals(slave.getNodeName())) {
          plannedNode.future.cancel(false);
        }
      }
    }
    if (online) {
      terminateOnOffline=true;
    }
 else {
      terminateNow=true;
    }
  }
  Future<?> future=super.disconnect(cause);
  if (terminateNow) {
    terminate();
  }
  return future;
}
Program: 149404
Project: 149404
Buggy source:
BoxStack(String boxId,JSONArray boxes,Client client){
  this.boxId=boxId;
  this.boxes=boxes;
  this.client=client;
  overriddenVariables=new ArrayList<JSONObject>();
}

Fixed version (ground truth):
BoxStack(String boxId,JSONArray boxes,Client client,List<JSONObject> overridenVariables){
  this.boxId=boxId;
  this.boxes=boxes;
  this.client=client;
  this.overriddenVariables=overridenVariables;
}
Program: 149405
Project: 149405
Buggy source:
public IProgressMonitor poweron(String instanceId) throws IOException {
  String instanceUrl=getInstanceUrl(instanceId);
  HttpPut put=new HttpPut(MessageFormat.format("String_Node_Str",instanceUrl));
  try {
    execute(put);
    return new ProgressMonitor(instanceUrl,Collections.singleton(InstanceOperation.POWERON));
  }
  finally {
    put.reset();
  }
}

Fixed version (ground truth):
public IProgressMonitor poweron(String instanceId) throws IOException {
  String instanceUrl=getInstanceUrl(instanceId);
  JSONObject instance=(JSONObject)doGet(instanceUrl,false);
  HttpPut put=new HttpPut(MessageFormat.format("String_Node_Str",instanceUrl));
  try {
    execute(put);
    return new ProgressMonitor(instanceUrl,Collections.singleton(InstanceOperation.POWERON),instance.getString("String_Node_Str"));
  }
  finally {
    put.reset();
  }
}
Program: 149406
Project: 149406
Buggy source:
public IProgressMonitor reconfigure(String instanceId,JSONArray variables) throws IOException {
  JSONObject instance=getInstance(instanceId);
  JSONArray instanceVariables=instance.getJSONArray("String_Node_Str");
  JSONArray boxVariables=instance.getJSONArray("String_Node_Str").getJSONObject(0).getJSONArray("String_Node_Str");
  List<JSONObject> newVariables=new ArrayList<JSONObject>();
  for (  Object variable : variables) {
    JSONObject variableJson=(JSONObject)variable;
    JSONObject instanceVariable=findVariable(variableJson,instanceVariables);
    if (instanceVariable == null) {
      JSONObject boxVariable=findVariable(variableJson,boxVariables);
      if (boxVariable != null) {
        instanceVariable=JSONObject.fromObject(boxVariable);
        newVariables.add(instanceVariable);
      }
    }
    if (instanceVariable != null) {
      instanceVariable.put("String_Node_Str",variableJson.getString("String_Node_Str"));
    }
  }
  instanceVariables.addAll(newVariables);
  instance.put("String_Node_Str",instanceVariables);
  String instanceUrl=getInstanceUrl(instanceId);
  HttpPut put=new HttpPut(instanceUrl);
  put.setEntity(new StringEntity(instance.toString(),ContentType.APPLICATION_JSON));
  try {
    execute(put);
    put.reset();
    put=new HttpPut(MessageFormat.format("String_Node_Str",instanceUrl));
    execute(put);
    return new ProgressMonitor(instanceUrl,Collections.singleton(InstanceOperation.RECONFIGURE));
  }
  finally {
    put.reset();
  }
}

Fixed version (ground truth):
public IProgressMonitor reconfigure(String instanceId,JSONArray variables) throws IOException {
  JSONObject instance=getInstance(instanceId);
  JSONArray instanceVariables=instance.getJSONArray("String_Node_Str");
  JSONArray boxVariables=instance.getJSONArray("String_Node_Str").getJSONObject(0).getJSONArray("String_Node_Str");
  List<JSONObject> newVariables=new ArrayList<JSONObject>();
  for (  Object variable : variables) {
    JSONObject variableJson=(JSONObject)variable;
    JSONObject instanceVariable=findVariable(variableJson,instanceVariables);
    if (instanceVariable == null) {
      JSONObject boxVariable=findVariable(variableJson,boxVariables);
      if (boxVariable != null) {
        instanceVariable=JSONObject.fromObject(boxVariable);
        newVariables.add(instanceVariable);
      }
    }
    if (instanceVariable != null) {
      instanceVariable.put("String_Node_Str",variableJson.getString("String_Node_Str"));
    }
  }
  instanceVariables.addAll(newVariables);
  instance.put("String_Node_Str",instanceVariables);
  String instanceUrl=getInstanceUrl(instanceId);
  HttpPut put=new HttpPut(instanceUrl);
  put.setEntity(new StringEntity(instance.toString(),ContentType.APPLICATION_JSON));
  try {
    HttpResponse response=execute(put);
    instance=JSONObject.fromObject(getResponseBodyAsString(response));
    put.reset();
    put=new HttpPut(MessageFormat.format("String_Node_Str",instanceUrl));
    execute(put);
    return new ProgressMonitor(instanceUrl,Collections.singleton(InstanceOperation.RECONFIGURE),instance.getString("String_Node_Str"));
  }
  finally {
    put.reset();
  }
}
Program: 149408
Project: 149408
Buggy source:
/** 
 * @param states
 * @param timeout in minutes
 * @return the latest state if it is one of the specified states or the timeout elapsed
 * @throws IOException 
 */
private String waitFor(Set<String> states,int timeout) throws IOException {
  long startTime=System.currentTimeMillis();
  long remainingTime=timeout * 60000;
  String state=null;
  do {
    JSONObject instance=(JSONObject)doGet(instanceUrl,false);
    state=instance.getString("String_Node_Str");
    if (states.contains(state)) {
      if (operations == null) {
        break;
      }
      String operation=instance.getString("String_Node_Str");
      if (TERMINATE_OPERATIONS.contains(operation) || operations.contains(operation)) {
        break;
      }
    }
synchronized (waitLock) {
      try {
        waitLock.wait(1000);
      }
 catch (      InterruptedException ex) {
      }
    }
    long currentTime=System.currentTimeMillis();
    remainingTime=remainingTime - (currentTime - startTime);
    startTime=currentTime;
  }
 while (timeout == 0 || remainingTime > 0);
  return state;
}

Fixed version (ground truth):
/** 
 * @param states
 * @param timeout in minutes
 * @return the latest state if it is one of the specified states or the timeout elapsed
 * @throws IOException 
 */
private String waitFor(Set<String> states,int timeout) throws IOException {
  long startTime=System.currentTimeMillis();
  long remainingTime=timeout * 60000;
  String state=null;
  do {
    JSONObject instance=(JSONObject)doGet(instanceUrl,false);
    String updated=instance.getString("String_Node_Str");
    state=instance.getString("String_Node_Str");
    if (!lastModified.equals(updated) && states.contains(state)) {
      if (operations == null) {
        break;
      }
      String operation=instance.getString("String_Node_Str");
      if (TERMINATE_OPERATIONS.contains(operation) || operations.contains(operation)) {
        break;
      }
    }
synchronized (waitLock) {
      try {
        waitLock.wait(1000);
      }
 catch (      InterruptedException ex) {
      }
    }
    long currentTime=System.currentTimeMillis();
    remainingTime=remainingTime - (currentTime - startTime);
    startTime=currentTime;
  }
 while (timeout == 0 || remainingTime > 0);
  return state;
}
Program: 149409
Project: 149409
Buggy source:
private IProgressMonitor doTerminate(String instanceUrl,String operation) throws IOException {
  HttpDelete delete=new HttpDelete(MessageFormat.format("String_Node_Str",instanceUrl,operation));
  try {
    execute(delete);
    return new ProgressMonitor(instanceUrl,TERMINATE_OPERATIONS);
  }
  finally {
    delete.reset();
  }
}

Fixed version (ground truth):
private IProgressMonitor doTerminate(String instanceUrl,String operation) throws IOException {
  JSONObject instance=(JSONObject)doGet(instanceUrl,false);
  HttpDelete delete=new HttpDelete(MessageFormat.format("String_Node_Str",instanceUrl,operation));
  try {
    execute(delete);
    return new ProgressMonitor(instanceUrl,TERMINATE_OPERATIONS,instance.getString("String_Node_Str"));
  }
  finally {
    delete.reset();
  }
}
Program: 149410
Project: 149410
Buggy source:
private ProgressMonitor(String instanceUrl,Set<String> operations){
  this.instanceUrl=instanceUrl;
  this.operations=operations;
  creationTime=System.currentTimeMillis();
}

Fixed version (ground truth):
private ProgressMonitor(String instanceUrl,Set<String> operations,String lastModified){
  this.instanceUrl=instanceUrl;
  this.operations=operations;
  this.lastModified=lastModified;
  creationTime=System.currentTimeMillis();
}
Program: 149411
Project: 149411
Buggy source:
public IProgressMonitor reinstall(String instanceId) throws IOException {
  String instanceUrl=getInstanceUrl(instanceId);
  HttpPut put=new HttpPut(MessageFormat.format("String_Node_Str",instanceUrl));
  try {
    execute(put);
    return new ProgressMonitor(instanceUrl,Collections.singleton(InstanceOperation.REINSTALL));
  }
  finally {
    put.reset();
  }
}

Fixed version (ground truth):
public IProgressMonitor reinstall(String instanceId) throws IOException {
  String instanceUrl=getInstanceUrl(instanceId);
  JSONObject instance=(JSONObject)doGet(instanceUrl,false);
  HttpPut put=new HttpPut(MessageFormat.format("String_Node_Str",instanceUrl));
  try {
    execute(put);
    return new ProgressMonitor(instanceUrl,Collections.singleton(InstanceOperation.REINSTALL),instance.getString("String_Node_Str"));
  }
  finally {
    put.reset();
  }
}
Program: 149412
Project: 149412
Buggy source:
public IProgressMonitor shutdown(String instanceId) throws IOException {
  String instanceUrl=getInstanceUrl(instanceId);
  HttpPut put=new HttpPut(MessageFormat.format("String_Node_Str",instanceUrl));
  try {
    execute(put);
    return new ProgressMonitor(instanceUrl,SHUTDOWN_OPERATIONS);
  }
  finally {
    put.reset();
  }
}

Fixed version (ground truth):
public IProgressMonitor shutdown(String instanceId) throws IOException {
  String instanceUrl=getInstanceUrl(instanceId);
  JSONObject instance=(JSONObject)doGet(instanceUrl,false);
  HttpPut put=new HttpPut(MessageFormat.format("String_Node_Str",instanceUrl));
  try {
    execute(put);
    return new ProgressMonitor(instanceUrl,SHUTDOWN_OPERATIONS,instance.getString("String_Node_Str"));
  }
  finally {
    put.reset();
  }
}
Program: 149414
Project: 149414
Buggy source:
public boolean isDone() throws IncompleteException, IOException {
  String state=getState();
  if (state.equals(InstanceState.UNAVAILABLE)) {
    throw new IncompleteException("String_Node_Str");
  }
  return state.equals(InstanceState.DONE);
}

Fixed version (ground truth):
public boolean isDone() throws IncompleteException, IOException {
  String state;
  try {
    state=getState();
  }
 catch (  ClientException ex) {
    if (ex.getStatusCode() == HttpStatus.SC_NOT_FOUND) {
      throw new IncompleteException("String_Node_Str");
    }
 else {
      throw ex;
    }
  }
  if (state.equals(InstanceState.UNAVAILABLE)) {
    throw new IncompleteException("String_Node_Str");
  }
  return state.equals(InstanceState.DONE);
}
Program: 149415
Project: 149415
Buggy source:
private String getState() throws IOException {
  JSONObject instance=(JSONObject)doGet(instanceUrl,false);
  return instance.getString("String_Node_Str");
}

Fixed version (ground truth):
private String getState() throws IOException {
  Client client=new Client(endpointUrl,username,password);
  JSONObject instance=(JSONObject)client.doGet(instanceUrl,false);
  return instance.getString("String_Node_Str");
}
Program: 149416
Project: 149416
Buggy source:
/** 
 * @param states
 * @param timeout in minutes
 * @return the latest state if it is one of the specified states or the timeout elapsed
 * @throws IOException 
 */
private String waitFor(Set<String> states,int timeout) throws IOException {
  long startTime=System.currentTimeMillis();
  long remainingTime=timeout * 60000;
  String state=null;
synchronized (waitLock) {
    while (remainingTime > 0 && !states.contains((state=getState()))) {
      try {
        waitLock.wait(1000);
      }
 catch (      InterruptedException ex) {
      }
      long currentTime=System.currentTimeMillis();
      remainingTime=remainingTime - (currentTime - startTime);
      startTime=currentTime;
    }
  }
  return state;
}

Fixed version (ground truth):
/** 
 * @param states
 * @param timeout in minutes
 * @return the latest state if it is one of the specified states or the timeout elapsed
 * @throws IOException 
 */
private String waitFor(Set<String> states,int timeout) throws IOException {
  long startTime=System.currentTimeMillis();
  long remainingTime=timeout * 60000;
  String state=null;
  while (remainingTime > 0 && !states.contains((state=getState()))) {
synchronized (waitLock) {
      try {
        waitLock.wait(1000);
      }
 catch (      InterruptedException ex) {
      }
    }
    long currentTime=System.currentTimeMillis();
    remainingTime=remainingTime - (currentTime - startTime);
    startTime=currentTime;
  }
  return state;
}
Program: 149418
Project: 149418
Buggy source:
public ElasticBoxSlave(String name,boolean singleUse,String remoteFS,int numExecutors) throws Descriptor.FormException, IOException {
  super(name,"String_Node_Str",remoteFS,numExecutors,Mode.EXCLUSIVE,"String_Node_Str",new JNLPLauncher(),RetentionStrategy.INSTANCE);
  this.singleUse=singleUse;
  this.idleStartTime=System.currentTimeMillis();
}

Fixed version (ground truth):
public ElasticBoxSlave(String profileId,boolean singleUse,ElasticBoxCloud cloud) throws Descriptor.FormException, IOException {
  super(UUID.randomUUID().toString(),"String_Node_Str",getRemoteFS(profileId,cloud),1,Mode.EXCLUSIVE,"String_Node_Str",new JNLPLauncher(),RetentionStrategy.INSTANCE);
  this.profileId=profileId;
  this.singleUse=singleUse;
  this.idleStartTime=System.currentTimeMillis();
  this.cloud=cloud;
}
Program: 149419
Project: 149419
Buggy source:
private void wait(Callable<Boolean> condition,long timeout) throws Exception {
  long startTime=System.currentTimeMillis();
  long remainingTime=timeout;
synchronized (waitLock) {
    while (remainingTime > 0 && condition.call()) {
      try {
        waitLock.wait(remainingTime);
      }
 catch (      InterruptedException ex) {
      }
      long currentTime=System.currentTimeMillis();
      remainingTime=remainingTime - (currentTime - startTime);
      startTime=currentTime;
    }
  }
}

Fixed version (ground truth):
private void wait(Callable<Boolean> condition,long timeout) throws Exception {
  long startTime=System.currentTimeMillis();
  long remainingTime=timeout;
  while (remainingTime > 0 && condition.call()) {
synchronized (waitLock) {
      try {
        waitLock.wait(remainingTime);
      }
 catch (      InterruptedException ex) {
      }
    }
    long currentTime=System.currentTimeMillis();
    remainingTime=remainingTime - (currentTime - startTime);
    startTime=currentTime;
  }
}
Program: 149420
Project: 149420
Buggy source:
private void log(Level level,String message,Throwable exception,TaskListener listener){
  listener.getLogger().println(message);
  Logger.getLogger(InstanceCreator.class.getName()).log(level,message,exception);
}

Fixed version (ground truth):
private void log(Level level,String message,Throwable exception,TaskListener listener){
  listener.getLogger().println(message);
  LOGGER.log(level,message,exception);
}
Program: 149421
Project: 149421
Buggy source:
private int purgeSlaves(TaskListener listener) throws IOException {
  List<ElasticBoxSlave> slavesToRemove=new ArrayList<ElasticBoxSlave>();
  int numOfInstances=collectSlavesToRemove(slavesToRemove);
  for (Iterator<ElasticBoxSlave> iter=terminatedSlaves.iterator(); iter.hasNext(); ) {
    ElasticBoxSlave slave=iter.next();
    try {
      slave.delete();
      iter.remove();
      removeSlave(slave);
    }
 catch (    ClientException ex) {
      if (ex.getStatusCode() != HttpStatus.SC_CONFLICT) {
        log(Level.WARNING,MessageFormat.format("String_Node_Str",slave.getDisplayName()),ex,listener);
      }
    }
catch (    IOException ex) {
      log(Level.WARNING,MessageFormat.format("String_Node_Str",slave.getDisplayName()),ex,listener);
    }
  }
  for (  ElasticBoxSlave badSlave : slavesToRemove) {
    removeSlave(badSlave);
  }
  return numOfInstances;
}

Fixed version (ground truth):
private int purgeSlaves(TaskListener listener) throws IOException {
  List<ElasticBoxSlave> slavesToRemove=new ArrayList<ElasticBoxSlave>();
  int numOfInstances=collectSlavesToRemove(slavesToRemove);
  for (Iterator<ElasticBoxSlave> iter=terminatedSlaves.iterator(); iter.hasNext(); ) {
    ElasticBoxSlave slave=iter.next();
    try {
      try {
        slave.delete();
      }
 catch (      ClientException ex) {
        if (ex.getStatusCode() == HttpStatus.SC_CONFLICT) {
          continue;
        }
 else         if (ex.getStatusCode() != HttpStatus.SC_NOT_FOUND) {
          throw ex;
        }
      }
      iter.remove();
      removeSlave(slave);
    }
 catch (    IOException ex) {
      log(Level.WARNING,MessageFormat.format("String_Node_Str",slave.getDisplayName()),ex,listener);
    }
  }
  for (  ElasticBoxSlave badSlave : slavesToRemove) {
    removeSlave(badSlave);
  }
  return numOfInstances;
}
Program: 149422
Project: 149422
Buggy source:
public void waitForDone(int timeout) throws IncompleteException, IOException {
  long startTime=System.currentTimeMillis();
  try {
    wait(new Callable<Boolean>(){
      public Boolean call() throws Exception {
        return monitor == null;
      }
    }
,timeout);
  }
 catch (  Exception ex) {
  }
  if (monitor == DONE_MONITOR) {
    return;
  }
  long remainingTime=System.currentTimeMillis() - startTime;
  if (monitor != null && remainingTime > 0) {
    monitor.waitForDone(Math.round(remainingTime / 60000));
  }
  remainingTime=System.currentTimeMillis() - startTime;
  if (remainingTime > 0) {
    try {
      wait(new Callable<Boolean>(){
        public Boolean call() throws Exception {
          return slave.getComputer().isOffline();
        }
      }
,remainingTime);
    }
 catch (    Exception ex) {
    }
  }
}

Fixed version (ground truth):
public void waitForDone(int timeout) throws IncompleteException, IOException {
  StopWatch stopWatch=new StopWatch();
  stopWatch.start();
  long timeoutMiliseconds=timeout * 60000;
  long remainingTime=timeoutMiliseconds;
  try {
    wait(new Callable<Boolean>(){
      public Boolean call() throws Exception {
        return monitor == null;
      }
    }
,timeoutMiliseconds);
  }
 catch (  Exception ex) {
    LOGGER.log(Level.SEVERE,ex.getMessage(),ex);
  }
  if (monitor == DONE_MONITOR) {
    return;
  }
  remainingTime=remainingTime - stopWatch.getTime();
  if (monitor != null && remainingTime > 0) {
    monitor.waitForDone(Math.round(remainingTime / 60000));
  }
  remainingTime=remainingTime - stopWatch.getTime();
  if (remainingTime > 0) {
    try {
      wait(new Callable<Boolean>(){
        public Boolean call() throws Exception {
          return slave.getComputer().isOffline();
        }
      }
,remainingTime);
    }
 catch (    Exception ex) {
      LOGGER.log(Level.SEVERE,ex.getMessage(),ex);
    }
  }
}
Program: 149423
Project: 149423
Buggy source:
private void processSubmittedQueue(TaskListener listener){
  boolean saveNeeded=false;
  for (Iterator<InstanceCreationRequest> iter=submittedQueue.iterator(); iter.hasNext(); ) {
    InstanceCreationRequest request=iter.next();
    try {
      if (request.monitor.isDone()) {
        if (request.slave.getComputer().isOnline()) {
          request.slave.setInstanceStatusMessage(MessageFormat.format("String_Node_Str",request.slave.getInstancePageUrl()));
          saveNeeded=true;
          iter.remove();
        }
 else         if ((System.currentTimeMillis() - request.monitor.getCreationTime()) >= TIMEOUT) {
          request.slave.setInUse(false);
          iter.remove();
          log(Level.SEVERE,MessageFormat.format("String_Node_Str",request.slave.getNodeName(),TIMEOUT_MINUTES),null,listener);
        }
      }
    }
 catch (    IProgressMonitor.IncompleteException ex) {
      log(Level.SEVERE,ex.getMessage(),ex,listener);
    }
catch (    IOException ex) {
      log(Level.SEVERE,ex.getMessage(),ex,listener);
    }
  }
  if (saveNeeded) {
    try {
      Jenkins.getInstance().save();
    }
 catch (    IOException ex) {
      Logger.getLogger(ElasticBoxSlaveHandler.class.getName()).log(Level.SEVERE,"String_Node_Str",ex);
    }
  }
}

Fixed version (ground truth):
private void processSubmittedQueue(TaskListener listener){
  boolean saveNeeded=false;
  for (Iterator<InstanceCreationRequest> iter=submittedQueue.iterator(); iter.hasNext(); ) {
    InstanceCreationRequest request=iter.next();
    try {
      if (request.monitor.isDone()) {
        if (request.slave.getComputer().isOnline()) {
          request.slave.setInstanceStatusMessage(MessageFormat.format("String_Node_Str",request.slave.getInstancePageUrl()));
          saveNeeded=true;
          iter.remove();
        }
 else         if ((System.currentTimeMillis() - request.monitor.getCreationTime()) >= TIMEOUT) {
          request.slave.setInUse(false);
          iter.remove();
          log(Level.SEVERE,MessageFormat.format("String_Node_Str",request.slave.getNodeName(),TIMEOUT_MINUTES),null,listener);
        }
      }
    }
 catch (    IProgressMonitor.IncompleteException ex) {
      log(Level.SEVERE,ex.getMessage(),ex,listener);
      iter.remove();
    }
catch (    IOException ex) {
      log(Level.SEVERE,ex.getMessage(),ex,listener);
    }
  }
  if (saveNeeded) {
    try {
      Jenkins.getInstance().save();
    }
 catch (    IOException ex) {
      Logger.getLogger(ElasticBoxSlaveHandler.class.getName()).log(Level.SEVERE,"String_Node_Str",ex);
    }
  }
}
Program: 149425
Project: 149425
Buggy source:
@Override protected void doTunnel(HttpServletRequest req,final HttpServletResponse res){
  String destination=res.getHeader("String_Node_Str");
  int c=0;
  if (destination == null || (c=destination.indexOf("String_Node_Str")) < 0) {
    try {
      res.sendError(HttpServletResponse.SC_BAD_REQUEST);
    }
 catch (    IOException e) {
    }
    return;
  }
  int port=Numbers.parseInt(destination.substring(c + 1));
  String host=destination.substring(0,c);
  Socket socket=null;
  try {
    socket=new Socket(host,port);
    socket.setSoTimeout(DEFAULT_TIMEOUT);
  }
 catch (  IOException e) {
    try {
      res.sendError(HttpServletResponse.SC_BAD_GATEWAY);
    }
 catch (    IOException e1) {
      return;
    }
  }
  final Socket socket_=socket;
  executor.execute(new Runnable(){
    @Override public void run(){
      try {
        onRecvRemote(socket_.getInputStream(),res.getOutputStream());
      }
 catch (      IOException e) {
      }
      closeSocket(socket_);
    }
  }
);
  InputStream in=null;
  try {
    in=req.getInputStream();
    ins.add(in);
    onRecvClient(in,socket.getOutputStream());
  }
 catch (  IOException e) {
  }
 finally {
    if (in != null) {
      ins.remove(in);
    }
  }
  closeSocket(socket);
}

Fixed version (ground truth):
@Override protected void doTunnel(HttpServletRequest req,final HttpServletResponse res){
  String destination=req.getHeader("String_Node_Str");
  int c=0;
  if (destination == null || (c=destination.indexOf("String_Node_Str")) < 0) {
    try {
      res.sendError(HttpServletResponse.SC_BAD_REQUEST);
    }
 catch (    IOException e) {
    }
    return;
  }
  int port=Numbers.parseInt(destination.substring(c + 1));
  String host=destination.substring(0,c);
  Socket socket=null;
  try {
    socket=new Socket(host,port);
    socket.setSoTimeout(DEFAULT_TIMEOUT);
  }
 catch (  IOException e) {
    try {
      res.sendError(HttpServletResponse.SC_BAD_GATEWAY);
    }
 catch (    IOException e1) {
      return;
    }
  }
  final Socket socket_=socket;
  executor.execute(new Runnable(){
    @Override public void run(){
      try {
        onRecvRemote(socket_.getInputStream(),res.getOutputStream());
      }
 catch (      IOException e) {
      }
      closeSocket(socket_);
    }
  }
);
  InputStream in=null;
  try {
    in=req.getInputStream();
    ins.add(in);
    onRecvClient(in,socket.getOutputStream());
  }
 catch (  IOException e) {
  }
 finally {
    if (in != null) {
      ins.remove(in);
    }
  }
  closeSocket(socket);
}
Program: 149426
Project: 149426
Buggy source:
public static boolean handleShutdown(Class<?> clazz,String[] args,final AtomicBoolean running){
  if (args != null && args.length > 0 && args[0].equals("String_Node_Str")) {
    running.set(false);
    return true;
  }
  SignalHandler handler=new SignalHandler(){
    @Override public void handle(    Signal signal){
    }
  }
;
  String command=System.getProperty("String_Node_Str");
  if (command == null || command.isEmpty()) {
    return false;
  }
  if (clazz.getName().equals(command.split("String_Node_Str")[0])) {
    Signal.handle(new Signal("String_Node_Str"),handler);
    Signal.handle(new Signal("String_Node_Str"),handler);
  }
  return false;
}

Fixed version (ground truth):
public static boolean handleShutdown(Class<?> clazz,String[] args,final AtomicBoolean running){
  if (args != null && args.length > 0 && args[0].equals("String_Node_Str")) {
    running.set(false);
    return true;
  }
  SignalHandler handler=new SignalHandler(){
    @Override public void handle(    Signal signal){
      running.set(false);
    }
  }
;
  String command=System.getProperty("String_Node_Str");
  if (command == null || command.isEmpty()) {
    return false;
  }
  if (clazz.getName().equals(command.split("String_Node_Str")[0])) {
    Signal.handle(new Signal("String_Node_Str"),handler);
    Signal.handle(new Signal("String_Node_Str"),handler);
  }
  return false;
}
Program: 149427
Project: 149427
Buggy source:
@Override public void handle(Signal signal){
}

Fixed version (ground truth):
@Override public void handle(Signal signal){
  running.set(false);
}
Program: 149428
Project: 149428
Buggy source:
private static void connect(final Socket socket){
  try (Socket socket_=sf.createSocket(host,port);InputStream is=new BufferedInputStream(socket_.getInputStream());OutputStream os=socket_.getOutputStream()){
    String header=null;
    if (AUTH == null) {
      header=String.format(NO_AUTH_HEADER,path,host,port,destination);
    }
 else {
      header=String.format(path,host,port,destination,new String(Base64.encodeBase64(AUTH.getBytes())));
    }
    os.write(header.getBytes());
    HashMap<String,String> headers=Headers.generateHeaders(is);
    Headers.checkHeaders(headers);
    Executors.execute(new Runnable(){
      @Override public void run(){
        try {
          onRecvLocal(socket.getInputStream(),os);
        }
 catch (        IOException e) {
        }
      }
    }
);
    if ("String_Node_Str".equals(headers.get("String_Node_Str"))) {
      onRecvRemoteChunked(is,os);
    }
 else {
      onRecvRemote(is,os);
    }
  }
 catch (  IOException e) {
  }
}

Fixed version (ground truth):
private static void connect(final Socket socket){
  try (Socket socket_=sf.createSocket(host,port);InputStream is=new BufferedInputStream(socket_.getInputStream());OutputStream os=socket_.getOutputStream()){
    String header=null;
    if (AUTH == null) {
      header=String.format(NO_AUTH_HEADER,path,host,"String_Node_Str" + port,destination);
    }
 else {
      header=String.format(path,host,"String_Node_Str" + port,destination,new String(Base64.encodeBase64(AUTH.getBytes())));
    }
    os.write(header.getBytes());
    HashMap<String,String> headers=Headers.generateHeaders(is);
    Headers.checkHeaders(headers);
    Executors.execute(new Runnable(){
      @Override public void run(){
        try {
          onRecvLocal(socket.getInputStream(),os);
        }
 catch (        IOException e) {
        }
      }
    }
);
    if ("String_Node_Str".equals(headers.get("String_Node_Str"))) {
      onRecvRemoteChunked(is,socket.getOutputStream());
    }
 else {
      onRecvRemote(is,socket.getOutputStream());
    }
  }
 catch (  IOException e) {
  }
  close(socket);
}
Program: 149429
Project: 149429
Buggy source:
public static void init(final int measurements,final String[] events,int... options){
  if (defaultEventSet != -1) {
    Measurement.destroyEventSet(defaultEventSet);
  }
  defaultEventSet=Measurement.createEventSet(measurements,events,options);
}

Fixed version (ground truth):
public static void init(final int measurements,final String[] events,int... options){
  if (defaultEventSet != -1) {
    Measurement.destroyEventSet(defaultEventSet);
    defaultEventSet=-1;
  }
  defaultEventSet=Measurement.createEventSet(measurements,events,options);
}
Program: 149430
Project: 149430
Buggy source:
public void addDataRow(long[] row){
  data.add(row);
}

Fixed version (ground truth):
void addDataRow(long[] row){
  long copy[]=new long[row.length];
  for (int i=0; i < row.length; i++) {
    copy[i]=row[i];
  }
  data.add(copy);
}
Program: 149431
Project: 149431
Buggy source:
@RequestMapping(method=RequestMethod.POST) public String handleCreateGroup(@Valid @ModelAttribute(MODEL) CreateUserCommand command,BindingResult bindingResult){
  final RedirectBuilder redirect=new RedirectBuilder().setPath(CONTROLLER_PATH);
  try {
    if (!bindingResult.hasErrors()) {
      command.setActive(defaultActive);
      User createdUser=userService.createUser(command.getAsUser());
      redirect.setPath(EditUserController.CONTROLLER_PATH);
      redirect.addParameter("String_Node_Str",createdUser.getId());
      return redirect.build();
    }
  }
 catch (  SCIMDataValidationException e) {
    LOG.warn("String_Node_Str",e);
  }
catch (  ConflictException e) {
    LOG.warn("String_Node_Str",e);
  }
  storeInSession(SESSION_KEY_COMMAND,command);
  storeBindingResultIntoSession(bindingResult,MODEL);
  return redirect.build();
}

Fixed version (ground truth):
@RequestMapping(method=RequestMethod.POST) public String handleCreateGroup(@Valid @ModelAttribute(MODEL) CreateUserCommand command,BindingResult bindingResult){
  final RedirectBuilder redirect=new RedirectBuilder().setPath(CONTROLLER_PATH);
  try {
    if (!bindingResult.hasErrors()) {
      command.setActive(defaultActive);
      User createdUser=userService.createUser(command.getAsUser());
      redirect.setPath(EditUserController.CONTROLLER_PATH);
      redirect.addParameter("String_Node_Str",createdUser.getId());
      return redirect.build();
    }
  }
 catch (  SCIMDataValidationException e) {
    LOG.warn("String_Node_Str",e);
  }
catch (  ConflictException e) {
    LOG.warn("String_Node_Str",e);
  }
  storeInSession(SESSION_KEY_COMMAND,command);
  storeBindingResultIntoSession(bindingResult,MODEL);
  redirect.addParameter(REQUEST_PARAMETER_ERROR,"String_Node_Str");
  return redirect.build();
}
Program: 149432
Project: 149432
Buggy source:
@Test public void createUser(){
  User newUser=new User.Builder("String_Node_Str").build();
  toTestSpy.createUser(newUser);
  verify(connector,times(1)).createUser(eq(newUser),same(accessToken));
}

Fixed version (ground truth):
@Test public void createUser(){
  User newUser=new User.Builder("String_Node_Str").build();
  toTestSpy.createUser(newUser);
  verify(connector,times(1)).createUser(same(newUser),same(accessToken));
}
Program: 149433
Project: 149433
Buggy source:
@RequestMapping(method=RequestMethod.POST) public String handleCreateGroup(@Valid @ModelAttribute(MODEL) CreateGroupCommand command,BindingResult bindingResult){
  final RedirectBuilder redirect=new RedirectBuilder().setPath(CONTROLLER_PATH);
  try {
    if (!bindingResult.hasErrors()) {
      groupService.createGroup(command.getAsGroup());
      redirect.addParameter("String_Node_Str",true);
      redirect.setPath(GroupViewController.CONTROLLER_PATH);
      return redirect.build();
    }
  }
 catch (  SCIMDataValidationException e) {
    LOG.warn("String_Node_Str",e);
  }
  storeInSession(SESSION_KEY_COMMAND,command);
  storeBindingResultIntoSession(bindingResult,MODEL);
  redirect.addParameter(REQUEST_PARAMETER_ERROR,"String_Node_Str");
  return redirect.build();
}

Fixed version (ground truth):
@RequestMapping(method=RequestMethod.POST) public String handleCreateGroup(@Valid @ModelAttribute(MODEL) CreateGroupCommand command,BindingResult bindingResult){
  final RedirectBuilder redirect=new RedirectBuilder().setPath(CONTROLLER_PATH);
  try {
    if (!bindingResult.hasErrors()) {
      groupService.createGroup(command.getAsGroup());
      redirect.addParameter("String_Node_Str",true);
      redirect.setPath(GroupViewController.CONTROLLER_PATH);
      return redirect.build();
    }
  }
 catch (  SCIMDataValidationException e) {
    LOG.warn("String_Node_Str",e);
  }
catch (  ConflictException e) {
    LOG.warn("String_Node_Str",e);
  }
  storeInSession(SESSION_KEY_COMMAND,command);
  storeBindingResultIntoSession(bindingResult,MODEL);
  redirect.addParameter(REQUEST_PARAMETER_ERROR,"String_Node_Str");
  return redirect.build();
}
Program: 149434
Project: 149434
Buggy source:
/** 
 * Returns a SCIM   {@link UpdateGroup} based on this command.
 * @return the requested {@link UpdateGroup}
 */
public UpdateGroup getAsUpdateGroup(){
  UpdateGroup.Builder builder=new UpdateGroup.Builder();
  builder.updateDisplayName(getDisplayName());
  builder.updateExternalId(getExternalId());
  builder.deleteMembers();
  for (  String member : memberIds) {
    builder.addMember(member);
  }
  return builder.build();
}

Fixed version (ground truth):
/** 
 * Returns a SCIM   {@link UpdateGroup} based on this command.
 * @return the requested {@link UpdateGroup}
 */
public UpdateGroup getAsUpdateGroup(){
  UpdateGroup.Builder builder=new UpdateGroup.Builder();
  builder.updateDisplayName(getDisplayName());
  if (getExternalId() != null && getExternalId().equals("String_Node_Str")) {
    builder.deleteExternalId();
  }
 else {
    builder.updateExternalId(getExternalId());
  }
  builder.deleteMembers();
  for (  String member : memberIds) {
    builder.addMember(member);
  }
  return builder.build();
}
Program: 149435
Project: 149435
Buggy source:
protected void restoreBindingResultFromSession(String modelName,ModelAndView model){
  model.addObject(SPRING_BR_PREFIX + modelName,restoreBindingResultFromSession(modelName));
}

Fixed version (ground truth):
protected Object restoreBindingResultFromSession(String modelName){
  return restoreFromSession(generateKey(modelName));
}
Program: 149436
Project: 149436
Buggy source:
@RequestMapping(method=RequestMethod.GET,params=REQUEST_PARAMETER_ERROR + "String_Node_Str") public ModelAndView handleUserEditFailure(@RequestParam(value=REQUEST_PARAMETER_ID) final String id){
  ModelAndView modelAndView=new ModelAndView("String_Node_Str");
  modelAndView.addObject(MODEL,restoreFromSession(SESSION_KEY_COMMAND));
  restoreBindingResultFromSession(MODEL,modelAndView);
  return modelAndView;
}

Fixed version (ground truth):
@RequestMapping(method=RequestMethod.GET,params=REQUEST_PARAMETER_ERROR + "String_Node_Str") public ModelAndView handleUserEditFailure(@RequestParam(value=REQUEST_PARAMETER_ID) final String id){
  ModelAndView modelAndView=new ModelAndView("String_Node_Str");
  modelAndView.addObject(MODEL,restoreFromSession(SESSION_KEY_COMMAND));
  enrichBindingResultFromSession(MODEL,modelAndView);
  return modelAndView;
}
Program: 149437
Project: 149437
Buggy source:
/** 
 * Replace a user based on the given   {@link User}.
 * @param id the user ID
 * @param User the  {@link User}
 */
public void replaceUser(String id,User newUser){
  connector.replaceUser(id,newUser,sessionData.getAccesstoken());
  connector.revokeAllAccessTokens(id,sessionData.getAccesstoken());
}

Fixed version (ground truth):
/** 
 * Replace a user based on the given   {@link User} and revoke his access token.
 * @param id the user ID
 * @param User the  {@link User}
 */
public void replaceUser(String id,User newUser){
  connector.replaceUser(id,newUser,sessionData.getAccesstoken());
  connector.revokeAllAccessTokens(id,sessionData.getAccesstoken());
}