nus-yam/ex-repair huggingface dataset:
Program: 48101
Project: 48101
Buggy source:
private int makeBackups(long[] replicaVersions,int syncBackupCount,int totalBackupCount){
  int sentSyncBackupCount=0;
  InternalPartition partition=partitionService.getPartition(partitionId);
  for (int replicaIndex=1; replicaIndex <= totalBackupCount; replicaIndex++) {
    Address target=partition.getReplicaAddress(replicaIndex);
    if (target == null) {
      continue;
    }
    assertNoBackupOnPrimaryMember(partition,target);
    boolean isSyncBackup=replicaIndex <= syncBackupCount;
    makeBackup(replicaVersions,replicaIndex,target,isSyncBackup);
    if (isSyncBackup) {
      sentSyncBackupCount++;
    }
  }
  return sentSyncBackupCount;
}

Fixed version (ground truth):
private int makeBackups(BackupAwareOperation backupAwareOp,int partitionId,long[] replicaVersions,int syncBackupCount,int totalBackupCount){
  int sentSyncBackupCount=0;
  InternalPartitionService partitionService=node.getPartitionService();
  InternalPartition partition=partitionService.getPartition(partitionId);
  for (int replicaIndex=1; replicaIndex <= totalBackupCount; replicaIndex++) {
    Address target=partition.getReplicaAddress(replicaIndex);
    if (target == null) {
      continue;
    }
    assertNoBackupOnPrimaryMember(partition,target);
    boolean isSyncBackup=replicaIndex <= syncBackupCount;
    Backup backup=newBackup(backupAwareOp,replicaVersions,replicaIndex,isSyncBackup);
    send(backup,target);
    if (isSyncBackup) {
      sentSyncBackupCount++;
    }
  }
  return sentSyncBackupCount;
}
Program: 48102
Project: 48102
Buggy source:
/** 
 * Verfies that the backup of a partition doesn't end up at the member that also has the primary.
 */
private void assertNoBackupOnPrimaryMember(InternalPartition partition,Address target){
  if (target.equals(node.getThisAddress())) {
    throw new IllegalStateException("String_Node_Str" + "String_Node_Str" + partition);
  }
}

Fixed version (ground truth):
/** 
 * Verifies that the backup of a partition doesn't end up at the member that also has the primary.
 */
private void assertNoBackupOnPrimaryMember(InternalPartition partition,Address target){
  if (target.equals(node.getThisAddress())) {
    throw new IllegalStateException("String_Node_Str" + "String_Node_Str" + partition);
  }
}
Program: 48103
Project: 48103
Buggy source:
BasicOperationService(NodeEngineImpl nodeEngine){
  this.nodeEngine=nodeEngine;
  this.node=nodeEngine.getNode();
  this.logger=node.getLogger(OperationService.class);
  this.defaultCallTimeout=node.getGroupProperties().OPERATION_CALL_TIMEOUT_MILLIS.getLong();
  this.executionService=nodeEngine.getExecutionService();
  int coreSize=Runtime.getRuntime().availableProcessors();
  boolean reallyMultiCore=coreSize >= CORE_SIZE_CHECK;
  int concurrencyLevel=reallyMultiCore ? coreSize * CORE_SIZE_FACTOR : CONCURRENCY_LEVEL;
  this.executingCalls=new ConcurrentHashMap<RemoteCallKey,RemoteCallKey>(INITIAL_CAPACITY,LOAD_FACTOR,concurrencyLevel);
  this.invocations=new ConcurrentHashMap<Long,BasicInvocation>(INITIAL_CAPACITY,LOAD_FACTOR,concurrencyLevel);
  this.scheduler=new BasicOperationScheduler(node,executionService,new BasicDispatcherImpl());
  this.operationHandler=new OperationHandler();
  this.operationPacketHandler=new OperationPacketHandler();
  this.responsePacketHandler=new ResponsePacketHandler();
}

Fixed version (ground truth):
BasicOperationService(NodeEngineImpl nodeEngine){
  this.nodeEngine=nodeEngine;
  this.node=nodeEngine.getNode();
  this.logger=node.getLogger(OperationService.class);
  this.defaultCallTimeout=node.getGroupProperties().OPERATION_CALL_TIMEOUT_MILLIS.getLong();
  this.executionService=nodeEngine.getExecutionService();
  int coreSize=Runtime.getRuntime().availableProcessors();
  boolean reallyMultiCore=coreSize >= CORE_SIZE_CHECK;
  int concurrencyLevel=reallyMultiCore ? coreSize * CORE_SIZE_FACTOR : CONCURRENCY_LEVEL;
  this.executingCalls=new ConcurrentHashMap<RemoteCallKey,RemoteCallKey>(INITIAL_CAPACITY,LOAD_FACTOR,concurrencyLevel);
  this.invocations=new ConcurrentHashMap<Long,BasicInvocation>(INITIAL_CAPACITY,LOAD_FACTOR,concurrencyLevel);
  this.scheduler=new BasicOperationScheduler(node,executionService,new BasicDispatcherImpl());
  this.operationHandler=new OperationHandler();
  this.operationBackupHandler=new OperationBackupHandler();
  this.operationPacketHandler=new OperationPacketHandler();
  this.responsePacketHandler=new ResponsePacketHandler();
}
Program: 48104
Project: 48104
Buggy source:
private Backup newBackup(long[] replicaVersions,int replicaIndex,boolean isSyncBackup){
  Operation backupOp=initBackupOperation(replicaIndex);
  Data backupOpData=nodeEngine.getSerializationService().toData(backupOp);
  Backup backup=new Backup(backupOpData,op.getCallerAddress(),replicaVersions,isSyncBackup);
  backup.setPartitionId(partitionId).setReplicaIndex(replicaIndex).setServiceName(serviceName).setCallerUuid(nodeEngine.getLocalMember().getUuid());
  setCallId(backup,op.getCallId());
  return backup;
}

Fixed version (ground truth):
private Backup newBackup(BackupAwareOperation backupAwareOp,long[] replicaVersions,int replicaIndex,boolean isSyncBackup){
  Operation op=(Operation)backupAwareOp;
  Operation backupOp=initBackupOperation(backupAwareOp,replicaIndex);
  Data backupOpData=nodeEngine.getSerializationService().toData(backupOp);
  Backup backup=new Backup(backupOpData,op.getCallerAddress(),replicaVersions,isSyncBackup);
  backup.setPartitionId(op.getPartitionId()).setReplicaIndex(replicaIndex).setServiceName(op.getServiceName()).setCallerUuid(nodeEngine.getLocalMember().getUuid());
  setCallId(backup,op.getCallId());
  return backup;
}
Program: 48105
Project: 48105
Buggy source:
private void handleResponse(Operation op) throws Exception {
  boolean returnsResponse=op.returnsResponse();
  Object response=null;
  if (op instanceof BackupAwareOperation) {
    BackupAwareOperation backupAwareOp=(BackupAwareOperation)op;
    int syncBackupCount=0;
    if (backupAwareOp.shouldBackup()) {
      syncBackupCount=new OperationBackupHandler(backupAwareOp).backup();
    }
    if (returnsResponse) {
      response=new NormalResponse(op.getResponse(),op.getCallId(),syncBackupCount,op.isUrgent());
    }
  }
  if (returnsResponse) {
    if (response == null) {
      response=op.getResponse();
    }
    ResponseHandler responseHandler=op.getResponseHandler();
    if (responseHandler == null) {
      throw new IllegalStateException("String_Node_Str");
    }
    responseHandler.sendResponse(response);
  }
}

Fixed version (ground truth):
private void handleResponse(Operation op) throws Exception {
  boolean returnsResponse=op.returnsResponse();
  Object response=null;
  if (op instanceof BackupAwareOperation) {
    BackupAwareOperation backupAwareOp=(BackupAwareOperation)op;
    int syncBackupCount=0;
    if (backupAwareOp.shouldBackup()) {
      syncBackupCount=operationBackupHandler.backup(backupAwareOp);
    }
    if (returnsResponse) {
      response=new NormalResponse(op.getResponse(),op.getCallId(),syncBackupCount,op.isUrgent());
    }
  }
  if (returnsResponse) {
    if (response == null) {
      response=op.getResponse();
    }
    ResponseHandler responseHandler=op.getResponseHandler();
    if (responseHandler == null) {
      throw new IllegalStateException("String_Node_Str");
    }
    responseHandler.sendResponse(response);
  }
}
Program: 48106
Project: 48106
Buggy source:
@Test public void testGracefulShutdown2() throws Exception {
  Config config=new Config();
  config.getMapConfig(MAP_NAME).setBackupCount(2);
  config.setProperty(GroupProperties.PROP_PARTITION_COUNT,"String_Node_Str");
  TestHazelcastInstanceFactory f=createHazelcastInstanceFactory(6);
  final HazelcastInstance hz=f.newHazelcastInstance(config);
  final IMap<Object,Object> map=hz.getMap(MAP_NAME);
  final int size=200000;
  for (int i=0; i < size; i++) {
    map.put(i,i);
  }
  final HazelcastInstance hz2=f.newHazelcastInstance(config);
  final IMap<Object,Object> map2=hz2.getMap(MAP_NAME);
  assertEquals(size,map2.size());
  final HazelcastInstance hz3=f.newHazelcastInstance(config);
  final IMap<Object,Object> map3=hz3.getMap(MAP_NAME);
  final HazelcastInstance hz4=f.newHazelcastInstance(config);
  final IMap<Object,Object> map4=hz4.getMap(MAP_NAME);
  assertEquals(size,map3.size());
  assertEquals(size,map4.size());
  final HazelcastInstance hz5=f.newHazelcastInstance(config);
  final IMap<Object,Object> map5=hz5.getMap(MAP_NAME);
  final HazelcastInstance hz6=f.newHazelcastInstance(config);
  final IMap<Object,Object> map6=hz6.getMap(MAP_NAME);
  assertEquals(size,map5.size());
  assertEquals(size,map6.size());
  hz.shutdown();
  hz2.shutdown();
  assertEquals(size,map3.size());
  assertEquals(size,map4.size());
  assertEquals(size,map5.size());
  assertEquals(size,map6.size());
  hz3.shutdown();
  hz4.shutdown();
  assertEquals(size,map5.size());
  assertEquals(size,map6.size());
}

Fixed version (ground truth):
@Test public void testGracefulShutdown2() throws Exception {
  Config config=new Config();
  config.getMapConfig(MAP_NAME).setBackupCount(2);
  TestHazelcastInstanceFactory f=createHazelcastInstanceFactory(6);
  final HazelcastInstance hz=f.newHazelcastInstance(config);
  final IMap<Object,Object> map=hz.getMap(MAP_NAME);
  final int size=50000;
  for (int i=0; i < size; i++) {
    map.put(i,i);
  }
  final HazelcastInstance hz2=f.newHazelcastInstance(config);
  final IMap<Object,Object> map2=hz2.getMap(MAP_NAME);
  assertEquals(size,map2.size());
  final HazelcastInstance hz3=f.newHazelcastInstance(config);
  final IMap<Object,Object> map3=hz3.getMap(MAP_NAME);
  final HazelcastInstance hz4=f.newHazelcastInstance(config);
  final IMap<Object,Object> map4=hz4.getMap(MAP_NAME);
  assertEquals(size,map3.size());
  assertEquals(size,map4.size());
  final HazelcastInstance hz5=f.newHazelcastInstance(config);
  final IMap<Object,Object> map5=hz5.getMap(MAP_NAME);
  final HazelcastInstance hz6=f.newHazelcastInstance(config);
  final IMap<Object,Object> map6=hz6.getMap(MAP_NAME);
  assertEquals(size,map5.size());
  assertEquals(size,map6.size());
  hz.shutdown();
  hz2.shutdown();
  assertEquals(size,map3.size());
  assertEquals(size,map4.size());
  assertEquals(size,map5.size());
  assertEquals(size,map6.size());
  hz3.shutdown();
  hz4.shutdown();
  assertEquals(size,map5.size());
  assertEquals(size,map6.size());
}
Program: 48108
Project: 48108
Buggy source:
private void testBackupMigrationAndRecovery(int nodeCount,int backupCount,int mapSize) throws Exception {
  TestHazelcastInstanceFactory nodeFactory=createHazelcastInstanceFactory(nodeCount);
  final String name=MAP_NAME;
  final Config config=new Config();
  config.setProperty(GroupProperties.PROP_PARTITION_COUNT,"String_Node_Str");
  config.setProperty(GroupProperties.PROP_PARTITION_BACKUP_SYNC_INTERVAL,"String_Node_Str");
  config.getMapConfig(name).setBackupCount(backupCount).setStatisticsEnabled(true);
  final HazelcastInstance[] instances=new HazelcastInstance[nodeCount];
  HazelcastInstance hz=nodeFactory.newHazelcastInstance(config);
  instances[0]=hz;
  IMap map1=hz.getMap(name);
  for (int i=0; i < mapSize; i++) {
    map1.put(i,"String_Node_Str" + i);
  }
  checkMapSizes(mapSize,backupCount,instances);
  for (int i=1; i < nodeCount; i++) {
    instances[i]=nodeFactory.newHazelcastInstance(config);
    checkMapSizes(mapSize,backupCount,instances);
  }
  final Random rand=new Random();
  for (int i=1; i < nodeCount; i++) {
    int ix;
    do {
      ix=rand.nextInt(nodeCount);
    }
 while (instances[ix] == null);
    final CountDownLatch latch=new CountDownLatch(1);
    instances[ix].getLifecycleService().addLifecycleListener(new LifecycleListener(){
      @Override public void stateChanged(      LifecycleEvent event){
        if (event.getState().equals(LifecycleEvent.LifecycleState.SHUTDOWN)) {
          latch.countDown();
        }
      }
    }
);
    latch.await(5,TimeUnit.SECONDS);
    TestUtil.terminateInstance(instances[ix]);
    instances[ix]=null;
    checkMapSizes(mapSize,backupCount,instances);
  }
}

Fixed version (ground truth):
private void testBackupMigrationAndRecovery(int nodeCount,int backupCount,int mapSize) throws Exception {
  TestHazelcastInstanceFactory nodeFactory=createHazelcastInstanceFactory(nodeCount);
  final String name=MAP_NAME;
  final Config config=new Config();
  config.setProperty(GroupProperties.PROP_PARTITION_BACKUP_SYNC_INTERVAL,"String_Node_Str");
  config.getMapConfig(name).setBackupCount(backupCount).setStatisticsEnabled(true);
  final HazelcastInstance[] instances=new HazelcastInstance[nodeCount];
  HazelcastInstance hz=nodeFactory.newHazelcastInstance(config);
  instances[0]=hz;
  IMap map1=hz.getMap(name);
  for (int i=0; i < mapSize; i++) {
    map1.put(i,"String_Node_Str" + i);
  }
  checkMapSizes(mapSize,backupCount,instances);
  for (int i=1; i < nodeCount; i++) {
    instances[i]=nodeFactory.newHazelcastInstance(config);
    checkMapSizes(mapSize,backupCount,instances);
  }
  final Random rand=new Random();
  for (int i=1; i < nodeCount; i++) {
    int ix;
    do {
      ix=rand.nextInt(nodeCount);
    }
 while (instances[ix] == null);
    TestUtil.terminateInstance(instances[ix]);
    instances[ix]=null;
    checkMapSizes(mapSize,backupCount,instances);
  }
}
Program: 48109
Project: 48109
Buggy source:
@Test public void testGracefulShutdown() throws Exception {
  int size=250000;
  TestHazelcastInstanceFactory nodeFactory=createHazelcastInstanceFactory(4);
  final Config config=new Config();
  config.setProperty(GroupProperties.PROP_PARTITION_COUNT,"String_Node_Str");
  HazelcastInstance h1=nodeFactory.newHazelcastInstance(config);
  IMap m1=h1.getMap(MAP_NAME);
  for (int i=0; i < size; i++) {
    m1.put(i,i);
  }
  HazelcastInstance h2=nodeFactory.newHazelcastInstance(config);
  IMap m2=h2.getMap(MAP_NAME);
  h1.shutdown();
  assertEquals(size,m2.size());
  HazelcastInstance h3=nodeFactory.newHazelcastInstance(config);
  IMap m3=h3.getMap(MAP_NAME);
  h2.shutdown();
  assertEquals(size,m3.size());
  HazelcastInstance h4=nodeFactory.newHazelcastInstance(config);
  IMap m4=h4.getMap(MAP_NAME);
  h3.shutdown();
  assertEquals(size,m4.size());
}

Fixed version (ground truth):
@Test public void testGracefulShutdown() throws Exception {
  int size=50000;
  TestHazelcastInstanceFactory nodeFactory=createHazelcastInstanceFactory(4);
  final Config config=new Config();
  HazelcastInstance h1=nodeFactory.newHazelcastInstance(config);
  IMap m1=h1.getMap(MAP_NAME);
  for (int i=0; i < size; i++) {
    m1.put(i,i);
  }
  HazelcastInstance h2=nodeFactory.newHazelcastInstance(config);
  IMap m2=h2.getMap(MAP_NAME);
  h1.shutdown();
  assertEquals(size,m2.size());
  HazelcastInstance h3=nodeFactory.newHazelcastInstance(config);
  IMap m3=h3.getMap(MAP_NAME);
  h2.shutdown();
  assertEquals(size,m3.size());
  HazelcastInstance h4=nodeFactory.newHazelcastInstance(config);
  IMap m4=h4.getMap(MAP_NAME);
  h3.shutdown();
  assertEquals(size,m4.size());
}
Program: 48110
Project: 48110
Buggy source:
/** 
 * Test for the issue https://code.google.com/p/hazelcast/issues/detail?id=395.
 */
@Test public void testBackupMigrationAndRecovery2() throws Exception {
  testBackupMigrationAndRecovery(6,2,50000);
}

Fixed version (ground truth):
/** 
 * Test for the issue https://code.google.com/p/hazelcast/issues/detail?id=395.
 */
@Test public void testBackupMigrationAndRecovery2() throws Exception {
  testBackupMigrationAndRecovery(6,2,5000);
}
Program: 48114
Project: 48114
Buggy source:
@Override public boolean prepareToSafeShutdown(long timeout,TimeUnit unit){
  long timeoutInMillis=unit.toMillis(timeout);
  int sleep=1000;
  while (timeoutInMillis > 0) {
    while (timeoutInMillis > 0 && shouldWaitMigrationOrBackups(Level.INFO)) {
      try {
        Thread.sleep(sleep);
      }
 catch (      InterruptedException ignored) {
      }
      timeoutInMillis-=sleep;
    }
    if (timeoutInMillis <= 0) {
      return false;
    }
    if (node.isMaster()) {
      syncPartitionRuntimeState();
    }
 else {
      while (timeoutInMillis > 0 && hasOnGoingMigrationMaster(Level.WARNING)) {
        logger.info("String_Node_Str");
        try {
          Thread.sleep(sleep);
        }
 catch (        InterruptedException ignored) {
        }
        timeoutInMillis-=sleep;
      }
      if (timeoutInMillis <= 0) {
        return false;
      }
    }
    long start=Clock.currentTimeMillis();
    boolean ok=checkReplicaSyncState();
    timeoutInMillis-=(Clock.currentTimeMillis() - start);
    if (ok) {
      logger.finest("String_Node_Str");
      return true;
    }
 else {
      if (timeoutInMillis <= 0) {
        return false;
      }
      logger.info("String_Node_Str" + "String_Node_Str" + timeoutInMillis + "String_Node_Str");
      try {
        Thread.sleep(sleep);
      }
 catch (      InterruptedException ignored) {
      }
      timeoutInMillis-=sleep;
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean prepareToSafeShutdown(long timeout,TimeUnit unit){
  long timeoutInMillis=unit.toMillis(timeout);
  int sleep=1000;
  while (timeoutInMillis > 0) {
    while (timeoutInMillis > 0 && shouldWaitMigrationOrBackups(Level.INFO)) {
      try {
        Thread.sleep(sleep);
      }
 catch (      InterruptedException ignored) {
      }
      timeoutInMillis-=sleep;
    }
    if (timeoutInMillis <= 0) {
      break;
    }
    if (node.isMaster()) {
      syncPartitionRuntimeState();
    }
 else {
      while (timeoutInMillis > 0 && hasOnGoingMigrationMaster(Level.WARNING)) {
        logger.info("String_Node_Str");
        try {
          Thread.sleep(sleep);
        }
 catch (        InterruptedException ignored) {
        }
        timeoutInMillis-=sleep;
      }
      if (timeoutInMillis <= 0) {
        break;
      }
    }
    long start=Clock.currentTimeMillis();
    boolean ok=checkReplicaSyncState();
    timeoutInMillis-=(Clock.currentTimeMillis() - start);
    if (ok) {
      logger.finest("String_Node_Str");
      return true;
    }
 else {
      if (timeoutInMillis <= 0) {
        break;
      }
      logger.info("String_Node_Str" + "String_Node_Str" + timeoutInMillis + "String_Node_Str");
      try {
        Thread.sleep(sleep);
      }
 catch (      InterruptedException ignored) {
      }
      timeoutInMillis-=sleep;
    }
  }
  return false;
}
Program: 48115
Project: 48115
Buggy source:
@Test public void testGracefulShutdown2() throws Exception {
  Config config=new Config();
  config.getMapConfig(MAP_NAME).setBackupCount(2);
  config.setProperty(GroupProperties.PROP_PARTITION_COUNT,"String_Node_Str");
  TestHazelcastInstanceFactory f=createHazelcastInstanceFactory(6);
  final HazelcastInstance hz=f.newHazelcastInstance(config);
  final IMap<Object,Object> map=hz.getMap(MAP_NAME);
  final int size=200000;
  for (int i=0; i < size; i++) {
    map.put(i,i);
  }
  final HazelcastInstance hz2=f.newHazelcastInstance(config);
  final IMap<Object,Object> map2=hz2.getMap(MAP_NAME);
  assertEquals(size,map2.size());
  final HazelcastInstance hz3=f.newHazelcastInstance(config);
  final IMap<Object,Object> map3=hz3.getMap(MAP_NAME);
  final HazelcastInstance hz4=f.newHazelcastInstance(config);
  final IMap<Object,Object> map4=hz4.getMap(MAP_NAME);
  assertEquals(size,map3.size());
  assertEquals(size,map4.size());
  final HazelcastInstance hz5=f.newHazelcastInstance(config);
  final IMap<Object,Object> map5=hz5.getMap(MAP_NAME);
  final HazelcastInstance hz6=f.newHazelcastInstance(config);
  final IMap<Object,Object> map6=hz6.getMap(MAP_NAME);
  assertEquals(size,map5.size());
  assertEquals(size,map6.size());
  hz.shutdown();
  hz2.shutdown();
  assertEquals(size,map3.size());
  assertEquals(size,map4.size());
  assertEquals(size,map5.size());
  assertEquals(size,map6.size());
  hz3.shutdown();
  hz4.shutdown();
  assertEquals(size,map5.size());
  assertEquals(size,map6.size());
}

Fixed version (ground truth):
@Test public void testGracefulShutdown2() throws Exception {
  Config config=new Config();
  config.getMapConfig(MAP_NAME).setBackupCount(2);
  TestHazelcastInstanceFactory f=createHazelcastInstanceFactory(6);
  final HazelcastInstance hz=f.newHazelcastInstance(config);
  final IMap<Object,Object> map=hz.getMap(MAP_NAME);
  final int size=50000;
  for (int i=0; i < size; i++) {
    map.put(i,i);
  }
  final HazelcastInstance hz2=f.newHazelcastInstance(config);
  final IMap<Object,Object> map2=hz2.getMap(MAP_NAME);
  assertEquals(size,map2.size());
  final HazelcastInstance hz3=f.newHazelcastInstance(config);
  final IMap<Object,Object> map3=hz3.getMap(MAP_NAME);
  final HazelcastInstance hz4=f.newHazelcastInstance(config);
  final IMap<Object,Object> map4=hz4.getMap(MAP_NAME);
  assertEquals(size,map3.size());
  assertEquals(size,map4.size());
  final HazelcastInstance hz5=f.newHazelcastInstance(config);
  final IMap<Object,Object> map5=hz5.getMap(MAP_NAME);
  final HazelcastInstance hz6=f.newHazelcastInstance(config);
  final IMap<Object,Object> map6=hz6.getMap(MAP_NAME);
  assertEquals(size,map5.size());
  assertEquals(size,map6.size());
  hz.shutdown();
  hz2.shutdown();
  assertEquals(size,map3.size());
  assertEquals(size,map4.size());
  assertEquals(size,map5.size());
  assertEquals(size,map6.size());
  hz3.shutdown();
  hz4.shutdown();
  assertEquals(size,map5.size());
  assertEquals(size,map6.size());
}
Program: 48117
Project: 48117
Buggy source:
private void testBackupMigrationAndRecovery(int nodeCount,int backupCount,int mapSize) throws Exception {
  TestHazelcastInstanceFactory nodeFactory=createHazelcastInstanceFactory(nodeCount);
  final String name=MAP_NAME;
  final Config config=new Config();
  config.setProperty(GroupProperties.PROP_PARTITION_COUNT,"String_Node_Str");
  config.setProperty(GroupProperties.PROP_PARTITION_BACKUP_SYNC_INTERVAL,"String_Node_Str");
  config.getMapConfig(name).setBackupCount(backupCount).setStatisticsEnabled(true);
  final HazelcastInstance[] instances=new HazelcastInstance[nodeCount];
  HazelcastInstance hz=nodeFactory.newHazelcastInstance(config);
  instances[0]=hz;
  IMap map1=hz.getMap(name);
  for (int i=0; i < mapSize; i++) {
    map1.put(i,"String_Node_Str" + i);
  }
  checkMapSizes(mapSize,backupCount,instances);
  for (int i=1; i < nodeCount; i++) {
    instances[i]=nodeFactory.newHazelcastInstance(config);
    checkMapSizes(mapSize,backupCount,instances);
  }
  final Random rand=new Random();
  for (int i=1; i < nodeCount; i++) {
    int ix;
    do {
      ix=rand.nextInt(nodeCount);
    }
 while (instances[ix] == null);
    final CountDownLatch latch=new CountDownLatch(1);
    instances[ix].getLifecycleService().addLifecycleListener(new LifecycleListener(){
      @Override public void stateChanged(      LifecycleEvent event){
        if (event.getState().equals(LifecycleEvent.LifecycleState.SHUTDOWN)) {
          latch.countDown();
        }
      }
    }
);
    latch.await(5,TimeUnit.SECONDS);
    TestUtil.terminateInstance(instances[ix]);
    instances[ix]=null;
    checkMapSizes(mapSize,backupCount,instances);
  }
}

Fixed version (ground truth):
private void testBackupMigrationAndRecovery(int nodeCount,int backupCount,int mapSize) throws Exception {
  TestHazelcastInstanceFactory nodeFactory=createHazelcastInstanceFactory(nodeCount);
  final String name=MAP_NAME;
  final Config config=new Config();
  config.setProperty(GroupProperties.PROP_PARTITION_BACKUP_SYNC_INTERVAL,"String_Node_Str");
  config.getMapConfig(name).setBackupCount(backupCount).setStatisticsEnabled(true);
  final HazelcastInstance[] instances=new HazelcastInstance[nodeCount];
  HazelcastInstance hz=nodeFactory.newHazelcastInstance(config);
  instances[0]=hz;
  IMap map1=hz.getMap(name);
  for (int i=0; i < mapSize; i++) {
    map1.put(i,"String_Node_Str" + i);
  }
  checkMapSizes(mapSize,backupCount,instances);
  for (int i=1; i < nodeCount; i++) {
    instances[i]=nodeFactory.newHazelcastInstance(config);
    checkMapSizes(mapSize,backupCount,instances);
  }
  final Random rand=new Random();
  for (int i=1; i < nodeCount; i++) {
    int ix;
    do {
      ix=rand.nextInt(nodeCount);
    }
 while (instances[ix] == null);
    TestUtil.terminateInstance(instances[ix]);
    instances[ix]=null;
    checkMapSizes(mapSize,backupCount,instances);
  }
}
Program: 48118
Project: 48118
Buggy source:
@Test public void testGracefulShutdown() throws Exception {
  int size=250000;
  TestHazelcastInstanceFactory nodeFactory=createHazelcastInstanceFactory(4);
  final Config config=new Config();
  config.setProperty(GroupProperties.PROP_PARTITION_COUNT,"String_Node_Str");
  HazelcastInstance h1=nodeFactory.newHazelcastInstance(config);
  IMap m1=h1.getMap(MAP_NAME);
  for (int i=0; i < size; i++) {
    m1.put(i,i);
  }
  HazelcastInstance h2=nodeFactory.newHazelcastInstance(config);
  IMap m2=h2.getMap(MAP_NAME);
  h1.shutdown();
  assertEquals(size,m2.size());
  HazelcastInstance h3=nodeFactory.newHazelcastInstance(config);
  IMap m3=h3.getMap(MAP_NAME);
  h2.shutdown();
  assertEquals(size,m3.size());
  HazelcastInstance h4=nodeFactory.newHazelcastInstance(config);
  IMap m4=h4.getMap(MAP_NAME);
  h3.shutdown();
  assertEquals(size,m4.size());
}

Fixed version (ground truth):
@Test public void testGracefulShutdown() throws Exception {
  int size=50000;
  TestHazelcastInstanceFactory nodeFactory=createHazelcastInstanceFactory(4);
  final Config config=new Config();
  HazelcastInstance h1=nodeFactory.newHazelcastInstance(config);
  IMap m1=h1.getMap(MAP_NAME);
  for (int i=0; i < size; i++) {
    m1.put(i,i);
  }
  HazelcastInstance h2=nodeFactory.newHazelcastInstance(config);
  IMap m2=h2.getMap(MAP_NAME);
  h1.shutdown();
  assertEquals(size,m2.size());
  HazelcastInstance h3=nodeFactory.newHazelcastInstance(config);
  IMap m3=h3.getMap(MAP_NAME);
  h2.shutdown();
  assertEquals(size,m3.size());
  HazelcastInstance h4=nodeFactory.newHazelcastInstance(config);
  IMap m4=h4.getMap(MAP_NAME);
  h3.shutdown();
  assertEquals(size,m4.size());
}
Program: 48119
Project: 48119
Buggy source:
/** 
 * Test for the issue https://code.google.com/p/hazelcast/issues/detail?id=395.
 */
@Test public void testBackupMigrationAndRecovery2() throws Exception {
  testBackupMigrationAndRecovery(6,2,50000);
}

Fixed version (ground truth):
/** 
 * Test for the issue https://code.google.com/p/hazelcast/issues/detail?id=395.
 */
@Test public void testBackupMigrationAndRecovery2() throws Exception {
  testBackupMigrationAndRecovery(6,2,5000);
}
Program: 48121
Project: 48121
Buggy source:
private void addPossibleAddresses(final Set<Address> possibleAddresses,final String host,final InetAddress inetAddress,final int port,final int count) throws UnknownHostException {
  for (int i=0; i < count; i++) {
    final int currentPort=port + i;
    final Address address=host != null ? new Address(host,currentPort) : new Address(inetAddress,currentPort);
    if (!isLocalAddress(address)) {
      possibleAddresses.add(address);
    }
  }
}

Fixed version (ground truth):
private void addPossibleAddresses(final Set<Address> possibleAddresses,final String host,final InetAddress inetAddress,final int port,final int count) throws UnknownHostException {
  for (int i=0; i < count; i++) {
    int currentPort=port + i;
    Address address=host != null ? new Address(host,currentPort) : new Address(inetAddress,currentPort);
    if (!isLocalAddress(address)) {
      possibleAddresses.add(address);
    }
  }
}
Program: 48124
Project: 48124
Buggy source:
private void addPossibleAddresses(final Set<Address> possibleAddresses,final String host,final InetAddress inetAddress,final int port,final int count) throws UnknownHostException {
  for (int i=0; i < count; i++) {
    final int currentPort=port + i;
    final Address address=host != null ? new Address(host,currentPort) : new Address(inetAddress,currentPort);
    if (!isLocalAddress(address)) {
      possibleAddresses.add(address);
    }
  }
}

Fixed version (ground truth):
private void addPossibleAddresses(final Set<Address> possibleAddresses,final String host,final InetAddress inetAddress,final int port,final int count) throws UnknownHostException {
  for (int i=0; i < count; i++) {
    int currentPort=port + i;
    Address address=host != null ? new Address(host,currentPort) : new Address(inetAddress,currentPort);
    if (!isLocalAddress(address)) {
      possibleAddresses.add(address);
    }
  }
}
Program: 48126
Project: 48126
Buggy source:
@Override public void init(final NodeEngine nodeEngine,Properties properties){
  final int partitionCount=nodeEngine.getPartitionService().getPartitionCount();
  final PartitionContainer[] partitionContainers=mapServiceContext.getPartitionContainers();
  for (int i=0; i < partitionCount; i++) {
    partitionContainers[i]=new PartitionContainer(mapServiceContext.getService(),i);
  }
  final LockService lockService=nodeEngine.getSharedService(LockService.SERVICE_NAME);
  if (lockService != null) {
    lockService.registerLockStoreConstructor(mapServiceContext.serviceName(),new ConstructorFunction<ObjectNamespace,LockStoreInfo>(){
      public LockStoreInfo createNew(      final ObjectNamespace key){
        final MapContainer mapContainer=mapServiceContext.getMapContainer(key.getObjectName());
        return new LockStoreInfo(){
          public int getBackupCount(){
            return mapContainer.getBackupCount();
          }
          public int getAsyncBackupCount(){
            return mapContainer.getAsyncBackupCount();
          }
        }
;
      }
    }
);
  }
  mapServiceContext.getExpirationManager().start();
}

Fixed version (ground truth):
@Override public void init(final NodeEngine nodeEngine,Properties properties){
  mapServiceContext.initPartitionsContainers();
  final LockService lockService=nodeEngine.getSharedService(LockService.SERVICE_NAME);
  if (lockService != null) {
    lockService.registerLockStoreConstructor(mapServiceContext.serviceName(),new ConstructorFunction<ObjectNamespace,LockStoreInfo>(){
      public LockStoreInfo createNew(      final ObjectNamespace key){
        final MapContainer mapContainer=mapServiceContext.getMapContainer(key.getObjectName());
        return new LockStoreInfo(){
          public int getBackupCount(){
            return mapContainer.getBackupCount();
          }
          public int getAsyncBackupCount(){
            return mapContainer.getAsyncBackupCount();
          }
        }
;
      }
    }
);
  }
  mapServiceContext.getExpirationManager().start();
}
Program: 48127
Project: 48127
Buggy source:
private Object resolveCallTimeout(){
  if (logger.isFinestEnabled()) {
    logger.finest("String_Node_Str" + toString());
  }
  if (op instanceof WaitSupport) {
    long waitTimeout=op.getWaitTimeout();
    waitTimeout-=callTimeout;
    op.setWaitTimeout(waitTimeout);
  }
  invokeCount--;
  return RETRY_RESPONSE;
}

Fixed version (ground truth):
@edu.umd.cs.findbugs.annotations.SuppressWarnings(value="String_Node_Str",justification="String_Node_Str") private Object resolveCallTimeout(){
  if (logger.isFinestEnabled()) {
    logger.finest("String_Node_Str" + toString());
  }
  if (op instanceof WaitSupport) {
    long waitTimeout=op.getWaitTimeout();
    waitTimeout-=callTimeout;
    op.setWaitTimeout(waitTimeout);
  }
  invokeCount--;
  return RETRY_RESPONSE;
}
Program: 48129
Project: 48129
Buggy source:
private LoadAllKeysTask(Collection<Data> keys,boolean replaceExistingValues,AtomicBoolean loaded){
  this.keys=keys;
  this.replaceExistingValues=replaceExistingValues;
  this.loaded=loaded;
}

Fixed version (ground truth):
private LoadAllKeysTask(Collection<Data> keys,boolean replaceExistingValues){
  this.keys=keys;
  this.replaceExistingValues=replaceExistingValues;
}
Program: 48130
Project: 48130
Buggy source:
@Override public void loadAllFromStore(Collection<Data> keys,boolean replaceExistingValues){
  if (keys.isEmpty()) {
    return;
  }
  loaded.set(false);
  final NodeEngine nodeEngine=mapService.getNodeEngine();
  ExecutionService executionService=nodeEngine.getExecutionService();
  executionService.submit("String_Node_Str",new LoadAllKeysTask(keys,replaceExistingValues,loaded));
}

Fixed version (ground truth):
@Override public void loadAllFromStore(Collection<Data> keys,boolean replaceExistingValues){
  if (keys.isEmpty()) {
    return;
  }
  loaded.set(false);
  final NodeEngine nodeEngine=mapService.getNodeEngine();
  ExecutionService executionService=nodeEngine.getExecutionService();
  executionService.submit("String_Node_Str",new LoadAllKeysTask(keys,replaceExistingValues));
}
Program: 48131
Project: 48131
Buggy source:
private Object evict0(Data key){
  Record record=records.get(key);
  Object value=null;
  if (record != null) {
    value=record.getValue();
    final long lastUpdateTime=record.getLastUpdateTime();
    putEvictionStagingArea(key,value,lastUpdateTime);
    mapService.interceptRemove(name,value);
    updateSizeEstimator(-calculateRecordSize(record));
    deleteRecord(key);
    removeIndex(key);
  }
  return value;
}

Fixed version (ground truth):
private Object evict0(Data key){
  Record record=records.get(key);
  Object value=null;
  if (record != null) {
    value=record.getValue();
    final long lastUpdateTime=record.getLastUpdateTime();
    putEvictionStagingArea(key,value,lastUpdateTime);
    mapService.interceptRemove(name,value);
    updateSizeEstimator(-calculateRecordSize(record));
    deleteRecord(key);
    removeIndex(key);
  }
  removeFromWriteBehindWaitingDeletions(key);
  return value;
}
Program: 48132
Project: 48132
Buggy source:
public Object put(Data key,Object value,long ttl){
  checkIfLoaded();
  final long now=getNow();
  earlyWriteCleanup(now);
  markRecordStoreExpirable(ttl);
  Record record=records.get(key);
  Object oldValue=null;
  if (record == null) {
    if (mapContainer.getStore() != null) {
      oldValue=mapContainer.getStore().load(mapService.toObject(key));
    }
    value=mapService.interceptPut(name,null,value);
    value=mapStoreWrite(key,value,null,now);
    record=mapService.createRecord(name,key,value,ttl,now);
    records.put(key,record);
    updateSizeEstimator(calculateRecordSize(record));
    saveIndex(record);
  }
 else {
    oldValue=record.getValue();
    value=mapService.interceptPut(name,oldValue,value);
    value=mapStoreWrite(key,value,record,now);
    updateSizeEstimator(-calculateRecordSize(record));
    setRecordValue(record,value,now);
    updateSizeEstimator(calculateRecordSize(record));
    updateTtl(record,ttl);
    saveIndex(record);
  }
  removeFromWriteBehindWaitingDeletions(key);
  return oldValue;
}

Fixed version (ground truth):
public Object put(Data key,Object value,long ttl){
  checkIfLoaded();
  final long now=getNow();
  earlyWriteCleanup(now);
  markRecordStoreExpirable(ttl);
  Record record=records.get(key);
  Object oldValue=null;
  if (record == null) {
    if (mapContainer.getStore() != null) {
      oldValue=loadFromStoreOrStagingArea(key);
    }
    value=mapService.interceptPut(name,null,value);
    value=mapStoreWrite(key,value,null,now);
    record=mapService.createRecord(name,key,value,ttl,now);
    records.put(key,record);
    updateSizeEstimator(calculateRecordSize(record));
    saveIndex(record);
  }
 else {
    oldValue=record.getValue();
    value=mapService.interceptPut(name,oldValue,value);
    value=mapStoreWrite(key,value,record,now);
    updateSizeEstimator(-calculateRecordSize(record));
    setRecordValue(record,value,now);
    updateSizeEstimator(calculateRecordSize(record));
    updateTtl(record,ttl);
    saveIndex(record);
  }
  removeFromWriteBehindWaitingDeletions(key);
  return oldValue;
}
Program: 48133
Project: 48133
Buggy source:
private Record getRecordInternal(Data dataKey,boolean enableIndex){
  Record record=null;
  if (mapContainer.getStore() != null) {
    final Object value=mapContainer.getStore().load(mapService.toObject(dataKey));
    if (value != null) {
      record=mapService.createRecord(name,dataKey,value,DEFAULT_TTL,getNow());
      records.put(dataKey,record);
      if (enableIndex) {
        saveIndex(record);
      }
      updateSizeEstimator(calculateRecordSize(record));
    }
  }
  return record;
}

Fixed version (ground truth):
private Record getRecordInternal(Data key,boolean enableIndex){
  Record record=null;
  if (mapContainer.getStore() != null) {
    final Object value=loadFromStoreOrStagingArea(key);
    if (value != null) {
      record=mapService.createRecord(name,key,value,DEFAULT_TTL,getNow());
      records.put(key,record);
      if (enableIndex) {
        saveIndex(record);
      }
      updateSizeEstimator(calculateRecordSize(record));
    }
  }
  return record;
}
Program: 48134
Project: 48134
Buggy source:
@Override public Object get(Data key){
  checkIfLoaded();
  if (hasWaitingWriteBehindDeleteOperation(key)) {
    return null;
  }
  long now=getNow();
  Record record=records.get(key);
  record=nullIfExpired(record);
  Object value=null;
  if (record == null) {
    if (mapContainer.getStore() != null) {
      value=getFromStoreOrEvictionStagingArea(key);
      if (value != null) {
        record=mapService.createRecord(name,key,value,DEFAULT_TTL,now);
        records.put(key,record);
        saveIndex(record);
        updateSizeEstimator(calculateRecordSize(record));
      }
    }
  }
 else {
    accessRecord(record,now);
    value=record.getValue();
  }
  value=mapService.interceptGet(name,value);
  postReadCleanUp(now);
  return value;
}

Fixed version (ground truth):
@Override public Object get(Data key){
  checkIfLoaded();
  long now=getNow();
  Record record=records.get(key);
  record=nullIfExpired(record);
  Object value=null;
  if (record == null) {
    if (mapContainer.getStore() != null) {
      value=loadFromStoreOrStagingArea(key);
      if (value != null) {
        record=mapService.createRecord(name,key,value,DEFAULT_TTL,now);
        records.put(key,record);
        saveIndex(record);
        updateSizeEstimator(calculateRecordSize(record));
      }
    }
  }
 else {
    accessRecord(record,now);
    value=record.getValue();
  }
  value=mapService.interceptGet(name,value);
  postReadCleanUp(now);
  return value;
}
Program: 48135
Project: 48135
Buggy source:
@Override public boolean containsKey(Data key){
  checkIfLoaded();
  final long now=getNow();
  Record record=records.get(key);
  if (hasWaitingWriteBehindDeleteOperation(key)) {
    return false;
  }
  record=nullIfExpired(record);
  if (record == null) {
    if (mapContainer.getStore() != null) {
      Object value=getFromStoreOrEvictionStagingArea(key);
      if (value != null) {
        record=mapService.createRecord(name,key,value,DEFAULT_TTL,now);
        records.put(key,record);
        updateSizeEstimator(calculateRecordSize(record));
      }
    }
  }
  boolean contains=record != null;
  if (contains) {
    accessRecord(record,now);
  }
  postReadCleanUp(now);
  return contains;
}

Fixed version (ground truth):
@Override public boolean containsKey(Data key){
  checkIfLoaded();
  final long now=getNow();
  Record record=records.get(key);
  record=nullIfExpired(record);
  if (record == null) {
    if (mapContainer.getStore() != null) {
      Object value=loadFromStoreOrStagingArea(key);
      if (value != null) {
        record=mapService.createRecord(name,key,value,DEFAULT_TTL,now);
        records.put(key,record);
        updateSizeEstimator(calculateRecordSize(record));
      }
    }
  }
  boolean contains=record != null;
  if (contains) {
    accessRecord(record,now);
  }
  postReadCleanUp(now);
  return contains;
}
Program: 48136
Project: 48136
Buggy source:
@Override public Object remove(Data key){
  checkIfLoaded();
  final long now=getNow();
  earlyWriteCleanup(now);
  Record record=records.get(key);
  Object oldValue=null;
  if (record == null) {
    if (mapContainer.getStore() != null) {
      oldValue=getFromStoreOrEvictionStagingArea(key);
      if (oldValue != null) {
        removeIndex(key);
        mapStoreDelete(null,key,now);
      }
    }
  }
 else {
    oldValue=record.getValue();
    oldValue=mapService.interceptRemove(name,oldValue);
    if (oldValue != null) {
      removeIndex(key);
      mapStoreDelete(record,key,now);
    }
    updateSizeEstimator(-calculateRecordSize(record));
    deleteRecord(key);
  }
  return oldValue;
}

Fixed version (ground truth):
@Override public Object remove(Data key){
  checkIfLoaded();
  final long now=getNow();
  earlyWriteCleanup(now);
  Record record=records.get(key);
  Object oldValue=null;
  if (record == null) {
    if (mapContainer.getStore() != null) {
      oldValue=loadFromStoreOrStagingArea(key);
      if (oldValue != null) {
        removeIndex(key);
        mapStoreDelete(null,key,now);
      }
    }
  }
 else {
    oldValue=record.getValue();
    oldValue=mapService.interceptRemove(name,oldValue);
    if (oldValue != null) {
      removeIndex(key);
      mapStoreDelete(record,key,now);
    }
    updateSizeEstimator(-calculateRecordSize(record));
    deleteRecord(key);
  }
  return oldValue;
}
Program: 48138
Project: 48138
Buggy source:
public Object putIfAbsent(Data key,Object value,long ttl){
  checkIfLoaded();
  final long now=getNow();
  earlyWriteCleanup(now);
  markRecordStoreExpirable(ttl);
  Record record=records.get(key);
  Object oldValue=null;
  if (record == null) {
    if (mapContainer.getStore() != null) {
      oldValue=mapContainer.getStore().load(mapService.toObject(key));
      if (oldValue != null) {
        record=mapService.createRecord(name,key,oldValue,DEFAULT_TTL,now);
        records.put(key,record);
        updateSizeEstimator(calculateRecordSize(record));
      }
    }
  }
 else {
    accessRecord(record,now);
    oldValue=record.getValue();
  }
  if (oldValue == null) {
    value=mapService.interceptPut(name,null,value);
    value=mapStoreWrite(key,value,record,now);
    record=mapService.createRecord(name,key,value,ttl,now);
    records.put(key,record);
    updateSizeEstimator(calculateRecordSize(record));
    updateTtl(record,ttl);
  }
  saveIndex(record);
  removeFromWriteBehindWaitingDeletions(key);
  return oldValue;
}

Fixed version (ground truth):
public Object putIfAbsent(Data key,Object value,long ttl){
  checkIfLoaded();
  final long now=getNow();
  earlyWriteCleanup(now);
  markRecordStoreExpirable(ttl);
  Record record=records.get(key);
  Object oldValue=null;
  if (record == null) {
    if (mapContainer.getStore() != null) {
      oldValue=loadFromStoreOrStagingArea(key);
      if (oldValue != null) {
        record=mapService.createRecord(name,key,oldValue,DEFAULT_TTL,now);
        records.put(key,record);
        updateSizeEstimator(calculateRecordSize(record));
      }
    }
  }
 else {
    accessRecord(record,now);
    oldValue=record.getValue();
  }
  if (oldValue == null) {
    value=mapService.interceptPut(name,null,value);
    value=mapStoreWrite(key,value,record,now);
    record=mapService.createRecord(name,key,value,ttl,now);
    records.put(key,record);
    updateSizeEstimator(calculateRecordSize(record));
    updateTtl(record,ttl);
  }
  saveIndex(record);
  removeFromWriteBehindWaitingDeletions(key);
  return oldValue;
}
Program: 48139
Project: 48139
Buggy source:
private void processTask(){
  InputStream inputStream=null;
  try {
    inputStream=openTaskInputStream();
    BufferedReader in=new BufferedReader(new InputStreamReader(inputStream));
    StringBuilder sb=new StringBuilder();
    String input;
    while ((input=in.readLine()) != null) {
      sb.append(input);
    }
    JsonObject request=JsonObject.readFrom(sb.toString());
    if (!request.isEmpty()) {
      JsonObject innerRequest=getObject(request,"String_Node_Str");
      final int type=getInt(innerRequest,"String_Node_Str");
      final int taskId=getInt(request,"String_Node_Str");
      Class<? extends ConsoleRequest> requestClass=consoleRequests.get(type);
      if (requestClass == null) {
        throw new RuntimeException("String_Node_Str" + type);
      }
      ConsoleRequest task=requestClass.newInstance();
      task.fromJson(getObject(innerRequest,"String_Node_Str"));
      processTaskAndSendResponse(taskId,task);
    }
  }
 catch (  Exception e) {
    logger.warning(e);
  }
 finally {
    IOUtil.closeResource(inputStream);
  }
}

Fixed version (ground truth):
private void processTask(){
  InputStream inputStream=null;
  InputStreamReader reader=null;
  try {
    inputStream=openTaskInputStream();
    reader=new InputStreamReader(inputStream,"String_Node_Str");
    JsonObject request=JsonValue.readFrom(reader).asObject();
    if (!request.isEmpty()) {
      JsonObject innerRequest=getObject(request,"String_Node_Str");
      final int type=getInt(innerRequest,"String_Node_Str");
      final int taskId=getInt(request,"String_Node_Str");
      Class<? extends ConsoleRequest> requestClass=consoleRequests.get(type);
      if (requestClass == null) {
        throw new RuntimeException("String_Node_Str" + type);
      }
      ConsoleRequest task=requestClass.newInstance();
      task.fromJson(getObject(innerRequest,"String_Node_Str"));
      processTaskAndSendResponse(taskId,task);
    }
  }
 catch (  Exception e) {
    logger.warning(e);
  }
 finally {
    IOUtil.closeResource(reader);
    IOUtil.closeResource(inputStream);
  }
}
Program: 48140
Project: 48140
Buggy source:
private void sendState() throws InterruptedException, MalformedURLException {
  URL url=newCollectorUrl();
  try {
    HttpURLConnection connection=openConnection(url);
    OutputStream outputStream=connection.getOutputStream();
    final OutputStreamWriter writer=new OutputStreamWriter(outputStream);
    try {
      JsonObject root=new JsonObject();
      root.add("String_Node_Str",identifier.toJson());
      TimedMemberState timedMemberState=timedMemberStateFactory.createTimedMemberState();
      root.add("String_Node_Str",timedMemberState.toJson());
      root.writeTo(writer);
      writer.flush();
      outputStream.flush();
      post(connection);
    }
  finally {
      closeResource(writer);
      closeResource(outputStream);
    }
  }
 catch (  ConnectException e) {
    if (logger.isFinestEnabled()) {
      logger.finest(e);
    }
 else {
      logger.info("String_Node_Str" + url);
    }
  }
catch (  Exception e) {
    logger.warning(e);
  }
}

Fixed version (ground truth):
private void sendState() throws InterruptedException, MalformedURLException {
  URL url=newCollectorUrl();
  try {
    HttpURLConnection connection=openConnection(url);
    OutputStream outputStream=connection.getOutputStream();
    final OutputStreamWriter writer=new OutputStreamWriter(outputStream,"String_Node_Str");
    try {
      JsonObject root=new JsonObject();
      root.add("String_Node_Str",identifier.toJson());
      TimedMemberState timedMemberState=timedMemberStateFactory.createTimedMemberState();
      root.add("String_Node_Str",timedMemberState.toJson());
      root.writeTo(writer);
      writer.flush();
      outputStream.flush();
      post(connection);
    }
  finally {
      closeResource(writer);
      closeResource(outputStream);
    }
  }
 catch (  ConnectException e) {
    if (logger.isFinestEnabled()) {
      logger.finest(e);
    }
 else {
      logger.info("String_Node_Str" + url);
    }
  }
catch (  Exception e) {
    logger.warning(e);
  }
}