nus-yam/ex-repair huggingface dataset:
Program: 49533
Project: 49533
Buggy source:
private InetAddress pickLoopbackAddress() throws UnknownHostException {
  if (System.getProperty("String_Node_Str") == null && System.getProperty("String_Node_Str") == null) {
    logger.log(Level.WARNING,"String_Node_Str");
    System.setProperty("String_Node_Str","String_Node_Str");
  }
  return InetAddress.getByName("String_Node_Str");
}

Fixed version (ground truth):
private AddressDefinition pickLoopbackAddress() throws UnknownHostException {
  if (System.getProperty("String_Node_Str") == null && System.getProperty("String_Node_Str") == null) {
    logger.log(Level.WARNING,"String_Node_Str");
    System.setProperty("String_Node_Str","String_Node_Str");
  }
  return new AddressDefinition("String_Node_Str",InetAddress.getByName("String_Node_Str"));
}
Program: 49534
Project: 49534
Buggy source:
private boolean preferIPv4Stack(){
  boolean preferIPv4Stack=node.groupProperties.PREFER_IPv4_STACK.getBoolean();
  Join join=node.getConfig().getNetworkConfig().getJoin();
  AwsConfig awsConfig=join.getAwsConfig();
  boolean awsEnabled=awsConfig != null && awsConfig.isEnabled();
  return preferIPv4Stack || awsEnabled;
}

Fixed version (ground truth):
private boolean preferIPv4Stack(){
  boolean preferIPv4Stack=Boolean.getBoolean("String_Node_Str") || node.groupProperties.PREFER_IPv4_STACK.getBoolean();
  Join join=node.getConfig().getNetworkConfig().getJoin();
  AwsConfig awsConfig=join.getAwsConfig();
  boolean awsEnabled=awsConfig != null && awsConfig.isEnabled();
  return preferIPv4Stack || awsEnabled;
}
Program: 49535
Project: 49535
Buggy source:
private InetAddress getSystemConfiguredAddress() throws UnknownHostException {
  final String localAddress=System.getProperty("String_Node_Str");
  if (localAddress != null) {
    if ("String_Node_Str".equals(localAddress.trim()) || "String_Node_Str".equals(localAddress.trim())) {
      return pickLoopbackAddress();
    }
 else {
      return InetAddress.getByName(localAddress.trim());
    }
  }
  return null;
}

Fixed version (ground truth):
private AddressDefinition getSystemConfiguredAddress() throws UnknownHostException {
  String localAddress=System.getProperty("String_Node_Str");
  if (localAddress != null) {
    localAddress=localAddress.trim();
    if ("String_Node_Str".equals(localAddress) || "String_Node_Str".equals(localAddress)) {
      return pickLoopbackAddress();
    }
 else {
      logger.log(Level.INFO,"String_Node_Str");
      return new AddressDefinition(localAddress,InetAddress.getByName(localAddress));
    }
  }
  return null;
}
Program: 49536
Project: 49536
Buggy source:
public void doRun(){
  clientEndpoint.connectionRemoved(connection);
  if (node.securityContext != null) {
    try {
      clientEndpoint.getLoginContext().logout();
    }
 catch (    LoginException e) {
      logger.log(Level.WARNING,e.getMessage(),e);
    }
  }
}

Fixed version (ground truth):
public void doRun(){
  logger.log(Level.INFO,"String_Node_Str" + connection + "String_Node_Str");
  clientEndpoint.connectionRemoved(connection);
  if (node.securityContext != null) {
    try {
      clientEndpoint.getLoginContext().logout();
    }
 catch (    LoginException e) {
      logger.log(Level.WARNING,e.getMessage(),e);
    }
  }
}
Program: 49537
Project: 49537
Buggy source:
public void connectionRemoved(final Connection connection){
  final ClientEndpoint clientEndpoint=removeClientEndpoint(connection);
  if (clientEndpoint != null) {
    node.executorManager.executeNow(new FallThroughRunnable(){
      public void doRun(){
        clientEndpoint.connectionRemoved(connection);
        if (node.securityContext != null) {
          try {
            clientEndpoint.getLoginContext().logout();
          }
 catch (          LoginException e) {
            logger.log(Level.WARNING,e.getMessage(),e);
          }
        }
      }
    }
);
  }
}

Fixed version (ground truth):
public void connectionRemoved(final Connection connection){
  final ClientEndpoint clientEndpoint=removeClientEndpoint(connection);
  if (clientEndpoint != null) {
    node.executorManager.executeNow(new FallThroughRunnable(){
      public void doRun(){
        logger.log(Level.INFO,"String_Node_Str" + connection + "String_Node_Str");
        clientEndpoint.connectionRemoved(connection);
        if (node.securityContext != null) {
          try {
            clientEndpoint.getLoginContext().logout();
          }
 catch (          LoginException e) {
            logger.log(Level.WARNING,e.getMessage(),e);
          }
        }
      }
    }
);
  }
}
Program: 49538
Project: 49538
Buggy source:
public void doLocalOp(){
  if (isMigrationAware() && isMigrating(request)) {
    setResult(OBJECT_REDO);
  }
 else {
    request.attachment=TargetAwareOp.this;
    request.local=true;
    ((RequestHandler)getPacketProcessor(request.operation)).handle(request);
  }
}

Fixed version (ground truth):
public void doLocalOp(){
  if (isMigrationAware() && isPartitionMigrating()) {
    setResult(OBJECT_REDO);
  }
 else {
    request.attachment=TargetAwareOp.this;
    request.local=true;
    ((RequestHandler)getPacketProcessor(request.operation)).handle(request);
  }
}
Program: 49539
Project: 49539
Buggy source:
protected boolean isMigrating(Request req){
  return false;
}

Fixed version (ground truth):
protected boolean isMigrating(Request req,int replica){
  return false;
}
Program: 49540
Project: 49540
Buggy source:
protected void backup(ClusterOperation operation){
  final int localBackupCount=backupCount;
  final int localAsyncBackupCount=asyncBackupCount;
  final int totalBackupCount=localBackupCount + localAsyncBackupCount;
  if (localBackupCount <= 0 && localAsyncBackupCount <= 0) {
    return;
  }
  if (totalBackupCount > MAX_BACKUP_COUNT) {
    String msg="String_Node_Str" + MAX_BACKUP_COUNT + "String_Node_Str"+ totalBackupCount;
    logger.log(Level.SEVERE,msg);
    throw new RuntimeException(msg);
  }
  if (request.key == null || request.key.size() == 0) {
    throw new RuntimeException("String_Node_Str" + request.key);
  }
  final MBackup[] backupOps=new MBackup[localBackupCount];
  for (int i=0; i < totalBackupCount; i++) {
    int replicaIndex=i + 1;
    if (i < localBackupCount) {
      MBackup backupOp=new MBackup();
      backupOps[i]=backupOp;
      backupOp.sendBackup(operation,replicaIndex,request);
    }
 else {
      final Request reqBackup=Request.copyFromRequest(request);
      reqBackup.operation=operation;
      enqueueAndReturn(new AsyncBackupProcessable(reqBackup,replicaIndex));
    }
  }
  for (int i=0; i < localBackupCount; i++) {
    MBackup backupOp=backupOps[i];
    backupOp.getResultAsBoolean();
  }
}

Fixed version (ground truth):
protected void backup(ClusterOperation operation){
  final int localBackupCount=backupCount;
  final int localAsyncBackupCount=asyncBackupCount;
  final int totalBackupCount=localBackupCount + localAsyncBackupCount;
  if (localBackupCount <= 0 && localAsyncBackupCount <= 0) {
    return;
  }
  if (totalBackupCount > MAX_BACKUP_COUNT) {
    String msg="String_Node_Str" + MAX_BACKUP_COUNT + "String_Node_Str"+ totalBackupCount;
    logger.log(Level.SEVERE,msg);
    throw new RuntimeException(msg);
  }
  if (request.key == null || request.key.size() == 0) {
    throw new RuntimeException("String_Node_Str" + request.key);
  }
  final MBackup[] backupOps=new MBackup[localBackupCount];
  for (int i=0; i < totalBackupCount; i++) {
    final int replicaIndex=i + 1;
    if (i < localBackupCount) {
      MBackup backupOp=new MBackup();
      backupOps[i]=backupOp;
      backupOp.sendBackup(operation,replicaIndex,request);
    }
 else {
      final Request reqBackup=Request.copyFromRequest(request);
      reqBackup.operation=operation;
      enqueueAndReturn(new AsyncBackupProcessable(reqBackup,replicaIndex));
    }
  }
  for (int i=0; i < localBackupCount; i++) {
    MBackup backupOp=backupOps[i];
    backupOp.getResultAsBoolean();
  }
}
Program: 49542
Project: 49542
Buggy source:
public void sendBackup(ClusterOperation operation,int replicaIndex,Request reqBackup){
  reset();
  this.replicaIndex=replicaIndex;
  SystemLogService css=node.getSystemLogService();
  if (css.shouldLog(CS_TRACE)) {
    css.trace(this,"String_Node_Str",callId);
  }
  request.setFromRequest(reqBackup);
  request.operation=operation;
  request.caller=thisAddress;
  request.setBooleanRequest();
  doOp();
}

Fixed version (ground truth):
public void sendBackup(ClusterOperation operation,int replicaIndex,Request reqBackup){
  reset();
  this.replicaIndex=replicaIndex;
  SystemLogService css=node.getSystemLogService();
  if (css.shouldLog(CS_TRACE)) {
    css.trace(this,"String_Node_Str",callId);
  }
  request.setFromRequest(reqBackup);
  request.operation=operation;
  request.caller=thisAddress;
  request.longValue=replicaIndex;
  request.setBooleanRequest();
  doOp();
}
Program: 49543
Project: 49543
Buggy source:
@Override public boolean isMigrating(Request req){
  final Data key=req.key;
  if (key == null)   return false;
  return partitionManager.isOwnedPartitionMigrating(getPartitionId(req));
}

Fixed version (ground truth):
@Override public boolean isMigrating(Request req,int replica){
  final Data key=req.key;
  return key != null && partitionManager.isPartitionMigrating(getPartitionId(req),replica);
}
Program: 49544
Project: 49544
Buggy source:
public void doJoin(AtomicBoolean joined){
  int tryCount=0;
  long joinStartTime=Clock.currentTimeMillis();
  long maxJoinMillis=node.getGroupProperties().MAX_JOIN_SECONDS.getInteger() * 1000;
  while (node.isActive() && !joined.get() && (Clock.currentTimeMillis() - joinStartTime < maxJoinMillis)) {
    String msg="String_Node_Str" + node.getMasterAddress();
    logger.log(Level.FINEST,msg);
    systemLogService.logJoin(msg);
    Address masterAddressNow=findMasterWithMulticast();
    node.setMasterAddress(masterAddressNow);
    systemLogService.logJoin("String_Node_Str" + masterAddressNow);
    if (node.getMasterAddress() == null || node.address.equals(node.getMasterAddress())) {
      TcpIpConfig tcpIpConfig=config.getNetworkConfig().getJoin().getTcpIpConfig();
      if (tcpIpConfig != null && tcpIpConfig.isEnabled()) {
        doTCP(joined);
      }
 else {
        systemLogService.logJoin("String_Node_Str");
        node.setAsMaster();
      }
      return;
    }
    if (++tryCount > 24) {
      failedJoiningToMaster(true,tryCount);
    }
    if (!node.getMasterAddress().equals(node.address)) {
      connectAndSendJoinRequest(node.getMasterAddress());
    }
 else {
      node.setMasterAddress(null);
      tryCount=0;
    }
    try {
      Thread.sleep(500L);
    }
 catch (    InterruptedException ignored) {
    }
  }
}

Fixed version (ground truth):
public void doJoin(AtomicBoolean joined){
  int tryCount=0;
  long joinStartTime=Clock.currentTimeMillis();
  long maxJoinMillis=node.getGroupProperties().MAX_JOIN_SECONDS.getInteger() * 1000;
  while (node.isActive() && !joined.get() && (Clock.currentTimeMillis() - joinStartTime < maxJoinMillis)) {
    String msg="String_Node_Str" + node.getMasterAddress();
    logger.log(Level.FINEST,msg);
    systemLogService.logJoin(msg);
    Address masterAddressNow=findMasterWithMulticast();
    node.setMasterAddress(masterAddressNow);
    systemLogService.logJoin("String_Node_Str" + masterAddressNow);
    if (node.getMasterAddress() == null || node.address.equals(node.getMasterAddress())) {
      TcpIpConfig tcpIpConfig=config.getNetworkConfig().getJoin().getTcpIpConfig();
      if (tcpIpConfig != null && tcpIpConfig.isEnabled()) {
        doTCP(joined);
      }
 else {
        systemLogService.logJoin("String_Node_Str");
        node.setAsMaster();
      }
      return;
    }
    if (++tryCount > 49) {
      failedJoiningToMaster(true,tryCount);
    }
    if (!node.getMasterAddress().equals(node.address)) {
      connectAndSendJoinRequest(node.getMasterAddress());
    }
 else {
      node.setMasterAddress(null);
      tryCount=0;
    }
    try {
      Thread.sleep(500L);
    }
 catch (    InterruptedException ignored) {
    }
  }
}
Program: 49545
Project: 49545
Buggy source:
/** 
 * @param partitionId
 * @return true if owned replica (0) of partition is migrating, false otherwise
 */
public boolean isOwnedPartitionMigrating(int partitionId){
  final MigratingPartition currentMigratingPartition=migratingPartition;
  return currentMigratingPartition != null && currentMigratingPartition.getPartitionId() == partitionId && currentMigratingPartition.getReplicaIndex() == 0;
}

Fixed version (ground truth):
/** 
 * @param partitionId
 * @return true if owned replica (0) of partition is migrating, false otherwise
 */
public boolean isOwnedPartitionMigrating(int partitionId){
  return isPartitionMigrating(partitionId,0);
}
Program: 49546
Project: 49546
Buggy source:
/** 
 * @param partitionId
 * @return true if any replica of partition is migrating, false otherwise
 */
public boolean isPartitionMigrating(int partitionId){
  final MigratingPartition currentMigratingPartition=migratingPartition;
  return currentMigratingPartition != null && currentMigratingPartition.getPartitionId() == partitionId;
}

Fixed version (ground truth):
/** 
 * @param partitionId
 * @param replicaIndex
 * @return true if replicaIndex of partition is migrating, false otherwise
 */
public boolean isPartitionMigrating(int partitionId,int replicaIndex){
  final MigratingPartition currentMigratingPartition=migratingPartition;
  return currentMigratingPartition != null && currentMigratingPartition.getPartitionId() == partitionId && currentMigratingPartition.getReplicaIndex() == replicaIndex;
}
Program: 49547
Project: 49547
Buggy source:
@Override public String toString(){
  return "String_Node_Str" + "String_Node_Str" + name + '\''+ "String_Node_Str"+ operation+ "String_Node_Str"+ redoCount+ '\''+ "String_Node_Str"+ callId+ '\''+ "String_Node_Str"+ lockThreadId+ '\''+ '}';
}

Fixed version (ground truth):
@Override public String toString(){
  return "String_Node_Str" + "String_Node_Str" + name + '\''+ "String_Node_Str"+ operation+ "String_Node_Str"+ redoCount+ '\''+ "String_Node_Str"+ callId+ '\''+ "String_Node_Str"+ lockThreadId+ '\''+ "String_Node_Str"+ target+ '\''+ "String_Node_Str"+ local+ '\''+ '}';
}
Program: 49549
Project: 49549
Buggy source:
@Test public void issue395BackupProblemWithBCount2() throws InterruptedException {
  final int size=1000;
  Config config=new Config();
  config.getProperties().put(GroupProperties.PROP_PARTITION_MIGRATION_INTERVAL,"String_Node_Str");
  config.getMapConfig("String_Node_Str").setBackupCount(2);
  HazelcastInstance h1=Hazelcast.newHazelcastInstance(config);
  HazelcastInstance h2=Hazelcast.newHazelcastInstance(config);
  IMap map1=h1.getMap("String_Node_Str");
  IMap map2=h2.getMap("String_Node_Str");
  for (int i=0; i < size; i++) {
    map1.put(i,i);
  }
  assertEquals(size,getTotalOwnedEntryCount(map1,map2));
  assertEquals(size,getTotalBackupEntryCount(map1,map2));
  HazelcastInstance h3=Hazelcast.newHazelcastInstance(config);
  IMap map3=h3.getMap("String_Node_Str");
  Thread.sleep(1000 * 2);
  assertEquals(size,getTotalOwnedEntryCount(map1,map2,map3));
  assertEquals(2 * size,getTotalBackupEntryCount(map1,map2,map3));
}

Fixed version (ground truth):
@Test public void issue395BackupProblemWithBCount2() throws InterruptedException {
  final int size=1000;
  Config config=new Config();
  config.setProperty(GroupProperties.PROP_PARTITION_MIGRATION_INTERVAL,"String_Node_Str");
  config.getMapConfig("String_Node_Str").setBackupCount(2);
  HazelcastInstance h1=Hazelcast.newHazelcastInstance(config);
  HazelcastInstance h2=Hazelcast.newHazelcastInstance(config);
  IMap map1=h1.getMap("String_Node_Str");
  IMap map2=h2.getMap("String_Node_Str");
  for (int i=0; i < size; i++) {
    map1.put(i,i);
  }
  assertEquals(size,getTotalOwnedEntryCount(map1,map2));
  assertEquals(size,getTotalBackupEntryCount(map1,map2));
  HazelcastInstance h3=Hazelcast.newHazelcastInstance(config);
  IMap map3=h3.getMap("String_Node_Str");
  Thread.sleep(1000 * 3);
  assertEquals(size,getTotalOwnedEntryCount(map1,map2,map3));
  assertEquals(2 * size,getTotalBackupEntryCount(map1,map2,map3));
}
Program: 49550
Project: 49550
Buggy source:
private void executeStoreUpdate(final Set<Record> dirtyRecords){
  if (dirtyRecords.size() > 0) {
    concurrentMapManager.storeExecutor.execute(new Runnable(){
      public void run(){
        try {
          Set<Object> keysToDelete=new HashSet<Object>();
          Set<Record> toStore=new HashSet<Record>();
          Map<Object,Object> updates=new HashMap<Object,Object>();
          for (          Record dirtyRecord : dirtyRecords) {
            if (!dirtyRecord.isActive()) {
              keysToDelete.add(dirtyRecord.getKey());
            }
 else {
              toStore.add(dirtyRecord);
              updates.put(dirtyRecord.getKey(),dirtyRecord.getValue());
            }
          }
          if (keysToDelete.size() == 1) {
            store.delete(keysToDelete.iterator().next());
          }
 else           if (keysToDelete.size() > 1) {
            store.deleteAll(keysToDelete);
          }
          if (updates.size() == 1) {
            Map.Entry entry=updates.entrySet().iterator().next();
            store.store(entry.getKey(),entry.getValue());
          }
 else           if (updates.size() > 1) {
            store.storeAll(updates);
          }
          for (          Record stored : toStore) {
            stored.setLastStoredTime(Clock.currentTimeMillis());
          }
        }
 catch (        Exception e) {
          for (          Record dirtyRecord : dirtyRecords) {
            dirtyRecord.setDirty(true);
          }
        }
      }
    }
);
  }
}

Fixed version (ground truth):
private void executeStoreUpdate(final Set<Record> dirtyRecords){
  if (dirtyRecords.size() > 0) {
    concurrentMapManager.storeExecutor.execute(new Runnable(){
      public void run(){
        runStoreUpdate(dirtyRecords);
      }
    }
);
  }
}
Program: 49551
Project: 49551
Buggy source:
public void run(){
  try {
    Set<Object> keysToDelete=new HashSet<Object>();
    Set<Record> toStore=new HashSet<Record>();
    Map<Object,Object> updates=new HashMap<Object,Object>();
    for (    Record dirtyRecord : dirtyRecords) {
      if (!dirtyRecord.isActive()) {
        keysToDelete.add(dirtyRecord.getKey());
      }
 else {
        toStore.add(dirtyRecord);
        updates.put(dirtyRecord.getKey(),dirtyRecord.getValue());
      }
    }
    if (keysToDelete.size() == 1) {
      store.delete(keysToDelete.iterator().next());
    }
 else     if (keysToDelete.size() > 1) {
      store.deleteAll(keysToDelete);
    }
    if (updates.size() == 1) {
      Map.Entry entry=updates.entrySet().iterator().next();
      store.store(entry.getKey(),entry.getValue());
    }
 else     if (updates.size() > 1) {
      store.storeAll(updates);
    }
    for (    Record stored : toStore) {
      stored.setLastStoredTime(Clock.currentTimeMillis());
    }
  }
 catch (  Exception e) {
    for (    Record dirtyRecord : dirtyRecords) {
      dirtyRecord.setDirty(true);
    }
  }
}

Fixed version (ground truth):
public void run(){
  runStoreUpdate(dirtyRecords);
}
Program: 49552
Project: 49552
Buggy source:
public void flush(String name){
  CMap cmap=getMap(name);
  if (cmap != null && cmap.store != null && cmap.writeDelayMillis > 0) {
    Map mapDirtyEntries=new HashMap();
    for (    Record record : cmap.mapRecords.values()) {
      if (record.isDirty()) {
        Object key=record.getKey();
        Object value=record.getValue();
        if (key != null && value != null) {
          mapDirtyEntries.put(key,value);
        }
      }
    }
    if (mapDirtyEntries.size() > 0) {
      cmap.store.storeAll(mapDirtyEntries);
    }
  }
}

Fixed version (ground truth):
public void flush(String name){
  CMap cmap=getMap(name);
  if (cmap != null && cmap.store != null && cmap.writeDelayMillis > 0) {
    final Set<Record> dirtyRecords=new HashSet<Record>();
    for (    Record record : cmap.mapRecords.values()) {
      if (record.isDirty()) {
        PartitionInfo partition=partitionManager.getPartition(record.getBlockId());
        Address owner=partition.getOwner();
        if (owner != null && thisAddress.equals(owner)) {
          dirtyRecords.add(record);
          record.setDirty(false);
        }
      }
    }
    cmap.runStoreUpdate(dirtyRecords);
  }
}
Program: 49553
Project: 49553
Buggy source:
@Test public void testOneMemberFlush() throws Exception {
  TestMapStore testMapStore=new TestMapStore(1,1,1);
  testMapStore.setLoadAllKeys(false);
  Config config=newConfig(testMapStore,200);
  HazelcastInstance h1=Hazelcast.newHazelcastInstance(config);
  IMap map=h1.getMap("String_Node_Str");
  assertEquals(0,map.size());
  for (int i=0; i < 100; i++) {
    map.put(i,i);
  }
  assertEquals(100,map.size());
  assertEquals(0,testMapStore.getStore().size());
  getConcurrentMapManager(h1).flush(Prefix.MAP + "String_Node_Str");
  assertEquals(100,testMapStore.getStore().size());
  assertEquals(100,map.size());
}

Fixed version (ground truth):
@Test public void testOneMemberFlush() throws Exception {
  TestMapStore testMapStore=new TestMapStore(1,1,1);
  testMapStore.setLoadAllKeys(false);
  Config config=newConfig(testMapStore,200);
  HazelcastInstance h1=Hazelcast.newHazelcastInstance(config);
  IMap map=h1.getMap("String_Node_Str");
  assertEquals(0,map.size());
  for (int i=0; i < 100; i++) {
    map.put(i,i);
  }
  assertEquals(100,map.size());
  assertEquals(0,testMapStore.getStore().size());
  assertEquals(100,map.getLocalMapStats().getDirtyEntryCount());
  getConcurrentMapManager(h1).flush(Prefix.MAP + "String_Node_Str");
  assertEquals(100,testMapStore.getStore().size());
  assertEquals(0,map.getLocalMapStats().getDirtyEntryCount());
  assertEquals(100,map.size());
  for (int i=0; i < 50; i++) {
    map.remove(i);
  }
  assertEquals(50,map.size());
  assertEquals(100,testMapStore.getStore().size());
  getConcurrentMapManager(h1).flush(Prefix.MAP + "String_Node_Str");
  assertEquals(50,testMapStore.getStore().size());
  assertEquals(50,map.size());
}
Program: 49554
Project: 49554
Buggy source:
private void executeStoreUpdate(final Set<Record> dirtyRecords){
  if (dirtyRecords.size() > 0) {
    concurrentMapManager.storeExecutor.execute(new Runnable(){
      public void run(){
        try {
          Set<Object> keysToDelete=new HashSet<Object>();
          Set<Record> toStore=new HashSet<Record>();
          Map<Object,Object> updates=new HashMap<Object,Object>();
          for (          Record dirtyRecord : dirtyRecords) {
            if (!dirtyRecord.isActive()) {
              keysToDelete.add(dirtyRecord.getKey());
            }
 else {
              toStore.add(dirtyRecord);
              updates.put(dirtyRecord.getKey(),dirtyRecord.getValue());
            }
          }
          if (keysToDelete.size() == 1) {
            store.delete(keysToDelete.iterator().next());
          }
 else           if (keysToDelete.size() > 1) {
            store.deleteAll(keysToDelete);
          }
          if (updates.size() == 1) {
            Map.Entry entry=updates.entrySet().iterator().next();
            store.store(entry.getKey(),entry.getValue());
          }
 else           if (updates.size() > 1) {
            store.storeAll(updates);
          }
          for (          Record stored : toStore) {
            stored.setLastStoredTime(Clock.currentTimeMillis());
          }
        }
 catch (        Exception e) {
          for (          Record dirtyRecord : dirtyRecords) {
            dirtyRecord.setDirty(true);
          }
        }
      }
    }
);
  }
}

Fixed version (ground truth):
private void executeStoreUpdate(final Set<Record> dirtyRecords){
  if (dirtyRecords.size() > 0) {
    concurrentMapManager.storeExecutor.execute(new Runnable(){
      public void run(){
        runStoreUpdate(dirtyRecords);
      }
    }
);
  }
}
Program: 49555
Project: 49555
Buggy source:
public void run(){
  try {
    Set<Object> keysToDelete=new HashSet<Object>();
    Set<Record> toStore=new HashSet<Record>();
    Map<Object,Object> updates=new HashMap<Object,Object>();
    for (    Record dirtyRecord : dirtyRecords) {
      if (!dirtyRecord.isActive()) {
        keysToDelete.add(dirtyRecord.getKey());
      }
 else {
        toStore.add(dirtyRecord);
        updates.put(dirtyRecord.getKey(),dirtyRecord.getValue());
      }
    }
    if (keysToDelete.size() == 1) {
      store.delete(keysToDelete.iterator().next());
    }
 else     if (keysToDelete.size() > 1) {
      store.deleteAll(keysToDelete);
    }
    if (updates.size() == 1) {
      Map.Entry entry=updates.entrySet().iterator().next();
      store.store(entry.getKey(),entry.getValue());
    }
 else     if (updates.size() > 1) {
      store.storeAll(updates);
    }
    for (    Record stored : toStore) {
      stored.setLastStoredTime(Clock.currentTimeMillis());
    }
  }
 catch (  Exception e) {
    for (    Record dirtyRecord : dirtyRecords) {
      dirtyRecord.setDirty(true);
    }
  }
}

Fixed version (ground truth):
public void run(){
  runStoreUpdate(dirtyRecords);
}
Program: 49556
Project: 49556
Buggy source:
public void flush(String name){
  CMap cmap=getMap(name);
  if (cmap != null && cmap.store != null && cmap.writeDelayMillis > 0) {
    Map mapDirtyEntries=new HashMap();
    Set<Record> toStore=new HashSet<Record>();
    for (    Record record : cmap.mapRecords.values()) {
      if (record.isDirty()) {
        Object key=record.getKey();
        Object value=record.getValue();
        if (key != null && value != null) {
          mapDirtyEntries.put(key,value);
          toStore.add(record);
        }
      }
    }
    if (mapDirtyEntries.size() > 0) {
      cmap.store.storeAll(mapDirtyEntries);
      for (      Record stored : toStore) {
        stored.setDirty(false);
        stored.setLastStoredTime(Clock.currentTimeMillis());
      }
    }
  }
}

Fixed version (ground truth):
public void flush(String name){
  CMap cmap=getMap(name);
  if (cmap != null && cmap.store != null && cmap.writeDelayMillis > 0) {
    final Set<Record> dirtyRecords=new HashSet<Record>();
    for (    Record record : cmap.mapRecords.values()) {
      if (record.isDirty()) {
        PartitionInfo partition=partitionManager.getPartition(record.getBlockId());
        Address owner=partition.getOwner();
        if (owner != null && thisAddress.equals(owner)) {
          dirtyRecords.add(record);
          record.setDirty(false);
        }
      }
    }
    cmap.runStoreUpdate(dirtyRecords);
  }
}
Program: 49557
Project: 49557
Buggy source:
@Test public void testOneMemberFlush() throws Exception {
  TestMapStore testMapStore=new TestMapStore(1,1,1);
  testMapStore.setLoadAllKeys(false);
  Config config=newConfig(testMapStore,200);
  HazelcastInstance h1=Hazelcast.newHazelcastInstance(config);
  IMap map=h1.getMap("String_Node_Str");
  assertEquals(0,map.size());
  for (int i=0; i < 100; i++) {
    map.put(i,i);
  }
  assertEquals(100,map.size());
  assertEquals(0,testMapStore.getStore().size());
  assertEquals(100,map.getLocalMapStats().getDirtyEntryCount());
  getConcurrentMapManager(h1).flush(Prefix.MAP + "String_Node_Str");
  assertEquals(100,testMapStore.getStore().size());
  assertEquals(0,map.getLocalMapStats().getDirtyEntryCount());
  assertEquals(100,map.size());
}

Fixed version (ground truth):
@Test public void testOneMemberFlush() throws Exception {
  TestMapStore testMapStore=new TestMapStore(1,1,1);
  testMapStore.setLoadAllKeys(false);
  Config config=newConfig(testMapStore,200);
  HazelcastInstance h1=Hazelcast.newHazelcastInstance(config);
  IMap map=h1.getMap("String_Node_Str");
  assertEquals(0,map.size());
  for (int i=0; i < 100; i++) {
    map.put(i,i);
  }
  assertEquals(100,map.size());
  assertEquals(0,testMapStore.getStore().size());
  assertEquals(100,map.getLocalMapStats().getDirtyEntryCount());
  getConcurrentMapManager(h1).flush(Prefix.MAP + "String_Node_Str");
  assertEquals(100,testMapStore.getStore().size());
  assertEquals(0,map.getLocalMapStats().getDirtyEntryCount());
  assertEquals(100,map.size());
  for (int i=0; i < 50; i++) {
    map.remove(i);
  }
  assertEquals(50,map.size());
  assertEquals(100,testMapStore.getStore().size());
  getConcurrentMapManager(h1).flush(Prefix.MAP + "String_Node_Str");
  assertEquals(50,testMapStore.getStore().size());
  assertEquals(50,map.size());
}
Program: 49558
Project: 49558
Buggy source:
public Member getTarget(HazelcastInstance hazelcastInstance){
  Object[] memberObjects=hazelcastInstance.getCluster().getMembers().toArray();
  return (MemberImpl)memberObjects[((int)(count++ % memberObjects.length))];
}

Fixed version (ground truth):
public Member getTarget(HazelcastInstance hazelcastInstance){
  Object[] memberObjects=hazelcastInstance.getCluster().getMembers().toArray();
  return (MemberImpl)memberObjects[((int)(Math.abs(count.incrementAndGet()) % memberObjects.length))];
}
Program: 49559
Project: 49559
Buggy source:
public Member getTarget(HazelcastInstance hazelcastInstance){
  Object[] memberObjects=hazelcastInstance.getCluster().getMembers().toArray();
  return (MemberImpl)memberObjects[((int)(count++ % memberObjects.length))];
}

Fixed version (ground truth):
public Member getTarget(HazelcastInstance hazelcastInstance){
  Object[] memberObjects=hazelcastInstance.getCluster().getMembers().toArray();
  return (MemberImpl)memberObjects[((int)(Math.abs(count.incrementAndGet()) % memberObjects.length))];
}
Program: 49560
Project: 49560
Buggy source:
public static void kill(HazelcastInstanceProxy hazelcastInstanceProxy){
  FactoryImpl factory=hazelcastInstanceProxy.getFactory();
  factory.managementService.unregister();
  factories.remove(factory.getName());
  if (factories.size() == 0) {
    shutdownManagementService();
  }
  factory.proxies.clear();
  for (  ExecutorService esp : factory.executorServiceProxies.values()) {
    esp.shutdown();
  }
  factory.node.shutdown(true,true);
}

Fixed version (ground truth):
public static void kill(FactoryImpl factory){
  factory.managementService.unregister();
  factories.remove(factory.getName());
  if (factories.size() == 0) {
    shutdownManagementService();
  }
  factory.proxies.clear();
  for (  ExecutorService esp : factory.executorServiceProxies.values()) {
    esp.shutdown();
  }
  factory.node.shutdown(true,true);
}
Program: 49561
Project: 49561
Buggy source:
public void kill(){
synchronized (lifecycleLock) {
    fireLifecycleEvent(SHUTTING_DOWN);
    FactoryImpl.kill(factory.getHazelcastInstanceProxy());
    fireLifecycleEvent(SHUTDOWN);
  }
}

Fixed version (ground truth):
public void kill(){
synchronized (lifecycleLock) {
    fireLifecycleEvent(SHUTTING_DOWN);
    FactoryImpl.kill(factory);
    fireLifecycleEvent(SHUTDOWN);
  }
}
Program: 49562
Project: 49562
Buggy source:
public void shutdown(){
synchronized (lifecycleLock) {
    fireLifecycleEvent(SHUTTING_DOWN);
    FactoryImpl.shutdown(factory.getHazelcastInstanceProxy());
    fireLifecycleEvent(SHUTDOWN);
  }
}

Fixed version (ground truth):
public void shutdown(){
synchronized (lifecycleLock) {
    fireLifecycleEvent(SHUTTING_DOWN);
    FactoryImpl.shutdown(factory);
    fireLifecycleEvent(SHUTDOWN);
  }
}
Program: 49563
Project: 49563
Buggy source:
/** 
 * Unregister a cluster instance.
 */
public void unregister(){
synchronized (LOCK) {
    if (!started) {
      return;
    }
    MBeanServer mbs=mBeanServer();
    Set<ObjectName> entries;
    try {
      entries=mbs.queryNames(ObjectNameSpec.getClusterNameFilter(this.name),null);
      for (      ObjectName name : entries) {
        if (mbs.isRegistered(name)) {
          mbs.unregisterMBean(name);
        }
      }
    }
 catch (    Exception e) {
      logger.log(Level.FINEST,"String_Node_Str",e);
    }
    counter.decrementAndGet();
  }
}

Fixed version (ground truth):
/** 
 * Unregister a cluster instance.
 */
public void unregister(){
  if (!enabled) {
    return;
  }
  if (started.compareAndSet(true,false)) {
    MBeanServer mbs=mBeanServer();
    try {
      Set<ObjectName> entries=mbs.queryNames(new ObjectName(ObjectNameSpec.NAME_DOMAIN + "String_Node_Str" + name+ "String_Node_Str"),null);
      for (      ObjectName name : entries) {
        if (mbs.isRegistered(name)) {
          mbs.unregisterMBean(name);
        }
      }
    }
 catch (    Exception e) {
      logger.log(Level.FINEST,"String_Node_Str",e);
    }
  }
}
Program: 49564
Project: 49564
Buggy source:
/** 
 * Create a new collector or return null if statistics are not enabled
 * @return statisticsCollector
 */
@SuppressWarnings("String_Node_Str") public static StatisticsCollector newStatisticsCollector(){
synchronized (LOCK) {
    if (statCollectors != null) {
      long interval=1L;
      ScheduledCollector collector=new ScheduledCollector(interval);
      ScheduledFuture future=statCollectors.scheduleWithFixedDelay(collector,interval,interval,TimeUnit.SECONDS);
      collector.setScheduledFuture(future);
      return collector;
    }
 else {
      return null;
    }
  }
}

Fixed version (ground truth):
/** 
 * Create a new collector or return null if statistics are not enabled
 * @return statisticsCollector
 */
@SuppressWarnings("String_Node_Str") public static StatisticsCollector newStatisticsCollector(){
  final ScheduledExecutorService scheduledExecutor=statCollectorExecutor;
  if (scheduledExecutor != null) {
    long interval=1L;
    ScheduledCollector collector=new ScheduledCollector(interval);
    ScheduledFuture future=scheduledExecutor.scheduleWithFixedDelay(collector,interval,interval,TimeUnit.SECONDS);
    collector.setScheduledFuture(future);
    return collector;
  }
 else {
    return null;
  }
}
Program: 49565
Project: 49565
Buggy source:
public ManagementService(FactoryImpl instance){
  this.instance=instance;
  this.logger=instance.node.getLogger(ManagementService.class.getName());
  this.showDetails=instance.node.groupProperties.ENABLE_JMX_DETAILED.getBoolean();
}

Fixed version (ground truth):
public ManagementService(FactoryImpl instance){
  this.instance=instance;
  this.name=instance.getName();
  this.logger=instance.node.getLogger(ManagementService.class.getName());
  this.enabled=instance.node.groupProperties.ENABLE_JMX.getBoolean();
  this.showDetails=instance.node.groupProperties.ENABLE_JMX_DETAILED.getBoolean();
}
Program: 49566
Project: 49566
Buggy source:
/** 
 * Stop the management service
 */
public static void shutdown(){
synchronized (LOCK) {
    if (counter.get() > 0) {
      return;
    }
    MBeanServer mbs=mBeanServer();
    Set<ObjectName> entries;
    try {
      entries=mbs.queryNames(new ObjectName(ObjectNameSpec.NAME_DOMAIN + "String_Node_Str"),null);
      for (      ObjectName name : entries) {
        if (mbs.isRegistered(name)) {
          mbs.unregisterMBean(name);
        }
      }
    }
 catch (    Exception e) {
      Logger.getLogger("String_Node_Str").log(Level.FINEST,"String_Node_Str",e);
    }
    if (statCollectors != null) {
      statCollectors.shutdownNow();
      statCollectors=null;
    }
  }
}

Fixed version (ground truth):
/** 
 * Stop the management service
 */
public synchronized static void shutdown(){
  MBeanServer mbs=mBeanServer();
  try {
    Set<ObjectName> entries=mbs.queryNames(new ObjectName(ObjectNameSpec.NAME_DOMAIN + "String_Node_Str"),null);
    for (    ObjectName name : entries) {
      if (mbs.isRegistered(name)) {
        mbs.unregisterMBean(name);
      }
    }
  }
 catch (  Exception e) {
    Logger.getLogger("String_Node_Str").log(Level.FINEST,"String_Node_Str",e);
  }
  stopStatsCollector();
}
Program: 49567
Project: 49567
Buggy source:
/** 
 * Register all the MBeans.
 */
public void register(){
synchronized (LOCK) {
    if (!started) {
      start();
    }
    if (!started) {
      return;
    }
    MBeanServer mbs=mBeanServer();
    try {
      nameLookup();
      ClusterMBean clusterMBean=new ClusterMBean(this,this.name);
      mbs.registerMBean(clusterMBean,clusterMBean.getObjectName());
      DataMBean dataMBean=new DataMBean(this);
      dataMBean.setParentName(clusterMBean.getRootName());
      mbs.registerMBean(dataMBean,dataMBean.getObjectName());
    }
 catch (    Exception e) {
      logger.log(Level.WARNING,"String_Node_Str",e);
      return;
    }
    counter.incrementAndGet();
  }
}

Fixed version (ground truth):
/** 
 * Register all the MBeans.
 */
public void register(){
  if (!enabled) {
    return;
  }
  if (started.compareAndSet(false,true)) {
    logger.log(Level.INFO,"String_Node_Str");
    if (showDetails()) {
      startStatsCollector();
    }
    MBeanServer mbs=mBeanServer();
    try {
      ClusterMBean clusterMBean=new ClusterMBean(this,this.name);
      mbs.registerMBean(clusterMBean,clusterMBean.getObjectName());
      DataMBean dataMBean=new DataMBean(this);
      dataMBean.setParentName(clusterMBean.getRootName());
      mbs.registerMBean(dataMBean,dataMBean.getObjectName());
    }
 catch (    Exception e) {
      logger.log(Level.WARNING,"String_Node_Str",e);
    }
  }
}
Program: 49568
Project: 49568
Buggy source:
/** 
 * Builde the name, overwriting the defaults
 */
public ObjectName buildObjectName(String type,String name) throws Exception {
  StringBuffer sb=new StringBuffer(NAME_DOMAIN);
  if (type != null) {
    sb.append("String_Node_Str").append(clean(type));
  }
  if (name != null) {
    if (type != null || cluster != null) {
      sb.append(',');
    }
    sb.append("String_Node_Str").append(clean(name));
  }
  return new ObjectName(sb.toString());
}

Fixed version (ground truth):
/** 
 * Builde the name, overwriting the defaults
 */
public ObjectName buildObjectName(String type,String name) throws Exception {
  StringBuilder sb=new StringBuilder(NAME_DOMAIN);
  if (type != null) {
    sb.append("String_Node_Str").append(clean(type));
  }
  if (name != null) {
    if (type != null || cluster != null) {
      sb.append(',');
    }
    sb.append("String_Node_Str").append(clean(name));
  }
  return new ObjectName(sb.toString());
}
Program: 49569
Project: 49569
Buggy source:
public static void kill(HazelcastInstanceProxy hazelcastInstanceProxy){
  FactoryImpl factory=hazelcastInstanceProxy.getFactory();
  factory.managementService.unregister();
  factories.remove(factory.getName());
  if (factories.size() == 0) {
    shutdownManagementService();
  }
  factory.proxies.clear();
  for (  ExecutorService esp : factory.executorServiceProxies.values()) {
    esp.shutdown();
  }
  factory.node.shutdown(true,true);
}

Fixed version (ground truth):
public static void kill(FactoryImpl factory){
  factory.managementService.unregister();
  factories.remove(factory.getName());
  if (factories.size() == 0) {
    shutdownManagementService();
  }
  factory.proxies.clear();
  for (  ExecutorService esp : factory.executorServiceProxies.values()) {
    esp.shutdown();
  }
  factory.node.shutdown(true,true);
}
Program: 49570
Project: 49570
Buggy source:
public void kill(){
synchronized (lifecycleLock) {
    fireLifecycleEvent(SHUTTING_DOWN);
    FactoryImpl.kill(factory.getHazelcastInstanceProxy());
    fireLifecycleEvent(SHUTDOWN);
  }
}

Fixed version (ground truth):
public void kill(){
synchronized (lifecycleLock) {
    fireLifecycleEvent(SHUTTING_DOWN);
    FactoryImpl.kill(factory);
    fireLifecycleEvent(SHUTDOWN);
  }
}
Program: 49571
Project: 49571
Buggy source:
public void shutdown(){
synchronized (lifecycleLock) {
    fireLifecycleEvent(SHUTTING_DOWN);
    FactoryImpl.shutdown(factory.getHazelcastInstanceProxy());
    fireLifecycleEvent(SHUTDOWN);
  }
}

Fixed version (ground truth):
public void shutdown(){
synchronized (lifecycleLock) {
    fireLifecycleEvent(SHUTTING_DOWN);
    FactoryImpl.shutdown(factory);
    fireLifecycleEvent(SHUTDOWN);
  }
}
Program: 49572
Project: 49572
Buggy source:
/** 
 * Unregister a cluster instance.
 */
public void unregister(){
synchronized (LOCK) {
    if (!started) {
      return;
    }
    MBeanServer mbs=mBeanServer();
    Set<ObjectName> entries;
    try {
      entries=mbs.queryNames(ObjectNameSpec.getClusterNameFilter(this.name),null);
      for (      ObjectName name : entries) {
        if (mbs.isRegistered(name)) {
          mbs.unregisterMBean(name);
        }
      }
    }
 catch (    Exception e) {
      logger.log(Level.FINEST,"String_Node_Str",e);
    }
    counter.decrementAndGet();
  }
}

Fixed version (ground truth):
/** 
 * Unregister a cluster instance.
 */
public void unregister(){
  if (!enabled) {
    return;
  }
  if (started.compareAndSet(true,false)) {
    MBeanServer mbs=mBeanServer();
    try {
      Set<ObjectName> entries=mbs.queryNames(new ObjectName(ObjectNameSpec.NAME_DOMAIN + "String_Node_Str" + name+ "String_Node_Str"),null);
      for (      ObjectName name : entries) {
        if (mbs.isRegistered(name)) {
          mbs.unregisterMBean(name);
        }
      }
    }
 catch (    Exception e) {
      logger.log(Level.FINEST,"String_Node_Str",e);
    }
  }
}
Program: 49573
Project: 49573
Buggy source:
/** 
 * Create a new collector or return null if statistics are not enabled
 * @return statisticsCollector
 */
@SuppressWarnings("String_Node_Str") public static StatisticsCollector newStatisticsCollector(){
synchronized (LOCK) {
    if (statCollectors != null) {
      long interval=1L;
      ScheduledCollector collector=new ScheduledCollector(interval);
      ScheduledFuture future=statCollectors.scheduleWithFixedDelay(collector,interval,interval,TimeUnit.SECONDS);
      collector.setScheduledFuture(future);
      return collector;
    }
 else {
      return null;
    }
  }
}

Fixed version (ground truth):
/** 
 * Create a new collector or return null if statistics are not enabled
 * @return statisticsCollector
 */
@SuppressWarnings("String_Node_Str") public static StatisticsCollector newStatisticsCollector(){
  final ScheduledExecutorService scheduledExecutor=statCollectorExecutor;
  if (scheduledExecutor != null) {
    long interval=1L;
    ScheduledCollector collector=new ScheduledCollector(interval);
    ScheduledFuture future=scheduledExecutor.scheduleWithFixedDelay(collector,interval,interval,TimeUnit.SECONDS);
    collector.setScheduledFuture(future);
    return collector;
  }
 else {
    return null;
  }
}
Program: 49574
Project: 49574
Buggy source:
public ManagementService(FactoryImpl instance){
  this.instance=instance;
  this.logger=instance.node.getLogger(ManagementService.class.getName());
  this.showDetails=instance.node.groupProperties.ENABLE_JMX_DETAILED.getBoolean();
}

Fixed version (ground truth):
public ManagementService(FactoryImpl instance){
  this.instance=instance;
  this.name=instance.getName();
  this.logger=instance.node.getLogger(ManagementService.class.getName());
  this.enabled=instance.node.groupProperties.ENABLE_JMX.getBoolean();
  this.showDetails=instance.node.groupProperties.ENABLE_JMX_DETAILED.getBoolean();
}
Program: 49575
Project: 49575
Buggy source:
/** 
 * Stop the management service
 */
public static void shutdown(){
synchronized (LOCK) {
    if (counter.get() > 0) {
      return;
    }
    MBeanServer mbs=mBeanServer();
    Set<ObjectName> entries;
    try {
      entries=mbs.queryNames(new ObjectName(ObjectNameSpec.NAME_DOMAIN + "String_Node_Str"),null);
      for (      ObjectName name : entries) {
        if (mbs.isRegistered(name)) {
          mbs.unregisterMBean(name);
        }
      }
    }
 catch (    Exception e) {
      Logger.getLogger("String_Node_Str").log(Level.FINEST,"String_Node_Str",e);
    }
    if (statCollectors != null) {
      statCollectors.shutdownNow();
      statCollectors=null;
    }
  }
}

Fixed version (ground truth):
/** 
 * Stop the management service
 */
public synchronized static void shutdown(){
  MBeanServer mbs=mBeanServer();
  try {
    Set<ObjectName> entries=mbs.queryNames(new ObjectName(ObjectNameSpec.NAME_DOMAIN + "String_Node_Str"),null);
    for (    ObjectName name : entries) {
      if (mbs.isRegistered(name)) {
        mbs.unregisterMBean(name);
      }
    }
  }
 catch (  Exception e) {
    Logger.getLogger("String_Node_Str").log(Level.FINEST,"String_Node_Str",e);
  }
  stopStatsCollector();
}
Program: 49576
Project: 49576
Buggy source:
/** 
 * Register all the MBeans.
 */
public void register(){
synchronized (LOCK) {
    if (!started) {
      start();
    }
    if (!started) {
      return;
    }
    MBeanServer mbs=mBeanServer();
    try {
      nameLookup();
      ClusterMBean clusterMBean=new ClusterMBean(this,this.name);
      mbs.registerMBean(clusterMBean,clusterMBean.getObjectName());
      DataMBean dataMBean=new DataMBean(this);
      dataMBean.setParentName(clusterMBean.getRootName());
      mbs.registerMBean(dataMBean,dataMBean.getObjectName());
    }
 catch (    Exception e) {
      logger.log(Level.WARNING,"String_Node_Str",e);
      return;
    }
    counter.incrementAndGet();
  }
}

Fixed version (ground truth):
/** 
 * Register all the MBeans.
 */
public void register(){
  if (!enabled) {
    return;
  }
  if (started.compareAndSet(false,true)) {
    logger.log(Level.INFO,"String_Node_Str");
    if (showDetails()) {
      startStatsCollector();
    }
    MBeanServer mbs=mBeanServer();
    try {
      ClusterMBean clusterMBean=new ClusterMBean(this,this.name);
      mbs.registerMBean(clusterMBean,clusterMBean.getObjectName());
      DataMBean dataMBean=new DataMBean(this);
      dataMBean.setParentName(clusterMBean.getRootName());
      mbs.registerMBean(dataMBean,dataMBean.getObjectName());
    }
 catch (    Exception e) {
      logger.log(Level.WARNING,"String_Node_Str",e);
    }
  }
}
Program: 49577
Project: 49577
Buggy source:
/** 
 * Builde the name, overwriting the defaults
 */
public ObjectName buildObjectName(String type,String name) throws Exception {
  StringBuffer sb=new StringBuffer(NAME_DOMAIN);
  if (type != null) {
    sb.append("String_Node_Str").append(clean(type));
  }
  if (name != null) {
    if (type != null || cluster != null) {
      sb.append(',');
    }
    sb.append("String_Node_Str").append(clean(name));
  }
  return new ObjectName(sb.toString());
}

Fixed version (ground truth):
/** 
 * Builde the name, overwriting the defaults
 */
public ObjectName buildObjectName(String type,String name) throws Exception {
  StringBuilder sb=new StringBuilder(NAME_DOMAIN);
  if (type != null) {
    sb.append("String_Node_Str").append(clean(type));
  }
  if (name != null) {
    if (type != null || cluster != null) {
      sb.append(',');
    }
    sb.append("String_Node_Str").append(clean(name));
  }
  return new ObjectName(sb.toString());
}
Program: 49578
Project: 49578
Buggy source:
private InetAddress pickInetAddress(final Collection<String> interfaces) throws SocketException {
  final Enumeration<NetworkInterface> networkInterfaces=NetworkInterface.getNetworkInterfaces();
  final boolean preferIPv4Stack=preferIPv4Stack();
  while (networkInterfaces.hasMoreElements()) {
    final NetworkInterface ni=networkInterfaces.nextElement();
    final Enumeration<InetAddress> e=ni.getInetAddresses();
    while (e.hasMoreElements()) {
      final InetAddress inetAddress=e.nextElement();
      if (preferIPv4Stack && inetAddress instanceof Inet6Address) {
        continue;
      }
      if (interfaces != null && !interfaces.isEmpty()) {
        final String address=inetAddress.getHostAddress();
        if (matchAddress(address,interfaces)) {
          return inetAddress;
        }
      }
 else       if (!inetAddress.isLoopbackAddress()) {
        return inetAddress;
      }
    }
  }
  return null;
}

Fixed version (ground truth):
private InetAddress pickInetAddress(final Collection<String> interfaces) throws SocketException {
  final Enumeration<NetworkInterface> networkInterfaces=NetworkInterface.getNetworkInterfaces();
  final boolean preferIPv4Stack=preferIPv4Stack();
  while (networkInterfaces.hasMoreElements()) {
    final NetworkInterface ni=networkInterfaces.nextElement();
    final Enumeration<InetAddress> e=ni.getInetAddresses();
    while (e.hasMoreElements()) {
      final InetAddress inetAddress=e.nextElement();
      if (preferIPv4Stack && inetAddress instanceof Inet6Address) {
        continue;
      }
      if (interfaces != null && !interfaces.isEmpty()) {
        final String address=inetAddress.getHostAddress();
        if (AddressUtil.matchAnyInterface(address,interfaces)) {
          return inetAddress;
        }
      }
 else       if (!inetAddress.isLoopbackAddress()) {
        return inetAddress;
      }
    }
  }
  return null;
}
Program: 49580
Project: 49580
Buggy source:
public AddressPicker(Node node,ServerSocketChannel serverSocketChannel){
  this.node=node;
  this.logger=Logger.getLogger(AddressPicker.class.getName());
  this.serverSocketChannel=serverSocketChannel;
}

Fixed version (ground truth):
public AddressPicker(Node node){
  this.node=node;
  this.logger=Logger.getLogger(AddressPicker.class.getName());
}