nus-yam/ex-repair huggingface dataset:
Program: 8000
Project: 8000
Buggy source:
@Override public TTQueueTable getStreamTable(byte[] streamTableName) throws OperationException {
  TTQueueTable streamTable=this.streamTables.get(streamTableName);
  if (streamTable != null)   return streamTable;
  OrderedVersionedColumnarTable table=getTable(streamOVCTable);
  streamTable=new TTQueueTableOnVCTable(table,oracle,conf);
  TTQueueTable existing=this.streamTables.putIfAbsent(streamTableName,streamTable);
  return existing != null ? existing : streamTable;
}

Fixed version (ground truth):
@Override public TTQueueTable getStreamTable(byte[] streamTableName) throws OperationException {
  TTQueueTable streamTable=this.streamTables.get(streamTableName);
  if (streamTable != null)   return streamTable;
  OrderedVersionedColumnarTable table=getTable(streamOVCTable);
  streamTable=new TTQueueTableNewOnVCTable(table,oracle,conf);
  TTQueueTable existing=this.streamTables.putIfAbsent(streamTableName,streamTable);
  return existing != null ? existing : streamTable;
}
Program: 8002
Project: 8002
Buggy source:
@Override public List<Long> fetchNextEntries(QueueConsumer consumer,QueueConfig config,QueueStateImpl queueState,ReadPointer readPointer) throws OperationException {
  List<Long> newEntryIds=new ArrayList<Long>();
  ClaimedEntryRange claimedEntryRange=queueState.getClaimedEntryList().getClaimedEntry();
  if (claimedEntryRange.isValid()) {
    for (long i=claimedEntryRange.getBegin(); i <= claimedEntryRange.getEnd(); ++i) {
      newEntryIds.add(i);
    }
    return newEntryIds;
  }
  final int batchSize=getBatchSize(config);
  QueuePartitioner partitioner=config.getPartitionerType().getPartitioner();
  while (newEntryIds.isEmpty()) {
    long groupReadPointer=getGroupReadPointer(consumer);
    if (groupReadPointer + batchSize >= queueState.getQueueWritePointer()) {
      long queueWritePointer=table.incrementAtomicDirtily(makeRowName(GLOBAL_ENTRY_ID_PREFIX),GLOBAL_ENTRYID_COUNTER,0);
      queueState.setQueueWritePointer(queueWritePointer);
    }
    if (groupReadPointer >= queueState.getQueueWritePointer()) {
      return Collections.EMPTY_LIST;
    }
    long curBatchSize=groupReadPointer + (batchSize * consumer.getGroupSize()) < queueState.getQueueWritePointer() ? batchSize : (queueState.getQueueWritePointer() - groupReadPointer) / consumer.getGroupSize();
    if (curBatchSize < 1) {
      curBatchSize=1;
    }
    long endEntryId=table.incrementAtomicDirtily(makeRowKey(GROUP_READ_POINTER,consumer.getGroupId()),GROUP_READ_POINTER,curBatchSize);
    long startEntryId=endEntryId - curBatchSize + 1;
    queueState.getClaimedEntryList().add(startEntryId,endEntryId);
    final int cacheSize=(int)(endEntryId - startEntryId + 1);
    for (int id=0; id < cacheSize; ++id) {
      final long currentEntryId=startEntryId + id;
      if (partitioner.shouldEmit(consumer.getGroupSize(),consumer.getInstanceId(),currentEntryId) && queueState.getReconfigPartitionersList().shouldEmit(consumer.getGroupSize(),consumer.getInstanceId(),currentEntryId)) {
        newEntryIds.add(currentEntryId);
      }
    }
  }
  return newEntryIds;
}

Fixed version (ground truth):
@Override public void fetchNextEntries(QueueConsumer consumer,QueueConfig config,QueueStateImpl queueState,ReadPointer readPointer) throws OperationException {
  while (!queueState.getTransientWorkingSet().hasNext()) {
    List<Long> nextEntryIds=claimNextEntries(consumer,config,queueState,readPointer);
    if (nextEntryIds.isEmpty()) {
      return;
    }
    boolean allInvalid=readEntries(consumer,config,queueState,readPointer,nextEntryIds);
    if (allInvalid) {
      ignoreInvalidEntries(queueState,nextEntryIds);
      continue;
    }
    break;
  }
}
Program: 8004
Project: 8004
Buggy source:
@Override public void deleteDequeueState(QueueConsumer consumer) throws OperationException {
  writeQueueStateStore.addColumnName(CLAIMED_ENTRY_LIST);
  writeQueueStateStore.addColumnValue(new byte[0]);
  super.deleteDequeueState(consumer);
}

Fixed version (ground truth):
@Override public void deleteDequeueState(QueueConsumer consumer) throws OperationException {
  writeQueueStateStore.addColumnName(CLAIMED_ENTRY_LIST);
  writeQueueStateStore.addColumnValue(Bytes.EMPTY_BYTE_ARRAY);
  super.deleteDequeueState(consumer);
}
Program: 8005
Project: 8005
Buggy source:
public void deleteGroupEvictionState(ReadPointer readPointer,long writeVersion) throws OperationException {
  if (groupEvictEntries.isEmpty()) {
    readGroupEvictInformationInternal(readPointer);
  }
  if (groupEvictEntries.isEmpty()) {
    return;
  }
  byte[][] columnKeys=new byte[groupEvictEntries.size()][];
  byte[][] values=new byte[groupEvictEntries.size()][];
  int i=0;
  for (  Map.Entry<Long,Long> entry : groupEvictEntries.entrySet()) {
    columnKeys[i]=makeColumnName(GROUP_EVICT_ENTRY,entry.getKey());
    values[i]=Bytes.toBytes(entry.getValue());
    ++i;
  }
  table.put(GLOBAL_EVICT_META_ROW,columnKeys,writeVersion,values);
}

Fixed version (ground truth):
public void deleteGroupEvictionState(ReadPointer readPointer,long writeVersion) throws OperationException {
  if (groupEvictEntries.isEmpty()) {
    readGroupEvictInformationInternal(readPointer);
  }
  if (groupEvictEntries.isEmpty()) {
    return;
  }
  byte[][] columnKeys=new byte[groupEvictEntries.size()][];
  byte[][] values=new byte[groupEvictEntries.size()][];
  int i=0;
  for (  Map.Entry<Long,Long> entry : groupEvictEntries.entrySet()) {
    columnKeys[i]=makeColumnName(GROUP_EVICT_ENTRY,entry.getKey());
    values[i]=Bytes.EMPTY_BYTE_ARRAY;
    ++i;
  }
  table.put(GLOBAL_EVICT_META_ROW,columnKeys,writeVersion,values);
}
Program: 8006
Project: 8006
Buggy source:
public ClaimedEntryList(ClaimedEntry claimedEntry,List<ClaimedEntry> otherClaimedEntries){
  this.current=claimedEntry;
  this.otherClaimedEntries=otherClaimedEntries;
}

Fixed version (ground truth):
public ClaimedEntryList(ClaimedEntry claimedEntry,List<ClaimedEntry> otherClaimedEntries){
  otherClaimedEntries.remove(ClaimedEntry.INVALID_CLAIMED_ENTRY);
  if (claimedEntry.isValid()) {
    this.current=claimedEntry;
  }
 else   if (!otherClaimedEntries.isEmpty()) {
    this.current=otherClaimedEntries.get(0);
  }
 else {
    this.current=ClaimedEntry.INVALID_CLAIMED_ENTRY;
  }
  this.otherClaimedEntries=otherClaimedEntries;
}
Program: 8007
Project: 8007
Buggy source:
public void addAll(ClaimedEntryList claimedEntryList){
  ClaimedEntry otherCurrent=claimedEntryList.getClaimedEntry();
  add(otherCurrent.getBegin(),otherCurrent.getEnd());
  otherClaimedEntries.addAll(claimedEntryList.otherClaimedEntries);
}

Fixed version (ground truth):
public void addAll(ClaimedEntryList claimedEntryList){
  ClaimedEntry otherCurrent=claimedEntryList.getClaimedEntry();
  add(otherCurrent.getBegin(),otherCurrent.getEnd());
  claimedEntryList.otherClaimedEntries.remove(ClaimedEntry.INVALID_CLAIMED_ENTRY);
  otherClaimedEntries.addAll(claimedEntryList.otherClaimedEntries);
}
Program: 8008
Project: 8008
Buggy source:
public void add(long begin,long end){
  ClaimedEntry claimedEntry=new ClaimedEntry(begin,end);
  if (!claimedEntry.isValid()) {
    return;
  }
  makeCurrentValid();
  if (!current.isValid()) {
    current=claimedEntry;
  }
 else {
    if (otherClaimedEntries == Collections.EMPTY_LIST) {
      otherClaimedEntries=Lists.newArrayList();
    }
    otherClaimedEntries.add(claimedEntry);
  }
}

Fixed version (ground truth):
public void add(long begin,long end){
  ClaimedEntry newClaimedEntry=new ClaimedEntry(begin,end);
  if (!newClaimedEntry.isValid()) {
    return;
  }
  makeCurrentValid();
  if (!current.isValid()) {
    current=newClaimedEntry;
  }
 else {
    otherClaimedEntries.add(newClaimedEntry);
  }
}
Program: 8010
Project: 8010
Buggy source:
public void add(ClaimedEntryList claimedEntryList){
  otherClaimedEntries.add(claimedEntryList.getClaimedEntry());
  otherClaimedEntries.addAll(claimedEntryList.otherClaimedEntries);
}

Fixed version (ground truth):
public void add(long begin,long end){
  ClaimedEntry claimedEntry=new ClaimedEntry(begin,end);
  if (!claimedEntry.isValid()) {
    return;
  }
  makeCurrentValid();
  if (!current.isValid()) {
    current=claimedEntry;
  }
 else {
    if (otherClaimedEntries == Collections.EMPTY_LIST) {
      otherClaimedEntries=Lists.newArrayList();
    }
    otherClaimedEntries.add(claimedEntry);
  }
}
Program: 8011
Project: 8011
Buggy source:
@Override public void reconfigure(List<QueueConsumer> consumers,List<QueueStateImpl> queueStates,QueueConfig config,final long groupId,final int currentConsumerCount,final int newConsumerCount,ReadPointer readPointer) throws OperationException {
  if (newConsumerCount >= currentConsumerCount) {
    return;
  }
  if (consumers.isEmpty()) {
    if (currentConsumerCount != 0) {
      throw new OperationException(StatusCode.INTERNAL_ERROR,getLogMessage(String.format("String_Node_Str",currentConsumerCount)));
    }
    return;
  }
  PriorityQueue<ClaimedEntryList> priorityQueue=new PriorityQueue<ClaimedEntryList>(currentConsumerCount);
  for (  QueueStateImpl queueState : queueStates) {
    ClaimedEntryList claimedEntryList=queueState.getClaimedEntryList();
    priorityQueue.add(claimedEntryList);
  }
  for (int i=newConsumerCount; i < currentConsumerCount; ++i) {
    ClaimedEntryList claimedEntryList=queueStates.get(i).getClaimedEntryList();
    ClaimedEntryList transferEntryList=priorityQueue.poll();
    transferEntryList.add(claimedEntryList);
    priorityQueue.add(transferEntryList);
  }
  for (int i=0; i < newConsumerCount; ++i) {
    saveDequeueState(consumers.get(i),consumers.get(i).getQueueConfig(),queueStates.get(i),readPointer);
  }
  for (int i=newConsumerCount; i < currentConsumerCount; ++i) {
    deleteDequeueState(consumers.get(i));
  }
  return;
}

Fixed version (ground truth):
@Override public void reconfigure(List<QueueConsumer> consumers,List<QueueStateImpl> queueStates,QueueConfig config,final long groupId,final int currentConsumerCount,final int newConsumerCount,ReadPointer readPointer) throws OperationException {
  if (newConsumerCount >= currentConsumerCount) {
    return;
  }
  if (consumers.isEmpty()) {
    if (currentConsumerCount != 0) {
      throw new OperationException(StatusCode.INTERNAL_ERROR,getLogMessage(String.format("String_Node_Str",currentConsumerCount)));
    }
    return;
  }
  PriorityQueue<ClaimedEntryList> priorityQueue=new PriorityQueue<ClaimedEntryList>(currentConsumerCount);
  for (int i=0; i < newConsumerCount; ++i) {
    ClaimedEntryList claimedEntryList=queueStates.get(i).getClaimedEntryList();
    priorityQueue.add(claimedEntryList);
  }
  for (int i=newConsumerCount; i < currentConsumerCount; ++i) {
    ClaimedEntryList claimedEntryList=queueStates.get(i).getClaimedEntryList();
    ClaimedEntryList transferEntryList=priorityQueue.poll();
    transferEntryList.addAll(claimedEntryList);
    priorityQueue.add(transferEntryList);
  }
  for (int i=0; i < newConsumerCount; ++i) {
    saveDequeueState(consumers.get(i),consumers.get(i).getQueueConfig(),queueStates.get(i),readPointer);
  }
  for (int i=newConsumerCount; i < currentConsumerCount; ++i) {
    deleteDequeueState(consumers.get(i));
  }
  return;
}
Program: 8012
Project: 8012
Buggy source:
/** 
 * Returns the group read pointer for the consumer. This also initializes the group read pointer when the consumer group is starting for the first time.
 * @param consumer
 * @return group read pointer
 * @throws OperationException
 */
private long getGroupReadPointer(QueueConsumer consumer) throws OperationException {
  final byte[] rowKey=makeRowKey(GROUP_READ_POINTER,consumer.getGroupId());
  long groupReadPointer=table.incrementAtomicDirtily(rowKey,GROUP_READ_POINTER,0);
  if (groupReadPointer == 0) {
    long groupReadPointerInitialValue=getReadPointerIntialValue();
    table.compareAndSwapDirty(rowKey,GROUP_READ_POINTER,Bytes.toBytes(groupReadPointer),Bytes.toBytes(groupReadPointerInitialValue));
    return groupReadPointerInitialValue;
  }
  return groupReadPointer;
}

Fixed version (ground truth):
/** 
 * Returns the group read pointer for the consumer. This also initializes the group read pointer when the consumer group is starting for the first time.
 * @param consumer
 * @return group read pointer
 * @throws OperationException
 */
private long getGroupReadPointer(QueueConsumer consumer) throws OperationException {
  final byte[] rowKey=makeRowKey(GROUP_READ_POINTER,consumer.getGroupId());
  long groupReadPointer=table.incrementAtomicDirtily(rowKey,GROUP_READ_POINTER,0);
  if (groupReadPointer == 0) {
    long lastEvictEntry=getLastEvictEntry();
    if (lastEvictEntry != INVALID_ENTRY_ID) {
      table.compareAndSwapDirty(rowKey,GROUP_READ_POINTER,Bytes.toBytes(groupReadPointer),Bytes.toBytes(lastEvictEntry));
      return lastEvictEntry;
    }
  }
  return groupReadPointer;
}
Program: 8013
Project: 8013
Buggy source:
/** 
 * This function is used to initialize the read pointer when a consumer first runs. Initial value for the read pointer is max(lastEvictEntry, FIRST_QUEUE_ENTRY_ID - 1)
 * @return read pointer initial value
 * @throws OperationException
 */
protected long getReadPointerIntialValue() throws OperationException {
  QueueStateStore readEvictState=new QueueStateStore(table,oracle);
  readEvictState.setRowKey(GLOBAL_EVICT_META_PREFIX);
  readEvictState.addColumnName(GLOBAL_LAST_EVICT_ENTRY);
  readEvictState.read();
  OperationResult<Map<byte[],byte[]>> evictStateBytes=readEvictState.getReadResult();
  final long defaultInitialValue=FIRST_QUEUE_ENTRY_ID - 1;
  if (!evictStateBytes.isEmpty()) {
    byte[] lastEvictEntryBytes=evictStateBytes.getValue().get(GLOBAL_LAST_EVICT_ENTRY);
    if (lastEvictEntryBytes != null) {
      long lastEvictEntry=Bytes.toLong(lastEvictEntryBytes);
      if (lastEvictEntry > defaultInitialValue) {
        return lastEvictEntry;
      }
    }
  }
  return defaultInitialValue;
}

Fixed version (ground truth):
/** 
 * This function is used to initialize the read pointer when a consumer first runs. Initial value for the read pointer is max(lastEvictEntry, FIRST_QUEUE_ENTRY_ID - 1)
 * @return read pointer initial value
 * @throws OperationException
 */
protected long getReadPointerIntialValue() throws OperationException {
  final long defaultInitialValue=FIRST_QUEUE_ENTRY_ID - 1;
  long lastEvictEntry=getLastEvictEntry();
  if (lastEvictEntry != INVALID_ENTRY_ID && lastEvictEntry > defaultInitialValue) {
    return lastEvictEntry;
  }
  return defaultInitialValue;
}
Program: 8015
Project: 8015
Buggy source:
@Override public void deleteDirty(byte[][] rows) throws OperationException {
  for (int i=0; i < rows.length; ++i) {
    RowLockTable.Row r=new RowLockTable.Row(rows[i]);
    NavigableMap<Column,NavigableMap<Version,Value>> map=getAndLockRow(r);
    try {
      this.map.remove(r);
      this.locks.unlockAndRemove(r);
    }
  finally {
      this.locks.unlock(r);
    }
  }
}

Fixed version (ground truth):
@Override public void deleteDirty(byte[][] rows) throws OperationException {
  for (int i=0; i < rows.length; ++i) {
    RowLockTable.Row r=new RowLockTable.Row(rows[i]);
    NavigableMap<Column,NavigableMap<Version,Value>> map=getAndLockRow(r);
    try {
      this.map.remove(r);
    }
  finally {
      this.locks.unlockAndRemove(r);
    }
  }
}
Program: 8016
Project: 8016
Buggy source:
@Override public String toString(){
  return Objects.toStringHelper(this).add("String_Node_Str",super.toString()).add("String_Node_Str",queueState.toString()).toString();
}

Fixed version (ground truth):
@Override public String toString(){
  return Objects.toStringHelper(this).add("String_Node_Str",super.toString()).add("String_Node_Str",queueState).toString();
}
Program: 8018
Project: 8018
Buggy source:
protected TTQueueNewOnVCTable(VersionedColumnarTable table,byte[] queueName,TransactionOracle oracle,final CConfiguration conf){
  this.table=table;
  this.queueName=queueName;
  this.oracle=oracle;
  final long default_batch_size=conf.getLong("String_Node_Str",100);
  this.DEFAULT_BATCH_SIZE=default_batch_size > 0 ? default_batch_size : 100;
  final long evict_interval_in_secs=conf.getLong("String_Node_Str",10 * 60 * 60);
  this.EVICT_INTERVAL_IN_SECS=evict_interval_in_secs > 0 ? evict_interval_in_secs : 10 * 60 * 60;
}

Fixed version (ground truth):
protected TTQueueNewOnVCTable(VersionedColumnarTable table,byte[] queueName,TransactionOracle oracle,final CConfiguration conf){
  this.table=table;
  this.queueName=queueName;
  this.oracle=oracle;
  final long defaultBatchSize=conf.getLong("String_Node_Str",100);
  this.DEFAULT_BATCH_SIZE=defaultBatchSize > 0 ? defaultBatchSize : 100;
  final long evictIntervalInSecs=conf.getLong("String_Node_Str",10 * 60 * 60);
  this.EVICT_INTERVAL_IN_SECS=evictIntervalInSecs >= 0 ? evictIntervalInSecs : 10 * 60 * 60;
}
Program: 8021
Project: 8021
Buggy source:
@Override public long getGroupID() throws OperationException {
  return ++groupId;
}

Fixed version (ground truth):
@Override public long getGroupID() throws OperationException {
  return groupId++;
}
Program: 8023
Project: 8023
Buggy source:
@BeforeClass public static void startHBase() throws Exception {
  conf=new Configuration();
  conf.setInt("String_Node_Str",-1);
  conf.setInt("String_Node_Str",-1);
  zkCluster=new MiniZooKeeperCluster(conf);
  System.err.println("String_Node_Str");
  Thread.sleep(1000);
  int zkPort=zkCluster.startup(getRandomTempDir(),1);
  System.err.println("String_Node_Str" + zkPort + "String_Node_Str");
  conf.set(HConstants.ZOOKEEPER_CLIENT_PORT,Integer.toString(zkPort));
  File dfsPath=getRandomTempDir();
  System.setProperty("String_Node_Str",dfsPath.toString());
  System.setProperty("String_Node_Str",dfsPath.toString());
  System.err.println("String_Node_Str");
  Thread.sleep(1000);
  dfsCluster=new MiniDFSCluster.Builder(conf).nameNodePort(0).numDataNodes(1).format(true).manageDataDfsDirs(true).manageNameDfsDirs(true).build();
  System.err.println("String_Node_Str");
  dfsCluster.waitClusterUp();
  System.err.println("String_Node_Str");
  Thread.sleep(1000);
  conf.set("String_Node_Str",dfsCluster.getFileSystem().getUri().toString());
  createHBaseRootDir(conf);
  conf.setInt("String_Node_Str",1);
  conf.setInt("String_Node_Str",1);
  Configuration c=new Configuration(conf);
  System.err.println("String_Node_Str");
  Thread.sleep(1000);
  hbaseCluster=new MiniHBaseCluster(c,1,1);
  System.err.println("String_Node_Str");
  Thread.sleep(1000);
}

Fixed version (ground truth):
@BeforeClass public static void startHBase() throws Exception {
  conf=new Configuration();
  conf.setInt("String_Node_Str",-1);
  conf.setInt("String_Node_Str",-1);
  zkCluster=new MiniZooKeeperCluster(conf);
  System.err.println("String_Node_Str");
  Thread.sleep(1000);
  int zkPort=zkCluster.startup(getRandomTempDir(),1);
  System.err.println("String_Node_Str" + zkPort + "String_Node_Str");
  conf.set(HConstants.ZOOKEEPER_CLIENT_PORT,Integer.toString(zkPort));
  File dfsPath=getRandomTempDir();
  System.setProperty("String_Node_Str",dfsPath.toString());
  System.setProperty("String_Node_Str",dfsPath.toString());
  System.err.println("String_Node_Str");
  Thread.sleep(1000);
  dfsCluster=new MiniDFSCluster.Builder(conf).nameNodePort(0).numDataNodes(1).format(true).manageDataDfsDirs(true).manageNameDfsDirs(true).build();
  System.err.println("String_Node_Str");
  dfsCluster.waitClusterUp();
  System.err.println("String_Node_Str");
  Thread.sleep(1000);
  conf.set("String_Node_Str",dfsCluster.getFileSystem().getUri().toString());
  createHBaseRootDir(conf);
  conf.setInt("String_Node_Str",1);
  conf.setInt("String_Node_Str",1);
  conf.setInt("String_Node_Str",300000);
  Configuration c=new Configuration(conf);
  System.err.println("String_Node_Str");
  Thread.sleep(1000);
  hbaseCluster=new MiniHBaseCluster(c,1,1);
  System.err.println("String_Node_Str");
  Thread.sleep(1000);
}
Program: 8024
Project: 8024
Buggy source:
@Override @Test @Ignore public void testSingleConsumerSingleEntryWithInvalid_Empty_ChangeSizeAndToMulti(){
}

Fixed version (ground truth):
/** 
 * Currently not working.  Will be fixed in ENG-???.
 */
@Override @Test @Ignore public void testSingleConsumerSingleEntryWithInvalid_Empty_ChangeSizeAndToMulti(){
}
Program: 8025
Project: 8025
Buggy source:
@Override protected TTQueue createQueue(CConfiguration conf) throws OperationException {
  String rand="String_Node_Str" + Math.abs(r.nextInt());
  return new TTQueueNewOnVCTable(handle.getTable(Bytes.toBytes("String_Node_Str" + rand)),Bytes.toBytes("String_Node_Str" + rand),TestTTQueue.oracle,conf);
}

Fixed version (ground truth):
@Override protected TTQueue createQueue(CConfiguration conf) throws OperationException {
  String rand="String_Node_Str" + Math.abs(r.nextInt());
  conf.setLong("String_Node_Str",0);
  return new TTQueueNewOnVCTable(handle.getTable(Bytes.toBytes("String_Node_Str" + rand)),Bytes.toBytes("String_Node_Str" + rand),TestTTQueue.oracle,conf);
}
Program: 8028
Project: 8028
Buggy source:
@Inject public DefaultApplicationManager(OperationExecutor opex,StreamWriterFactory streamWriterFactory,ProcedureClientFactory procedureClientFactory,@Assisted AuthToken token,@Assisted("String_Node_Str") String accountId,@Assisted("String_Node_Str") String applicationId,@Assisted AppFabricService.Iface appFabricServer,@Assisted Location deployedJar,@Assisted ApplicationSpecification appSpec){
  this.token=token;
  this.accountId=accountId;
  this.applicationId=applicationId;
  this.appFabricServer=appFabricServer;
  this.streamWriterFactory=streamWriterFactory;
  this.procedureClientFactory=procedureClientFactory;
  try {
    OperationContext ctx=new OperationContext(accountId,applicationId);
    DataFabric dataFabric=new DataFabricImpl(opex,ctx);
    TransactionProxy proxy=new TransactionProxy();
    proxy.setTransactionAgent(new SynchronousTransactionAgent(opex,ctx));
    this.dataSetInstantiator=new DataSetInstantiator(dataFabric,proxy,new JarClassLoader(deployedJar));
    this.dataSetInstantiator.setDataSets(ImmutableList.copyOf(appSpec.getDataSets().values()));
  }
 catch (  IOException e) {
    throw Throwables.propagate(e);
  }
}

Fixed version (ground truth):
@Inject public DefaultApplicationManager(OperationExecutor opex,StreamWriterFactory streamWriterFactory,ProcedureClientFactory procedureClientFactory,@Assisted AuthToken token,@Assisted("String_Node_Str") String accountId,@Assisted("String_Node_Str") String applicationId,@Assisted AppFabricService.Iface appFabricServer,@Assisted Location deployedJar,@Assisted ApplicationSpecification appSpec){
  this.token=token;
  this.accountId=accountId;
  this.applicationId=applicationId;
  this.appFabricServer=appFabricServer;
  this.streamWriterFactory=streamWriterFactory;
  this.procedureClientFactory=procedureClientFactory;
  OperationContext ctx=new OperationContext(accountId,applicationId);
  DataFabric dataFabric=new DataFabricImpl(opex,ctx);
  TransactionProxy proxy=new TransactionProxy();
  proxy.setTransactionAgent(new SynchronousTransactionAgent(opex,ctx));
  try {
    this.dataSetInstantiator=new DataSetInstantiator(dataFabric,proxy,new DataSetClassLoader(new JarClassLoader(deployedJar)));
  }
 catch (  IOException e) {
    throw Throwables.propagate(e);
  }
  this.dataSetInstantiator.setDataSets(ImmutableList.copyOf(appSpec.getDataSets().values()));
}
Program: 8030
Project: 8030
Buggy source:
/** 
 * NOTE: fails with RuntimeException if program can't be found
 */
private Location getProgramLocation(Id.Program id,Type type) throws IOException {
  Location allAppsLocation=locationFactory.create(configuration.get(Constants.CFG_APP_FABRIC_OUTPUT_DIR,"String_Node_Str"));
  Location accountAppsLocation=allAppsLocation.append(id.getAccountId());
  String name=String.format(Locale.ENGLISH,"String_Node_Str",type.toString(),id.getApplicationId());
  Location applicationProgramsLocation=accountAppsLocation.append(name);
  if (!applicationProgramsLocation.exists()) {
    throw new RuntimeException("String_Node_Str");
  }
  Location programLocation=applicationProgramsLocation.append(String.format("String_Node_Str",id.getId()));
  if (!programLocation.exists()) {
    throw new RuntimeException(type.toString() + "String_Node_Str");
  }
  return programLocation;
}

Fixed version (ground truth):
/** 
 * NOTE: fails with RuntimeException if program can't be found
 */
private Location getProgramLocation(Id.Program id,Type type) throws IOException {
  Location allAppsLocation=locationFactory.create(configuration.get(Constants.CFG_APP_FABRIC_OUTPUT_DIR,"String_Node_Str"));
  Location accountAppsLocation=allAppsLocation.append(id.getAccountId());
  String name=String.format(Locale.ENGLISH,"String_Node_Str",type.toString(),id.getApplicationId());
  Location applicationProgramsLocation=accountAppsLocation.append(name);
  if (!applicationProgramsLocation.exists()) {
    throw new RuntimeException("String_Node_Str");
  }
  Location programLocation=applicationProgramsLocation.append(String.format("String_Node_Str",id.getId()));
  if (!programLocation.exists()) {
    throw new RuntimeException(String.format("String_Node_Str",id.getApplication(),id.getId(),type));
  }
  return programLocation;
}
Program: 8031
Project: 8031
Buggy source:
/** 
 * NOTE: fails with RuntimeException if program can't be found
 */
private Location getProgramLocation(Id.Program id,Type type) throws IOException {
  Location allAppsLocation=locationFactory.create(configuration.get(Constants.CFG_APP_FABRIC_OUTPUT_DIR,"String_Node_Str"));
  Location accountAppsLocation=allAppsLocation.append(id.getAccountId());
  String name=String.format(Locale.ENGLISH,"String_Node_Str",type.toString(),id.getApplicationId());
  Location applicationProgramsLocation=accountAppsLocation.append(name);
  if (!applicationProgramsLocation.exists()) {
    throw new RuntimeException("String_Node_Str");
  }
  Location programLocation=applicationProgramsLocation.append(String.format("String_Node_Str",id.getId()));
  if (!programLocation.exists()) {
    throw new RuntimeException(type.toString() + "String_Node_Str");
  }
  return programLocation;
}

Fixed version (ground truth):
/** 
 * NOTE: fails with RuntimeException if program can't be found
 */
private Location getProgramLocation(Id.Program id,Type type) throws IOException {
  Location allAppsLocation=locationFactory.create(configuration.get(Constants.CFG_APP_FABRIC_OUTPUT_DIR,"String_Node_Str"));
  Location accountAppsLocation=allAppsLocation.append(id.getAccountId());
  String name=String.format(Locale.ENGLISH,"String_Node_Str",type.toString(),id.getApplicationId());
  Location applicationProgramsLocation=accountAppsLocation.append(name);
  if (!applicationProgramsLocation.exists()) {
    throw new RuntimeException("String_Node_Str");
  }
  Location programLocation=applicationProgramsLocation.append(String.format("String_Node_Str",id.getId()));
  if (!programLocation.exists()) {
    throw new RuntimeException(String.format("String_Node_Str",id.getApplication(),id.getId(),type));
  }
  return programLocation;
}
Program: 8032
Project: 8032
Buggy source:
/** 
 * @param column operand
 * @return A byte array of a byte array where first and only entry is<code>column</code>
 */
public static byte[][] toByteArrays(final byte[] column){
  byte[][] result=new byte[1][];
  result[0]=column;
  return result;
}

Fixed version (ground truth):
/** 
 * Returns an array of byte arrays  where first and only entry is <code>column</code>
 * @param column operand
 * @return An array of byte arrays  where first and only entry is<code>column</code>
 */
public static byte[][] toByteArrays(final byte[] column){
  byte[][] result=new byte[1][];
  result[0]=column;
  return result;
}
Program: 8033
Project: 8033
Buggy source:
/** 
 * @param bytes byte array
 * @param offset offset where double is
 * @return Return double made from passed bytes.
 */
public static double toDouble(final byte[] bytes,final int offset){
  return Double.longBitsToDouble(toLong(bytes,offset,SIZEOF_LONG));
}

Fixed version (ground truth):
/** 
 * Return double made from passed bytes
 * @param bytes byte array
 * @param offset offset where double is
 * @return Return double made from passed bytes.
 */
public static double toDouble(final byte[] bytes,final int offset){
  return Double.longBitsToDouble(toLong(bytes,offset,SIZEOF_LONG));
}
Program: 8034
Project: 8034
Buggy source:
/** 
 * @param a first third
 * @param b second third
 * @param c third third
 * @return New array made from a, b and c
 */
public static byte[] add(final byte[] a,final byte[] b,final byte[] c){
  byte[] result=new byte[a.length + b.length + c.length];
  System.arraycopy(a,0,result,0,a.length);
  System.arraycopy(b,0,result,a.length,b.length);
  System.arraycopy(c,0,result,a.length + b.length,c.length);
  return result;
}

Fixed version (ground truth):
/** 
 * Concatenate three byte arrays
 * @param a first third
 * @param b second third
 * @param c third third
 * @return New array made from a, b and c
 */
public static byte[] add(final byte[] a,final byte[] b,final byte[] c){
  byte[] result=new byte[a.length + b.length + c.length];
  System.arraycopy(a,0,result,0,a.length);
  System.arraycopy(b,0,result,a.length,b.length);
  System.arraycopy(c,0,result,a.length + b.length,c.length);
  return result;
}
Program: 8035
Project: 8035
Buggy source:
/** 
 * @param bytes byte array
 * @param offset offset to write to
 * @param f float value
 * @return New offset in <code>bytes</code>
 */
public static int putFloat(byte[] bytes,int offset,float f){
  return putInt(bytes,offset,Float.floatToRawIntBits(f));
}

Fixed version (ground truth):
/** 
 * Put a float value out to the specified byte array position.
 * @param bytes byte array
 * @param offset offset to write to
 * @param f float value
 * @return New offset in <code>bytes</code>
 */
public static int putFloat(byte[] bytes,int offset,float f){
  return putInt(bytes,offset,Float.floatToRawIntBits(f));
}
Program: 8036
Project: 8036
Buggy source:
/** 
 * @param bytes byte array
 * @param offset offset to write to
 * @param d value
 * @return New offset into array <code>bytes</code>
 */
public static int putDouble(byte[] bytes,int offset,double d){
  return putLong(bytes,offset,Double.doubleToLongBits(d));
}

Fixed version (ground truth):
/** 
 * Put a double value out to the specified byte array position.
 * @param bytes byte array
 * @param offset offset to write to
 * @param d value
 * @return New offset into array <code>bytes</code>
 */
public static int putDouble(byte[] bytes,int offset,double d){
  return putLong(bytes,offset,Double.doubleToLongBits(d));
}
Program: 8037
Project: 8037
Buggy source:
/** 
 * @param a array
 * @param length amount of bytes to grab
 * @return First <code>length</code> bytes from <code>a</code>
 */
public static byte[] head(final byte[] a,final int length){
  if (a.length < length) {
    return null;
  }
  byte[] result=new byte[length];
  System.arraycopy(a,0,result,0,length);
  return result;
}

Fixed version (ground truth):
/** 
 * Returns first <code>length</code> bytes from byte array
 * @param a array
 * @param length amount of bytes to grab
 * @return First <code>length</code> bytes from <code>a</code>
 */
public static byte[] head(final byte[] a,final int length){
  if (a.length < length) {
    return null;
  }
  byte[] result=new byte[length];
  System.arraycopy(a,0,result,0,length);
  return result;
}
Program: 8038
Project: 8038
Buggy source:
/** 
 * @param a array
 * @param length amount of bytes to snarf
 * @return Last <code>length</code> bytes from <code>a</code>
 */
public static byte[] tail(final byte[] a,final int length){
  if (a.length < length) {
    return null;
  }
  byte[] result=new byte[length];
  System.arraycopy(a,a.length - length,result,0,length);
  return result;
}

Fixed version (ground truth):
/** 
 * Returns last <code>length</code> bytes from byte array
 * @param a array
 * @param length amount of bytes to snarf
 * @return Last <code>length</code> bytes from <code>a</code>
 */
public static byte[] tail(final byte[] a,final int length){
  if (a.length < length) {
    return null;
  }
  byte[] result=new byte[length];
  System.arraycopy(a,a.length - length,result,0,length);
  return result;
}
Program: 8039
Project: 8039
Buggy source:
/** 
 * @param b bytes to hash
 * @param length length to hash
 * @return A hash of <code>b</code> as an Integer that can be used as key inMaps.
 */
public static Integer mapKey(final byte[] b,final int length){
  return hashCode(b,length);
}

Fixed version (ground truth):
/** 
 * Returns a hash of a byte array segment as an Integer that can be used as key in Maps
 * @param b bytes to hash
 * @param length length to hash
 * @return A hash of <code>b</code> as an Integer that can be used as key inMaps.
 */
public static Integer mapKey(final byte[] b,final int length){
  return hashCode(b,length);
}
Program: 8040
Project: 8040
Buggy source:
/** 
 * @param a array
 * @param length new array size
 * @return Value in <code>a</code> plus <code>length</code> appended 0 bytes
 */
public static byte[] padTail(final byte[] a,final int length){
  byte[] padding=new byte[length];
  for (int i=0; i < length; i++) {
    padding[i]=0;
  }
  return add(a,padding);
}

Fixed version (ground truth):
/** 
 * Return a byte array with value in <code>a</code> plus <code>length</code> appended 0 bytes
 * @param a array
 * @param length new array size
 * @return Value in <code>a</code> plus <code>length</code> appended 0 bytes
 */
public static byte[] padTail(final byte[] a,final int length){
  byte[] padding=new byte[length];
  for (int i=0; i < length; i++) {
    padding[i]=0;
  }
  return add(a,padding);
}
Program: 8041
Project: 8041
Buggy source:
/** 
 * @param a array
 * @param length new array size
 * @return Value in <code>a</code> plus <code>length</code> prepended 0 bytes
 */
public static byte[] padHead(final byte[] a,final int length){
  byte[] padding=new byte[length];
  for (int i=0; i < length; i++) {
    padding[i]=0;
  }
  return add(padding,a);
}

Fixed version (ground truth):
/** 
 * Return a byte array with value in <code>a</code> plus <code>length</code> prepended 0 bytes
 * @param a array
 * @param length new array size
 * @return Value in <code>a</code> plus <code>length</code> prepended 0 bytes
 */
public static byte[] padHead(final byte[] a,final int length){
  byte[] padding=new byte[length];
  for (int i=0; i < length; i++) {
    padding[i]=0;
  }
  return add(padding,a);
}
Program: 8042
Project: 8042
Buggy source:
public static boolean equals(final byte[] left,int leftOffset,int leftLen,final byte[] right,int rightOffset,int rightLen){
  if (left == right && leftOffset == rightOffset && leftLen == rightLen) {
    return true;
  }
  if (leftLen != rightLen) {
    return false;
  }
  if (leftLen == 0) {
    return true;
  }
  if (left[leftOffset + leftLen - 1] != right[rightOffset + rightLen - 1])   return false;
  return LexicographicalComparerHolder.BEST_COMPARER.compareTo(left,leftOffset,leftLen,right,rightOffset,rightLen) == 0;
}

Fixed version (ground truth):
/** 
 * Checks segments of two byte arrays for equality
 * @param left left operand
 * @param leftOffset offset from which to start comparison
 * @param leftLen length of left segment
 * @param right right operand
 * @param rightOffset offset from which to start comparison
 * @param rightLen length of right segment
 * @return True if two segments are equal
 */
public static boolean equals(final byte[] left,int leftOffset,int leftLen,final byte[] right,int rightOffset,int rightLen){
  if (left == right && leftOffset == rightOffset && leftLen == rightLen) {
    return true;
  }
  if (leftLen != rightLen) {
    return false;
  }
  if (leftLen == 0) {
    return true;
  }
  if (left[leftOffset + leftLen - 1] != right[rightOffset + rightLen - 1])   return false;
  return LexicographicalComparerHolder.BEST_COMPARER.compareTo(left,leftOffset,leftLen,right,rightOffset,rightLen) == 0;
}
Program: 8043
Project: 8043
Buggy source:
public void increment(Increment increment) throws OperationException {
  Long indexIncrement=null;
  for (int i=0; i < increment.getColumns().length; ++i) {
    if (Arrays.equals(this.column,increment.getColumns()[i])) {
      indexIncrement=increment.getValues()[i];
      break;
    }
  }
  if (indexIncrement == null) {
    this.table.write(increment);
    return;
  }
  Long newIndexValue=this.table.incrementAndGet(increment).get(this.column);
  if (newIndexValue == null) {
    return;
  }
  byte[] oldSecondaryKey=Bytes.toBytes(newIndexValue - indexIncrement);
  this.table.write(new Delete(oldSecondaryKey,increment.getRow()));
  byte[] newSecondaryKey=Bytes.toBytes(newIndexValue);
  this.table.write(new Write(newSecondaryKey,increment.getRow(),EXISTS));
}

Fixed version (ground truth):
/** 
 * Perform an increment operation by primary key.
 * @param increment The increment operation, as if it were on a non-indexed table.Note that if the increment is on the secondary key column, then the index must be updated; otherwise this is a pass-through to the underlying table.
 * @throws OperationException if the operation goes wrong
 */
public void increment(Increment increment) throws OperationException {
  Long indexIncrement=null;
  for (int i=0; i < increment.getColumns().length; ++i) {
    if (Arrays.equals(this.column,increment.getColumns()[i])) {
      indexIncrement=increment.getValues()[i];
      break;
    }
  }
  if (indexIncrement == null) {
    this.table.write(increment);
    return;
  }
  Long newIndexValue=this.table.incrementAndGet(increment).get(this.column);
  if (newIndexValue == null) {
    return;
  }
  byte[] oldSecondaryKey=Bytes.toBytes(newIndexValue - indexIncrement);
  this.table.write(new Delete(oldSecondaryKey,increment.getRow()));
  byte[] newSecondaryKey=Bytes.toBytes(newIndexValue);
  this.table.write(new Write(newSecondaryKey,increment.getRow(),EXISTS));
}
Program: 8045
Project: 8045
Buggy source:
private Object readRecord(Decoder decoder,Schema sourceSchema,Schema targetSchema,TypeToken<?> targetTypeToken) throws IOException {
  try {
    Object record=create(targetTypeToken);
    for (    Schema.Field sourceField : sourceSchema.getFields()) {
      Schema.Field targetField=targetSchema.getField(sourceField.getName());
      if (targetField == null) {
        continue;
      }
      Field field=null;
      for (      TypeToken<?> type : targetTypeToken.getTypes().classes()) {
        try {
          field=type.getRawType().getDeclaredField(sourceField.getName());
        }
 catch (        NoSuchFieldException e) {
          continue;
        }
        break;
      }
      check(field != null,"String_Node_Str",targetTypeToken,sourceField.getName());
      if (!field.isAccessible()) {
        field.setAccessible(true);
      }
      TypeToken<?> fieldTypeToken=targetTypeToken.resolveType(field.getGenericType());
      field.set(record,read(decoder,sourceField.getSchema(),targetField.getSchema(),fieldTypeToken));
    }
    return record;
  }
 catch (  Exception e) {
    throw propagate(e);
  }
}

Fixed version (ground truth):
private Object readRecord(Decoder decoder,Schema sourceSchema,Schema targetSchema,TypeToken<?> targetTypeToken) throws IOException {
  try {
    Object record=create(targetTypeToken);
    for (    Schema.Field sourceField : sourceSchema.getFields()) {
      Schema.Field targetField=targetSchema.getField(sourceField.getName());
      if (targetField == null) {
        skip(decoder,sourceField.getSchema());
        continue;
      }
      Field field=null;
      for (      TypeToken<?> type : targetTypeToken.getTypes().classes()) {
        try {
          field=type.getRawType().getDeclaredField(sourceField.getName());
        }
 catch (        NoSuchFieldException e) {
          continue;
        }
        break;
      }
      check(field != null,"String_Node_Str",targetTypeToken,sourceField.getName());
      if (!field.isAccessible()) {
        field.setAccessible(true);
      }
      TypeToken<?> fieldTypeToken=targetTypeToken.resolveType(field.getGenericType());
      field.set(record,read(decoder,sourceField.getSchema(),targetField.getSchema(),fieldTypeToken));
    }
    return record;
  }
 catch (  Exception e) {
    throw propagate(e);
  }
}
Program: 8046
Project: 8046
Buggy source:
private void write(Object object,Encoder encoder,Schema objSchema,Set<Object> seenRefs) throws IOException {
  if (object != null) {
    if (seenRefs.contains(object)) {
      throw new IOException("String_Node_Str");
    }
    seenRefs.add(object);
  }
switch (objSchema.getType()) {
case NULL:
    encoder.writeNull();
  break;
case BOOLEAN:
encoder.writeBool((Boolean)object);
break;
case INT:
encoder.writeInt(((Number)object).intValue());
break;
case LONG:
encoder.writeLong(((Number)object).longValue());
break;
case FLOAT:
encoder.writeFloat((Float)object);
break;
case DOUBLE:
encoder.writeDouble((Double)object);
break;
case STRING:
encoder.writeString(object.toString());
break;
case BYTES:
writeBytes(object,encoder);
break;
case ENUM:
writeEnum(object.toString(),encoder,objSchema);
break;
case ARRAY:
writeArray(object,encoder,objSchema.getComponentSchema(),seenRefs);
break;
case MAP:
writeMap(object,encoder,objSchema.getMapSchema(),seenRefs);
break;
case RECORD:
writeRecord(object,encoder,objSchema,seenRefs);
break;
case UNION:
if (object == null) {
encoder.writeInt(1);
}
 else {
seenRefs.remove(object);
encoder.writeInt(0);
write(object,encoder,objSchema.getUnionSchema(0),seenRefs);
}
break;
}
}

Fixed version (ground truth):
private void write(Object object,Encoder encoder,Schema objSchema,Set<Object> seenRefs) throws IOException {
  if (object != null) {
    if (objSchema.getType() == Schema.Type.RECORD && seenRefs.contains(object)) {
      throw new IOException("String_Node_Str");
    }
    seenRefs.add(object);
  }
switch (objSchema.getType()) {
case NULL:
    encoder.writeNull();
  break;
case BOOLEAN:
encoder.writeBool((Boolean)object);
break;
case INT:
encoder.writeInt(((Number)object).intValue());
break;
case LONG:
encoder.writeLong(((Number)object).longValue());
break;
case FLOAT:
encoder.writeFloat((Float)object);
break;
case DOUBLE:
encoder.writeDouble((Double)object);
break;
case STRING:
encoder.writeString(object.toString());
break;
case BYTES:
writeBytes(object,encoder);
break;
case ENUM:
writeEnum(object.toString(),encoder,objSchema);
break;
case ARRAY:
writeArray(object,encoder,objSchema.getComponentSchema(),seenRefs);
break;
case MAP:
writeMap(object,encoder,objSchema.getMapSchema(),seenRefs);
break;
case RECORD:
writeRecord(object,encoder,objSchema,seenRefs);
break;
case UNION:
if (object == null) {
encoder.writeInt(1);
}
 else {
seenRefs.remove(object);
encoder.writeInt(0);
write(object,encoder,objSchema.getUnionSchema(0),seenRefs);
}
break;
}
}
Program: 8047
Project: 8047
Buggy source:
/** 
 * generic method to discover a thrift service and start up the thrift transport and protocol layer
 */
private TProtocol getThriftProtocol(String serviceName) throws ServerException {
  ImmutablePair<String,Integer> addr=this.accessor.getServiceDiscovery().getServiceAddress(serviceName);
  if (addr == null) {
    String message=String.format("String_Node_Str" + "String_Node_Str",serviceName);
    LOG.error(message);
    throw new ServerException(message);
  }
  TTransport transport=new TFramedTransport(new TSocket(addr.getFirst(),addr.getSecond()));
  try {
    transport.open();
  }
 catch (  TTransportException e) {
    String message=String.format("String_Node_Str" + "String_Node_Str",serviceName,addr.getFirst(),addr.getSecond(),e.getMessage());
    LOG.error(message);
    throw new ServerException(message,e);
  }
  return new TBinaryProtocol(transport);
}

Fixed version (ground truth):
/** 
 * generic method to discover a thrift service and start up the thrift transport and protocol layer
 */
private TProtocol getThriftProtocol(String serviceName) throws ServerException {
  ImmutablePair<String,Integer> addr;
  if (Constants.flowServiceName.equals(serviceName)) {
    List<Discoverable> endpoints=Lists.newArrayList(accessor.getDiscoveryServiceClient().discover("String_Node_Str"));
    if (endpoints.isEmpty()) {
      throw new ServerException("String_Node_Str");
    }
    Collections.shuffle(endpoints);
    InetSocketAddress endpoint=endpoints.get(0).getSocketAddress();
    addr=new ImmutablePair<String,Integer>(endpoint.getHostName(),endpoint.getPort());
  }
 else {
    addr=this.accessor.getServiceDiscovery().getServiceAddress(serviceName);
  }
  if (addr == null) {
    String message=String.format("String_Node_Str" + "String_Node_Str",serviceName);
    LOG.error(message);
    throw new ServerException(message);
  }
  TTransport transport=new TFramedTransport(new TSocket(addr.getFirst(),addr.getSecond()));
  try {
    transport.open();
  }
 catch (  TTransportException e) {
    String message=String.format("String_Node_Str" + "String_Node_Str",serviceName,addr.getFirst(),addr.getSecond(),e.getMessage());
    LOG.error(message);
    throw new ServerException(message,e);
  }
  return new TBinaryProtocol(transport);
}
Program: 8049
Project: 8049
Buggy source:
@Override public int compareTo(Entry other){
  return Long.signum(count - other.count);
}

Fixed version (ground truth):
@Override public int compareTo(Entry other){
  if (count == other.count) {
    return word.compareTo(other.word);
  }
  return Long.signum(count - other.count);
}
Program: 8050
Project: 8050
Buggy source:
private void increaseInstances(String flowletName,final int newInstanceCount,Map<Integer,ProgramController> liveFlowlets,int liveCount) throws InterruptedException, ExecutionException {
  Futures.successfulAsList(Iterables.transform(liveFlowlets.values(),new Function<ProgramController,ListenableFuture<?>>(){
    @Override public ListenableFuture<?> apply(    ProgramController controller){
      return controller.command("String_Node_Str",newInstanceCount);
    }
  }
)).get();
  for (int instanceId=liveCount; instanceId < newInstanceCount; instanceId++) {
    flowlets.put(flowletName,instanceId,startFlowlet(program,new FlowletOptions(flowletName,instanceId,newInstanceCount,getRunId())));
  }
}

Fixed version (ground truth):
private synchronized void increaseInstances(String flowletName,final int newInstanceCount,Map<Integer,ProgramController> liveFlowlets,int liveCount) throws InterruptedException, ExecutionException {
  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();
  for (int instanceId=liveCount; instanceId < newInstanceCount; instanceId++) {
    flowlets.put(flowletName,instanceId,startFlowlet(program,new FlowletOptions(flowletName,instanceId,newInstanceCount,getRunId())));
  }
}