nus-yam/ex-repair huggingface dataset:
Program: 8051
Project: 8051
Buggy source:
private void decreaseInstances(String flowletName,final int newInstanceCount,Map<Integer,ProgramController> liveFlowlets,int liveCount) throws InterruptedException, ExecutionException {
  List<ListenableFuture<?>> futures=Lists.newArrayListWithCapacity(liveCount - newInstanceCount);
  for (int instanceId=liveCount - 1; instanceId >= newInstanceCount; instanceId--) {
    futures.add(flowlets.remove(flowletName,instanceId).stop());
  }
  Futures.successfulAsList(futures).get();
  Futures.successfulAsList(Iterables.transform(liveFlowlets.values(),new Function<ProgramController,ListenableFuture<?>>(){
    @Override public ListenableFuture<?> apply(    ProgramController controller){
      return controller.suspend();
    }
  }
)).get();
  Futures.successfulAsList(Iterables.transform(liveFlowlets.values(),new Function<ProgramController,ListenableFuture<?>>(){
    @Override public ListenableFuture<?> apply(    ProgramController controller){
      return controller.command("String_Node_Str",newInstanceCount);
    }
  }
)).get();
  Futures.successfulAsList(Iterables.transform(liveFlowlets.values(),new Function<ProgramController,ListenableFuture<?>>(){
    @Override public ListenableFuture<?> apply(    ProgramController controller){
      return controller.resume();
    }
  }
)).get();
}

Fixed version (ground truth):
private synchronized void decreaseInstances(String flowletName,final int newInstanceCount,Map<Integer,ProgramController> liveFlowlets,int liveCount) throws InterruptedException, ExecutionException {
  List<ListenableFuture<?>> futures=Lists.newArrayListWithCapacity(liveCount - newInstanceCount);
  for (int instanceId=liveCount - 1; instanceId >= newInstanceCount; instanceId--) {
    futures.add(flowlets.remove(flowletName,instanceId).stop());
  }
  Futures.successfulAsList(futures).get();
  Futures.successfulAsList(Iterables.transform(liveFlowlets.values(),new Function<ProgramController,ListenableFuture<?>>(){
    @Override public ListenableFuture<?> apply(    ProgramController controller){
      return controller.suspend();
    }
  }
)).get();
  Futures.successfulAsList(Iterables.transform(liveFlowlets.values(),new Function<ProgramController,ListenableFuture<?>>(){
    @Override public ListenableFuture<?> apply(    ProgramController controller){
      return controller.command("String_Node_Str",newInstanceCount);
    }
  }
)).get();
  Futures.successfulAsList(Iterables.transform(liveFlowlets.values(),new Function<ProgramController,ListenableFuture<?>>(){
    @Override public ListenableFuture<?> apply(    ProgramController controller){
      return controller.resume();
    }
  }
)).get();
}
Program: 8052
Project: 8052
Buggy source:
private void changeInstances(String flowletName,final int newInstanceCount) throws ExecutionException, InterruptedException {
  Map<Integer,ProgramController> liveFlowlets=flowlets.row(flowletName);
  int liveCount=liveFlowlets.size();
  if (liveCount == newInstanceCount) {
    return;
  }
  if (liveCount < newInstanceCount) {
    increaseInstances(flowletName,newInstanceCount,liveFlowlets,liveCount);
    return;
  }
  decreaseInstances(flowletName,newInstanceCount,liveFlowlets,liveCount);
}

Fixed version (ground truth):
/** 
 * Change the number of instances of the running flowlet. Notice that this method needs to be synchronized as change of instances involves multiple steps that need to be completed all at once.
 * @param flowletName Name of the flowlet
 * @param newInstanceCount New instance count
 * @throws ExecutionException
 * @throws InterruptedException
 */
private synchronized void changeInstances(String flowletName,final int newInstanceCount) throws ExecutionException, InterruptedException {
  Map<Integer,ProgramController> liveFlowlets=flowlets.row(flowletName);
  int liveCount=liveFlowlets.size();
  if (liveCount == newInstanceCount) {
    return;
  }
  if (liveCount < newInstanceCount) {
    increaseInstances(flowletName,newInstanceCount,liveFlowlets,liveCount);
    return;
  }
  decreaseInstances(flowletName,newInstanceCount,liveFlowlets,liveCount);
}
Program: 8053
Project: 8053
Buggy source:
@Override protected void doCommand(String name,Object value) throws Exception {
  if (!"String_Node_Str".equals(name) || !(value instanceof Integer)) {
    return;
  }
  int instances=(Integer)value;
  LOG.info("String_Node_Str" + flowletName + "String_Node_Str"+ instances);
  driver.suspend();
  flowletContext.setInstanceCount(instances);
  driver.resume();
  LOG.info("String_Node_Str" + flowletName + "String_Node_Str"+ instances);
}

Fixed version (ground truth):
@Override protected void doCommand(String name,Object value) throws Exception {
  Preconditions.checkState(getState() == State.SUSPENDED,"String_Node_Str");
  if (!"String_Node_Str".equals(name) || !(value instanceof Integer)) {
    return;
  }
  int instances=(Integer)value;
  LOG.info("String_Node_Str" + flowletContext + "String_Node_Str"+ instances);
  flowletContext.setInstanceCount(instances);
  LOG.info("String_Node_Str" + flowletContext + "String_Node_Str"+ instances);
}
Program: 8054
Project: 8054
Buggy source:
private ProgramController programController(String programName,final String flowletName,final BasicFlowletContext flowletContext,final FlowletProcessDriver driver){
  return new AbstractProgramController(programName + "String_Node_Str" + flowletName,flowletContext.getRunId()){
    @Override protected void doSuspend() throws Exception {
      LOG.info("String_Node_Str" + flowletName);
      driver.suspend();
      LOG.info("String_Node_Str" + flowletName);
    }
    @Override protected void doResume() throws Exception {
      LOG.info("String_Node_Str" + flowletName);
      driver.resume();
      LOG.info("String_Node_Str" + flowletName);
    }
    @Override protected void doStop() throws Exception {
      LOG.info("String_Node_Str" + flowletName);
      driver.stopAndWait();
      LOG.info("String_Node_Str" + flowletName);
    }
    @Override protected void doCommand(    String name,    Object value) throws Exception {
      if (!"String_Node_Str".equals(name) || !(value instanceof Integer)) {
        return;
      }
      int instances=(Integer)value;
      LOG.info("String_Node_Str" + flowletName + "String_Node_Str"+ instances);
      driver.suspend();
      flowletContext.setInstanceCount(instances);
      driver.resume();
      LOG.info("String_Node_Str" + flowletName + "String_Node_Str"+ instances);
    }
  }
;
}

Fixed version (ground truth):
private ProgramController programController(String programName,final String flowletName,final BasicFlowletContext flowletContext,final FlowletProcessDriver driver){
  return new AbstractProgramController(programName + "String_Node_Str" + flowletName,flowletContext.getRunId()){
    @Override protected void doSuspend() throws Exception {
      LOG.info("String_Node_Str" + flowletName);
      driver.suspend();
      LOG.info("String_Node_Str" + flowletName);
    }
    @Override protected void doResume() throws Exception {
      LOG.info("String_Node_Str" + flowletName);
      driver.resume();
      LOG.info("String_Node_Str" + flowletName);
    }
    @Override protected void doStop() throws Exception {
      LOG.info("String_Node_Str" + flowletName);
      driver.stopAndWait();
      LOG.info("String_Node_Str" + flowletName);
    }
    @Override protected void doCommand(    String name,    Object value) throws Exception {
      Preconditions.checkState(getState() == State.SUSPENDED,"String_Node_Str");
      if (!"String_Node_Str".equals(name) || !(value instanceof Integer)) {
        return;
      }
      int instances=(Integer)value;
      LOG.info("String_Node_Str" + flowletContext + "String_Node_Str"+ instances);
      flowletContext.setInstanceCount(instances);
      LOG.info("String_Node_Str" + flowletContext + "String_Node_Str"+ instances);
    }
  }
;
}
Program: 8055
Project: 8055
Buggy source:
/** 
 * Executes the <code>Application.configure</code> within the same JVM. <p> This method could be dangerous and should be used only in singlenode. </p>
 * @return A instance of {@link ListenableFuture}.
 */
@Override public ListenableFuture<ConfigResponse> config(){
  StringWriter writer=null;
  SettableFuture result=SettableFuture.create();
  try {
    Application app=null;
    if (archive != null && application == null) {
      Object mainClass=new Archive(id,archive).getMainClass().newInstance();
      app=(Application)mainClass;
    }
 else     if (application != null && archive == null) {
      app=application;
    }
 else {
      throw new IllegalStateException("String_Node_Str");
    }
    ApplicationSpecification specification=app.configure();
    writer=new StringWriter();
    ApplicationSpecificationAdapter.create(new ReflectionSchemaGenerator()).toJson(specification,writer);
    result.set(new DefaultConfigResponse(0,newStringStream(writer.toString())));
  }
 catch (  Exception e) {
    return Futures.immediateFailedFuture(e);
  }
catch (  Throwable throwable) {
    return Futures.immediateFailedFuture(throwable);
  }
 finally {
    if (writer != null) {
      try {
        writer.close();
      }
 catch (      IOException e) {
        LOG.debug(StackTraceUtil.toStringStackTrace(e));
        return Futures.immediateFailedFuture(e);
      }
    }
  }
  return result;
}

Fixed version (ground truth):
/** 
 * Executes the <code>Application.configure</code> within the same JVM. <p> This method could be dangerous and should be used only in singlenode. </p>
 * @return A instance of {@link ListenableFuture}.
 */
@Override public ListenableFuture<ConfigResponse> config(){
  StringWriter writer=null;
  SettableFuture result=SettableFuture.create();
  try {
    Application app=null;
    if (archive != null && application == null) {
      Object mainClass=new Archive(id,archive).getMainClass().newInstance();
      app=(Application)mainClass;
    }
 else     if (application != null && archive == null) {
      app=application;
    }
 else {
      throw new IllegalStateException("String_Node_Str");
    }
    ApplicationSpecification specification=app.configure();
    writer=new StringWriter();
    ApplicationSpecificationAdapter.create(new ReflectionSchemaGenerator()).toJson(specification,writer);
    result.set(new DefaultConfigResponse(0,newStringStream(writer.toString())));
  }
 catch (  Exception e) {
    LOG.debug(StackTraceUtil.toStringStackTrace(e));
    return Futures.immediateFailedFuture(e);
  }
catch (  Throwable throwable) {
    LOG.debug(StackTraceUtil.toStringStackTrace(throwable));
    return Futures.immediateFailedFuture(throwable);
  }
 finally {
    if (writer != null) {
      try {
        writer.close();
      }
 catch (      IOException e) {
        LOG.debug(StackTraceUtil.toStringStackTrace(e));
        return Futures.immediateFailedFuture(e);
      }
    }
  }
  return result;
}
Program: 8056
Project: 8056
Buggy source:
private QueueConsumer createQueueConsumer(){
  int groupId=100000 + Objects.hashCode(getFlowletId(),getFlowletId());
  QueueConfig config=new QueueConfig(QueuePartitioner.PartitionerType.FIFO,!asyncMode);
  return new QueueConsumer(getInstanceId(),groupId,getInstanceCount(),getMetricName(),config);
}

Fixed version (ground truth):
private QueueConsumer createQueueConsumer(){
  int groupId=100000 + Objects.hashCode(getAccountId(),getApplicationId(),getFlowId(),getFlowletId());
  QueueConfig config=new QueueConfig(QueuePartitioner.PartitionerType.FIFO,!asyncMode);
  return new QueueConsumer(getInstanceId(),groupId,getInstanceCount(),getMetricName(),config);
}
Program: 8057
Project: 8057
Buggy source:
@Override public synchronized Class<?> loadClass(String className,boolean resolveIt) throws ClassNotFoundException {
  Class<?> result=classes.get(className);
  if (result != null) {
    return result;
  }
  try {
    result=super.findSystemClass(className);
    return result;
  }
 catch (  ClassNotFoundException e) {
    if (LOG.isTraceEnabled()) {
      LOG.trace("String_Node_Str",className,e.getMessage());
    }
  }
  byte[] classBytes=loadClassBytes(className);
  if (classBytes == null) {
    throw new ClassNotFoundException();
  }
  result=defineClass(className,classBytes,0,classBytes.length);
  if (result == null) {
    throw new ClassFormatError("String_Node_Str" + className);
  }
  if (resolveIt) {
    resolveClass(result);
  }
  classes.put(className,result);
  return result;
}

Fixed version (ground truth):
@Override public synchronized Class<?> loadClass(String className,boolean resolveIt) throws ClassNotFoundException {
  Class<?> result=classes.get(className);
  if (result != null) {
    return result;
  }
  try {
    result=super.findSystemClass(className);
    return result;
  }
 catch (  ClassNotFoundException e) {
    if (LOG.isTraceEnabled()) {
      LOG.trace("String_Node_Str",className,e.getMessage());
    }
  }
  byte[] classBytes=loadClassBytes(className);
  if (classBytes == null) {
    throw new ClassNotFoundException(className);
  }
  result=defineClass(className,classBytes,0,classBytes.length);
  if (result == null) {
    throw new ClassFormatError("String_Node_Str" + className);
  }
  if (resolveIt) {
    resolveClass(result);
  }
  classes.put(className,result);
  return result;
}
Program: 8058
Project: 8058
Buggy source:
/** 
 * Executes the <code>Application.configure</code> within the same JVM. <p> This method could be dangerous and should be used only in singlenode. </p>
 * @return A instance of {@link ListenableFuture}.
 */
@Override public ListenableFuture<ConfigResponse> config(){
  StringWriter writer=null;
  SettableFuture result=SettableFuture.create();
  try {
    Application app=null;
    if (archive != null && application == null) {
      Object mainClass=new Archive(id,archive).getMainClass().newInstance();
      app=(Application)mainClass;
    }
 else     if (application != null && archive == null) {
      app=application;
    }
 else {
      throw new IllegalStateException("String_Node_Str");
    }
    ApplicationSpecification specification=app.configure();
    writer=new StringWriter();
    ApplicationSpecificationAdapter.create(new ReflectionSchemaGenerator()).toJson(specification,writer);
    result.set(new DefaultConfigResponse(0,newStringStream(writer.toString())));
  }
 catch (  Exception e) {
    return Futures.immediateFailedFuture(e);
  }
catch (  Throwable throwable) {
    return Futures.immediateFailedFuture(throwable);
  }
 finally {
    if (writer != null) {
      try {
        writer.close();
      }
 catch (      IOException e) {
        Futures.immediateFailedFuture(e);
      }
    }
  }
  return result;
}

Fixed version (ground truth):
/** 
 * Executes the <code>Application.configure</code> within the same JVM. <p> This method could be dangerous and should be used only in singlenode. </p>
 * @return A instance of {@link ListenableFuture}.
 */
@Override public ListenableFuture<ConfigResponse> config(){
  StringWriter writer=null;
  SettableFuture result=SettableFuture.create();
  try {
    Application app=null;
    if (archive != null && application == null) {
      Object mainClass=new Archive(id,archive).getMainClass().newInstance();
      app=(Application)mainClass;
    }
 else     if (application != null && archive == null) {
      app=application;
    }
 else {
      throw new IllegalStateException("String_Node_Str");
    }
    ApplicationSpecification specification=app.configure();
    writer=new StringWriter();
    ApplicationSpecificationAdapter.create(new ReflectionSchemaGenerator()).toJson(specification,writer);
    result.set(new DefaultConfigResponse(0,newStringStream(writer.toString())));
  }
 catch (  Exception e) {
    return Futures.immediateFailedFuture(e);
  }
catch (  Throwable throwable) {
    return Futures.immediateFailedFuture(throwable);
  }
 finally {
    if (writer != null) {
      try {
        writer.close();
      }
 catch (      IOException e) {
        LOG.debug(StackTraceUtil.toStringStackTrace(e));
        return Futures.immediateFailedFuture(e);
      }
    }
  }
  return result;
}
Program: 8059
Project: 8059
Buggy source:
@Override public synchronized Class<?> loadClass(String className,boolean resolveIt) throws ClassNotFoundException {
  Class<?> result=classes.get(className);
  if (result != null) {
    return result;
  }
  try {
    result=super.findSystemClass(className);
    return result;
  }
 catch (  ClassNotFoundException e) {
    if (LOG.isTraceEnabled()) {
      LOG.trace("String_Node_Str",className,e.getMessage());
    }
  }
  byte[] classBytes=loadClassBytes(className);
  if (classBytes == null) {
    throw new ClassNotFoundException();
  }
  result=defineClass(className,classBytes,0,classBytes.length);
  if (result == null) {
    throw new ClassFormatError("String_Node_Str" + className);
  }
  if (resolveIt) {
    resolveClass(result);
  }
  classes.put(className,result);
  return result;
}

Fixed version (ground truth):
@Override public synchronized Class<?> loadClass(String className,boolean resolveIt) throws ClassNotFoundException {
  Class<?> result=classes.get(className);
  if (result != null) {
    return result;
  }
  try {
    result=super.findSystemClass(className);
    return result;
  }
 catch (  ClassNotFoundException e) {
    if (LOG.isTraceEnabled()) {
      LOG.trace("String_Node_Str",className,e.getMessage());
    }
  }
  byte[] classBytes=loadClassBytes(className);
  if (classBytes == null) {
    throw new ClassNotFoundException(className);
  }
  result=defineClass(className,classBytes,0,classBytes.length);
  if (result == null) {
    throw new ClassFormatError("String_Node_Str" + className);
  }
  if (resolveIt) {
    resolveClass(result);
  }
  classes.put(className,result);
  return result;
}
Program: 8060
Project: 8060
Buggy source:
@Override public synchronized Class<?> loadClass(String className,boolean resolveIt) throws ClassNotFoundException {
  Class<?> result=classes.get(className);
  if (result != null) {
    return result;
  }
  try {
    result=super.findSystemClass(className);
    return result;
  }
 catch (  ClassNotFoundException e) {
    if (LOG.isTraceEnabled()) {
      LOG.trace("String_Node_Str",className,e.getMessage());
    }
  }
  byte[] classBytes=loadClassBytes(className);
  if (classBytes == null) {
    throw new ClassNotFoundException();
  }
  result=defineClass(className,classBytes,0,classBytes.length);
  if (result == null) {
    throw new ClassFormatError("String_Node_Str" + className);
  }
  if (resolveIt) {
    resolveClass(result);
  }
  classes.put(className,result);
  return result;
}

Fixed version (ground truth):
@Override public synchronized Class<?> loadClass(String className,boolean resolveIt) throws ClassNotFoundException {
  Class<?> result=classes.get(className);
  if (result != null) {
    return result;
  }
  try {
    result=super.findSystemClass(className);
    return result;
  }
 catch (  ClassNotFoundException e) {
    if (LOG.isTraceEnabled()) {
      LOG.trace("String_Node_Str",className,e.getMessage());
    }
  }
  byte[] classBytes=loadClassBytes(className);
  if (classBytes == null) {
    throw new ClassNotFoundException(className);
  }
  result=defineClass(className,classBytes,0,classBytes.length);
  if (result == null) {
    throw new ClassFormatError("String_Node_Str" + className);
  }
  if (resolveIt) {
    resolveClass(result);
  }
  classes.put(className,result);
  return result;
}
Program: 8061
Project: 8061
Buggy source:
@Test public void testValidInvalidPromoteArgs() throws ParseException {
  AppFabricClient client=new AppFabricClient();
  String command=null;
  command=client.configure(CConfiguration.create(),new String[]{"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"});
  assert(command == null);
  command=client.configure(CConfiguration.create(),new String[]{"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"});
  assert(command == null);
  command=client.configure(CConfiguration.create(),new String[]{"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"});
  assert(command == null);
}

Fixed version (ground truth):
@Test(expected=IllegalArgumentException.class) public void testValidInvalidPromoteArgs() throws ParseException {
  AppFabricClient client=new AppFabricClient();
  String command=null;
  command=client.configure(CConfiguration.create(),new String[]{"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"});
  assert(command == null);
  command=client.configure(CConfiguration.create(),new String[]{"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"});
  assert(command == null);
  command=client.configure(CConfiguration.create(),new String[]{"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"});
  assert(command == null);
}
Program: 8062
Project: 8062
Buggy source:
@Test public void testValidInvalidStopArgs() throws ParseException {
  AppFabricClient client=new AppFabricClient();
  String command=null;
  command=client.configure(CConfiguration.create(),new String[]{"String_Node_Str","String_Node_Str","String_Node_Str"});
  assertTrue(command == null);
  command=client.configure(CConfiguration.create(),new String[]{"String_Node_Str","String_Node_Str","String_Node_Str"});
  assertTrue(command == null);
}

Fixed version (ground truth):
@Test(expected=IllegalArgumentException.class) public void testValidInvalidStopArgs() throws ParseException {
  AppFabricClient client=new AppFabricClient();
  String command=null;
  command=client.configure(CConfiguration.create(),new String[]{"String_Node_Str","String_Node_Str","String_Node_Str"});
  assertTrue(command == null);
  command=client.configure(CConfiguration.create(),new String[]{"String_Node_Str","String_Node_Str","String_Node_Str"});
  assertTrue(command == null);
}
Program: 8063
Project: 8063
Buggy source:
@Test public void testValidInvalidDeployArgs() throws ParseException {
  AppFabricClient client=new AppFabricClient();
  String command=null;
  command=client.configure(CConfiguration.create(),new String[]{"String_Node_Str"});
  assertTrue(command == null);
}

Fixed version (ground truth):
@Test(expected=IllegalArgumentException.class) public void testValidInvalidDeployArgs() throws ParseException {
  AppFabricClient client=new AppFabricClient();
  String command=null;
  command=client.configure(CConfiguration.create(),new String[]{"String_Node_Str"});
  assertTrue(command == null);
}
Program: 8064
Project: 8064
Buggy source:
@Test public void testValidInvalidVerifyArgs() throws ParseException {
  AppFabricClient client=new AppFabricClient();
  String command=null;
  command=client.configure(CConfiguration.create(),new String[]{"String_Node_Str","String_Node_Str","String_Node_Str"});
  assertTrue(command == null);
}

Fixed version (ground truth):
@Test(expected=IllegalArgumentException.class) public void testValidInvalidVerifyArgs() throws ParseException {
  AppFabricClient client=new AppFabricClient();
  String command=null;
  command=client.configure(CConfiguration.create(),new String[]{"String_Node_Str","String_Node_Str","String_Node_Str"});
  assertTrue(command == null);
}
Program: 8065
Project: 8065
Buggy source:
@Test(expected=RuntimeException.class) public void testValidInvalidStartArgs() throws ParseException {
  AppFabricClient client=new AppFabricClient();
  String command=null;
  command=client.configure(CConfiguration.create(),new String[]{"String_Node_Str","String_Node_Str","String_Node_Str"});
}

Fixed version (ground truth):
@Test(expected=IllegalArgumentException.class) public void testValidInvalidStartArgs() throws ParseException {
  AppFabricClient client=new AppFabricClient();
  String command=null;
  command=client.configure(CConfiguration.create(),new String[]{"String_Node_Str","String_Node_Str","String_Node_Str"});
  assertTrue(command == null);
  command=client.configure(CConfiguration.create(),new String[]{"String_Node_Str","String_Node_Str","String_Node_Str"});
  assertTrue(command == null);
}
Program: 8066
Project: 8066
Buggy source:
@Test public void testValidInvalidStatusArgs() throws ParseException {
  AppFabricClient client=new AppFabricClient();
  String command=null;
  command=client.configure(CConfiguration.create(),new String[]{"String_Node_Str","String_Node_Str","String_Node_Str"});
  assertTrue(command == null);
  command=client.configure(CConfiguration.create(),new String[]{"String_Node_Str","String_Node_Str","String_Node_Str"});
  assertTrue(command == null);
}

Fixed version (ground truth):
@Test(expected=IllegalArgumentException.class) public void testValidInvalidStatusArgs() throws ParseException {
  AppFabricClient client=new AppFabricClient();
  String command=null;
  command=client.configure(CConfiguration.create(),new String[]{"String_Node_Str","String_Node_Str","String_Node_Str"});
  assertTrue(command == null);
  command=client.configure(CConfiguration.create(),new String[]{"String_Node_Str","String_Node_Str","String_Node_Str"});
  assertTrue(command == null);
}
Program: 8067
Project: 8067
Buggy source:
@Test public void testUnknownCommands() throws ParseException {
  AppFabricClient client=new AppFabricClient();
  String command=client.configure(CConfiguration.create(),new String[]{"String_Node_Str","String_Node_Str","String_Node_Str"});
  assertTrue(command == null);
}

Fixed version (ground truth):
@Test(expected=IllegalArgumentException.class) public void testUnknownCommands() throws ParseException {
  AppFabricClient client=new AppFabricClient();
  String command=client.configure(CConfiguration.create(),new String[]{"String_Node_Str","String_Node_Str","String_Node_Str"});
  assertTrue(command == null);
}
Program: 8068
Project: 8068
Buggy source:
public void generate() throws InterruptedException {
  Integer randomNumber=new Integer(this.random.nextInt(10000));
  Thread.sleep(millis);
  millis+=direction;
  if (millis > 100 || millis < 1) {
    direction=direction * -1;
  }
  randomOutput.emit(randomNumber);
}

Fixed version (ground truth):
public void generate() throws InterruptedException {
  Integer randomNumber=new Integer(this.random.nextInt(10000));
  Thread.sleep(millis);
  millis*=direction;
  if (millis > 100 || millis < 1) {
    direction=direction * -1;
  }
  randomOutput.emit(randomNumber);
}
Program: 8069
Project: 8069
Buggy source:
public boolean isRetry(){
  return retry;
}

Fixed version (ground truth):
public boolean isRetry(){
  return retrySpec != null;
}
Program: 8071
Project: 8071
Buggy source:
@Override public void onFailure(Object inputObject,InputContext inputContext,FailureReason reason,PostProcess.InputAcknowledger inputAcknowledger){
  LOG.info("String_Node_Str" + reason.getMessage(),reason.getCause());
  FailurePolicy failurePolicy;
  inflight.decrementAndGet();
  try {
    flowletContext.getMetrics().count("String_Node_Str",1);
    failurePolicy=txCallback.onFailure(inputObject,inputContext,reason);
  }
 catch (  Throwable t) {
    LOG.info("String_Node_Str" + flowletContext,t);
    failurePolicy=FailurePolicy.RETRY;
  }
  if (input.getRetry() >= PROCESS_MAX_RETRY) {
    failurePolicy=FailurePolicy.IGNORE;
  }
  if (failurePolicy == FailurePolicy.RETRY) {
    ProcessEntry retryEntry=processEntry.isRetry() ? processEntry : new ProcessEntry(new ProcessSpecification(new SingleItemQueueReader(input),processEntry.processSpec.getProcessMethod()),true);
    processQueue.offer(retryEntry);
  }
 else   if (failurePolicy == FailurePolicy.IGNORE) {
    try {
      flowletContext.getMetrics().count("String_Node_Str",1);
      inputAcknowledger.ack();
    }
 catch (    OperationException e) {
      LOG.error("String_Node_Str" + flowletContext,e);
    }
  }
}

Fixed version (ground truth):
@Override public void onFailure(Object inputObject,InputContext inputContext,FailureReason reason,PostProcess.InputAcknowledger inputAcknowledger){
  LOG.info("String_Node_Str" + reason.getMessage(),reason.getCause());
  FailurePolicy failurePolicy;
  inflight.decrementAndGet();
  try {
    flowletContext.getMetrics().count("String_Node_Str",1);
    failurePolicy=txCallback.onFailure(inputObject,inputContext,reason);
  }
 catch (  Throwable t) {
    LOG.error("String_Node_Str" + flowletContext,t);
    failurePolicy=FailurePolicy.RETRY;
  }
  if (input.getRetry() >= PROCESS_MAX_RETRY) {
    LOG.info("String_Node_Str" + input);
    failurePolicy=FailurePolicy.IGNORE;
  }
  if (failurePolicy == FailurePolicy.RETRY) {
    ProcessEntry retryEntry=processEntry.isRetry() ? processEntry : new ProcessEntry(processEntry.getProcessSpec(),new ProcessSpecification(new SingleItemQueueReader(input),processEntry.getProcessSpec().getProcessMethod()));
    processQueue.offer(retryEntry);
  }
 else   if (failurePolicy == FailurePolicy.IGNORE) {
    try {
      flowletContext.getMetrics().count("String_Node_Str",1);
      inputAcknowledger.ack();
    }
 catch (    OperationException e) {
      LOG.error("String_Node_Str" + flowletContext,e);
    }
 finally {
      enqueueEntry();
    }
  }
}
Program: 8072
Project: 8072
Buggy source:
private ProcessEntry(ProcessSpecification processSpec,boolean retry){
  this.processSpec=processSpec;
  this.retry=retry;
}

Fixed version (ground truth):
private ProcessEntry(ProcessSpecification processSpec,ProcessSpecification retrySpec){
  this.processSpec=processSpec;
  this.retrySpec=retrySpec;
}
Program: 8074
Project: 8074
Buggy source:
@Override public void onSuccess(Object object,InputContext inputContext){
  inflight.decrementAndGet();
  try {
    flowletContext.getMetrics().count("String_Node_Str",1);
    txCallback.onSuccess(object,inputContext);
  }
 catch (  Throwable t) {
    LOG.info("String_Node_Str" + flowletContext,t);
  }
}

Fixed version (ground truth):
@Override public void onSuccess(Object object,InputContext inputContext){
  inflight.decrementAndGet();
  try {
    flowletContext.getMetrics().count("String_Node_Str",1);
    txCallback.onSuccess(object,inputContext);
  }
 catch (  Throwable t) {
    LOG.info("String_Node_Str" + flowletContext,t);
  }
 finally {
    enqueueEntry();
  }
}
Program: 8075
Project: 8075
Buggy source:
@Override public String toString(){
  if (!dequeueResult.isEmpty()) {
    return String.format("String_Node_Str",queueName,dequeueResult.getEntryPointer().getEntryId(),retry);
  }
 else {
    return String.format("String_Node_Str",queueName,retry);
  }
}

Fixed version (ground truth):
@Override public String toString(){
  if (!dequeueResult.isEmpty()) {
    return String.format("String_Node_Str",queueName,dequeueResult.getEntryPointer().getEntryId(),retry.get());
  }
 else {
    return String.format("String_Node_Str",queueName,retry.get());
  }
}
Program: 8077
Project: 8077
Buggy source:
@Override public void onFailure(Object inputObject,InputContext inputContext,FailureReason reason,PostProcess.InputAcknowledger inputAcknowledger){
  FailurePolicy failurePolicy;
  inflight.decrementAndGet();
  try {
    failurePolicy=txCallback.onFailure(inputObject,inputContext,reason);
  }
 catch (  Throwable t) {
    LOG.info("String_Node_Str" + flowletContext,t);
    failurePolicy=FailurePolicy.RETRY;
  }
  if (input.getRetry() >= PROCESS_MAX_RETRY) {
    failurePolicy=FailurePolicy.IGNORE;
  }
  if (failurePolicy == FailurePolicy.RETRY) {
    ProcessEntry retryEntry=processEntry.isRetry() ? processEntry : new ProcessEntry(new ProcessSpecification(new SingleItemQueueReader(input),processEntry.processSpec.getProcessMethod()),true);
    processQueue.offer(retryEntry);
  }
 else   if (failurePolicy == FailurePolicy.IGNORE) {
    try {
      inputAcknowledger.ack();
    }
 catch (    OperationException e) {
      LOG.error("String_Node_Str" + flowletContext,e);
    }
  }
}

Fixed version (ground truth):
@Override public void onFailure(Object inputObject,InputContext inputContext,FailureReason reason,PostProcess.InputAcknowledger inputAcknowledger){
  FailurePolicy failurePolicy;
  inflight.decrementAndGet();
  try {
    flowletContext.getMetrics().count("String_Node_Str",1);
    failurePolicy=txCallback.onFailure(inputObject,inputContext,reason);
  }
 catch (  Throwable t) {
    LOG.info("String_Node_Str" + flowletContext,t);
    failurePolicy=FailurePolicy.RETRY;
  }
  if (input.getRetry() >= PROCESS_MAX_RETRY) {
    failurePolicy=FailurePolicy.IGNORE;
  }
  if (failurePolicy == FailurePolicy.RETRY) {
    ProcessEntry retryEntry=processEntry.isRetry() ? processEntry : new ProcessEntry(new ProcessSpecification(new SingleItemQueueReader(input),processEntry.processSpec.getProcessMethod()),true);
    processQueue.offer(retryEntry);
  }
 else   if (failurePolicy == FailurePolicy.IGNORE) {
    try {
      flowletContext.getMetrics().count("String_Node_Str",1);
      inputAcknowledger.ack();
    }
 catch (    OperationException e) {
      LOG.error("String_Node_Str" + flowletContext,e);
    }
  }
}
Program: 8078
Project: 8078
Buggy source:
@Override public void onSuccess(Object object,InputContext inputContext){
  inflight.decrementAndGet();
  try {
    txCallback.onSuccess(object,inputContext);
  }
 catch (  Throwable t) {
    LOG.info("String_Node_Str" + flowletContext,t);
  }
}

Fixed version (ground truth):
@Override public void onSuccess(Object object,InputContext inputContext){
  inflight.decrementAndGet();
  try {
    flowletContext.getMetrics().count("String_Node_Str",1);
    txCallback.onSuccess(object,inputContext);
  }
 catch (  Throwable t) {
    LOG.info("String_Node_Str" + flowletContext,t);
  }
}
Program: 8079
Project: 8079
Buggy source:
/** 
 * Finds the right schema to be used for the connections. <p> A connection should have the following: <ul> <li>Equal overrides compatible : So if there is equal, we use that</li> <li>In case of compatible, we try to find one schema and only one. More than one is a error.</li> </ul> </p>
 * @param output Set of output {@link Schema}.
 * @param input  Set of input {@link Schema}.
 * @return An {@link ImmutablePair} with first as input schema and second as output schema.
 */
@Nullable public static ImmutablePair<Schema,Schema> findSchema(Set<Schema> output,Set<Schema> input){
  ImmutablePair<Schema,Schema> compatibleSchema=null;
  for (  Schema outputSchema : output) {
    for (    Schema inputSchema : input) {
      if (outputSchema.equals(inputSchema)) {
        return new ImmutablePair<Schema,Schema>(inputSchema,outputSchema);
      }
      if (outputSchema.isCompatible(inputSchema)) {
        if (compatibleSchema != null) {
          return null;
        }
        compatibleSchema=new ImmutablePair<Schema,Schema>(inputSchema,outputSchema);
      }
    }
  }
  return compatibleSchema;
}

Fixed version (ground truth):
/** 
 * Finds the right schema to be used for the connections. <p> A connection should have the following: <ul> <li>Equal overrides compatible : So if there is equal, we use that</li> <li>In case of compatible, we try to find one schema and only one. More than one is a error.</li> </ul> </p>
 * @param output Set of output {@link Schema}.
 * @param input  Set of input {@link Schema}.
 * @return An {@link ImmutablePair} with first as output schema and second as input schema.
 */
@Nullable public static ImmutablePair<Schema,Schema> findSchema(Set<Schema> output,Set<Schema> input){
  ImmutablePair<Schema,Schema> compatibleSchema=null;
  for (  Schema outputSchema : output) {
    for (    Schema inputSchema : input) {
      if (outputSchema.equals(inputSchema)) {
        return new ImmutablePair<Schema,Schema>(inputSchema,outputSchema);
      }
      if (outputSchema.isCompatible(inputSchema)) {
        if (compatibleSchema != null) {
          return null;
        }
        compatibleSchema=new ImmutablePair<Schema,Schema>(outputSchema,inputSchema);
      }
    }
  }
  return compatibleSchema;
}
Program: 8080
Project: 8080
Buggy source:
/** 
 * @return An instance of {@link QueueSpecification} containing the URI for the queueand the matching  {@link Schema}
 */
protected QueueSpecification createSpec(final QueueName queueName,final Schema inputSchema,final Schema outputSchema){
  return new QueueSpecification(){
    @Override public QueueName getQueueName(){
      return queueName;
    }
    @Override public Schema getInputSchema(){
      return inputSchema;
    }
    @Override public Schema getOutputSchema(){
      return outputSchema;
    }
    @Override public int hashCode(){
      return Objects.hashCode(getQueueName(),getInputSchema(),getOutputSchema());
    }
    @Override public boolean equals(    Object obj){
      if (obj == null || !(obj instanceof QueueSpecification)) {
        return false;
      }
      QueueSpecification other=(QueueSpecification)obj;
      return Objects.equal(getQueueName(),other.getQueueName()) && Objects.equal(getInputSchema(),other.getInputSchema()) && Objects.equal(getOutputSchema(),other.getOutputSchema());
    }
  }
;
}

Fixed version (ground truth):
/** 
 * @return An instance of {@link QueueSpecification} containing the URI for the queueand the matching  {@link Schema}
 */
protected QueueSpecification createSpec(final QueueName queueName,final Schema outputSchema,final Schema inputSchema){
  return new QueueSpecification(){
    @Override public QueueName getQueueName(){
      return queueName;
    }
    @Override public Schema getInputSchema(){
      return inputSchema;
    }
    @Override public Schema getOutputSchema(){
      return outputSchema;
    }
    @Override public int hashCode(){
      return Objects.hashCode(getQueueName(),getInputSchema(),getOutputSchema());
    }
    @Override public boolean equals(    Object obj){
      if (obj == null || !(obj instanceof QueueSpecification)) {
        return false;
      }
      QueueSpecification other=(QueueSpecification)obj;
      return Objects.equal(getQueueName(),other.getQueueName()) && Objects.equal(getInputSchema(),other.getInputSchema()) && Objects.equal(getOutputSchema(),other.getOutputSchema());
    }
    @Override public String toString(){
      return queueName.toString();
    }
  }
;
}
Program: 8082
Project: 8082
Buggy source:
@Override public ProgramController run(Program program,ProgramOptions options){
  ApplicationSpecification appSpec=program.getSpecification();
  Preconditions.checkNotNull(appSpec,"String_Node_Str");
  Type processorType=program.getProcessorType();
  Preconditions.checkNotNull(processorType,"String_Node_Str");
  Preconditions.checkArgument(processorType == Type.PROCEDURE,"String_Node_Str");
  ProcedureSpecification procedureSpec=appSpec.getProcedures().get(program.getProgramName());
  Preconditions.checkNotNull(procedureSpec,"String_Node_Str",program.getProgramName());
  RunId runId=RunId.generate();
  bootstrap=createBootstrap(program);
  return null;
}

Fixed version (ground truth):
@Override public ProgramController run(Program program,ProgramOptions options){
  try {
    ApplicationSpecification appSpec=program.getSpecification();
    Preconditions.checkNotNull(appSpec,"String_Node_Str");
    Type processorType=program.getProcessorType();
    Preconditions.checkNotNull(processorType,"String_Node_Str");
    Preconditions.checkArgument(processorType == Type.PROCEDURE,"String_Node_Str");
    ProcedureSpecification procedureSpec=appSpec.getProcedures().get(program.getProgramName());
    Preconditions.checkNotNull(procedureSpec,"String_Node_Str",program.getProgramName());
    int instanceId=Integer.parseInt(options.getArguments().getOption("String_Node_Str","String_Node_Str"));
    Class<? extends Procedure> procedureClass=(Class<? extends Procedure>)program.getMainClass();
    ClassLoader classLoader=procedureClass.getClassLoader();
    RunId runId=RunId.generate();
    OperationContext opCtx=new OperationContext(program.getAccountId(),program.getApplicationId());
    TransactionProxy transactionProxy=new TransactionProxy();
    DataFabric dataFabric=new DataFabricImpl(opex,opCtx);
    DataSetInstantiator dataSetInstantiator=new DataSetInstantiator(dataFabric,transactionProxy,classLoader);
    dataSetInstantiator.setReadOnly();
    dataSetInstantiator.setDataSets(ImmutableList.copyOf(appSpec.getDataSets().values()));
    BasicProcedureContext procedureContext=new BasicProcedureContext(program,instanceId,runId,DataSets.createDataSets(dataSetInstantiator,procedureSpec.getDataSets()),procedureSpec);
    bootstrap=createBootstrap(program);
    return null;
  }
 catch (  Exception e) {
    throw Throwables.propagate(e);
  }
}
Program: 8083
Project: 8083
Buggy source:
@BeforeClass public static void startService() throws Exception {
  Injector injector=Guice.createInjector(new DataFabricLevelDBModule());
  OperationExecutorServiceTest.startService(CConfiguration.create(),injector.getInstance(OperationExecutor.class));
}

Fixed version (ground truth):
@BeforeClass public static void startService() throws Exception {
  CConfiguration configuration=CConfiguration.create();
  configuration.unset("String_Node_Str");
  Injector injector=Guice.createInjector(new DataFabricLevelDBModule());
  OperationExecutorServiceTest.startService(CConfiguration.create(),injector.getInstance(OperationExecutor.class));
}
Program: 8085
Project: 8085
Buggy source:
/** 
 * Shutdown the service.
 */
public void shutDown(){
  try {
    webCloudAppService.stop(true);
    gateway.stop(true);
    metaDataServer.stop(true);
    overloadFrontend.stop(true);
    overlordCollection.stop(true);
    metaDataServer.stop(true);
    appFabricServer.startAndWait();
  }
 catch (  ServerException e) {
    LOG.error(StackTraceUtil.toStringStackTrace(e));
  }
}

Fixed version (ground truth):
/** 
 * Shutdown the service.
 */
public void shutDown(){
  try {
    webCloudAppService.stop(true);
    gateway.stop(true);
    metaDataServer.stop(true);
    overloadFrontend.stop(true);
    overlordCollection.stop(true);
    metaDataServer.stop(true);
    appFabricServer.startAndWait();
  }
 catch (  Exception e) {
    LOG.error(StackTraceUtil.toStringStackTrace(e));
  }
}
Program: 8088
Project: 8088
Buggy source:
BasicFlowletContext(Program program,String flowletId,int instanceId,Map<String,DataSet> datasets,FlowletSpecification flowletSpec,boolean asyncMode){
  this.accountId=program.getAccountId();
  this.applicationId=program.getApplicationId();
  this.flowId=program.getProgramName();
  this.flowletId=flowletId;
  this.runId=RunId.generate();
  this.instanceId=instanceId;
  this.datasets=ImmutableMap.copyOf(datasets);
  this.flowletSpec=flowletSpec;
  this.instanceCount=program.getSpecification().getFlows().get(flowId).getFlowlets().get(flowletId).getInstances();
  this.queueProducer=new QueueProducer(getMetricName());
  this.queueConsumer=createQueueConsumer();
  this.asyncMode=asyncMode;
  this.flowletMetrics=new FlowletMetrics(accountId,applicationId,flowId,flowletId,runId.toString(),instanceId);
  this.systemMetrics=new CMetrics(MetricType.FlowSystem,getMetricName());
}

Fixed version (ground truth):
BasicFlowletContext(Program program,String flowletId,int instanceId,Map<String,DataSet> datasets,FlowletSpecification flowletSpec,boolean asyncMode){
  this.accountId=program.getAccountId();
  this.applicationId=program.getApplicationId();
  this.flowId=program.getProgramName();
  this.flowletId=flowletId;
  this.runId=RunId.generate();
  this.instanceId=instanceId;
  this.datasets=ImmutableMap.copyOf(datasets);
  this.flowletSpec=flowletSpec;
  this.asyncMode=asyncMode;
  this.instanceCount=program.getSpecification().getFlows().get(flowId).getFlowlets().get(flowletId).getInstances();
  this.queueProducer=new QueueProducer(getMetricName());
  this.queueConsumer=createQueueConsumer();
  this.flowletMetrics=new FlowletMetrics(accountId,applicationId,flowId,flowletId,runId.toString(),instanceId);
  this.systemMetrics=new CMetrics(MetricType.FlowSystem,getMetricName());
}
Program: 8089
Project: 8089
Buggy source:
private PostProcess getPostProcess(final TransactionAgent txAgent,final InputDatum input,final T event,final InputContext inputContext){
  return new PostProcess(){
    @Override public void commit(    Executor executor,    final Callback callback){
      executor.execute(new Runnable(){
        @Override public void run(){
          try {
            input.submitAck(txAgent);
            txAgent.finish();
            callback.onSuccess(event,inputContext);
          }
 catch (          Throwable t) {
            LOGGER.error("String_Node_Str",t);
            callback.onFailure(event,inputContext,new FailureReason(FailureReason.Type.IO_ERROR,t.getMessage()),new SimpleInputAcknowledger(txAgentSupplier,input));
          }
        }
      }
);
    }
  }
;
}

Fixed version (ground truth):
private PostProcess getPostProcess(final TransactionAgent txAgent,final InputDatum input,final T event,final InputContext inputContext){
  return new PostProcess(){
    @Override public void commit(    Executor executor,    final Callback callback){
      executor.execute(new Runnable(){
        @Override public void run(){
          try {
            input.submitAck(txAgent);
            txAgent.finish();
            callback.onSuccess(event,inputContext);
          }
 catch (          Throwable t) {
            LOGGER.error("String_Node_Str" + input,t);
            callback.onFailure(event,inputContext,new FailureReason(FailureReason.Type.IO_ERROR,t.getMessage()),new SimpleInputAcknowledger(txAgentSupplier,input));
          }
        }
      }
);
    }
  }
;
}
Program: 8091
Project: 8091
Buggy source:
@Override public JsonElement serialize(ApplicationSpecification src,Type typeOfSrc,JsonSerializationContext context){
  JsonObject jsonObj=new JsonObject();
  jsonObj.add("String_Node_Str",new JsonPrimitive(src.getName()));
  jsonObj.add("String_Node_Str",new JsonPrimitive(src.getDescription()));
  jsonObj.add("String_Node_Str",context.serialize(src.getStreams(),new TypeToken<Map<String,StreamSpecification>>(){
  }
.getType()));
  jsonObj.add("String_Node_Str",context.serialize(src.getStreams(),new TypeToken<Map<String,DataSetSpecification>>(){
  }
.getType()));
  jsonObj.add("String_Node_Str",context.serialize(src.getStreams(),new TypeToken<Map<String,FlowSpecification>>(){
  }
.getType()));
  jsonObj.add("String_Node_Str",context.serialize(src.getStreams(),new TypeToken<Map<String,ProcedureSpecification>>(){
  }
.getType()));
  return jsonObj;
}

Fixed version (ground truth):
@Override public JsonElement serialize(ApplicationSpecification src,Type typeOfSrc,JsonSerializationContext context){
  JsonObject jsonObj=new JsonObject();
  jsonObj.add("String_Node_Str",new JsonPrimitive(src.getName()));
  jsonObj.add("String_Node_Str",new JsonPrimitive(src.getDescription()));
  jsonObj.add("String_Node_Str",context.serialize(src.getStreams(),new TypeToken<Map<String,StreamSpecification>>(){
  }
.getType()));
  jsonObj.add("String_Node_Str",context.serialize(src.getDataSets(),new TypeToken<Map<String,DataSetSpecification>>(){
  }
.getType()));
  jsonObj.add("String_Node_Str",context.serialize(src.getFlows(),new TypeToken<Map<String,FlowSpecification>>(){
  }
.getType()));
  jsonObj.add("String_Node_Str",context.serialize(src.getProcedures(),new TypeToken<Map<String,ProcedureSpecification>>(){
  }
.getType()));
  return jsonObj;
}
Program: 8093
Project: 8093
Buggy source:
@Override public void submit(TransactionAgent agent) throws OperationException {
  List<EmittedDatum> outputs=Lists.newArrayListWithExpectedSize(dataQueue.size());
  dataQueue.drainTo(outputs);
  agent.submit(ImmutableList.copyOf(Iterables.transform(dataQueue,DATUM_TO_WRITE_OP)));
}

Fixed version (ground truth):
@Override public void submit(TransactionAgent agent) throws OperationException {
  List<EmittedDatum> outputs=Lists.newArrayListWithExpectedSize(dataQueue.size());
  dataQueue.drainTo(outputs);
  agent.submit(ImmutableList.copyOf(Iterables.transform(outputs,DATUM_TO_WRITE_OP)));
}