Program: 49164
Project: 49164
Buggy source:
public LocalMapStats createStats(CollectionProxyId proxyId){
  LocalMultiMapStatsImpl stats=getLocalMultiMapStatsImpl(proxyId);
  long ownedEntryCount=0;
  long backupEntryCount=0;
  long dirtyCount=0;
  long ownedEntryMemoryCost=0;
  long backupEntryMemoryCost=0;
  long hits=0;
  long lockedEntryCount=0;
  ClusterServiceImpl clusterService=(ClusterServiceImpl)nodeEngine.getClusterService();
  Address thisAddress=clusterService.getThisAddress();
  for (int i=0; i < nodeEngine.getPartitionService().getPartitionCount(); i++) {
    PartitionView partition=nodeEngine.getPartitionService().getPartitionView(i);
    CollectionPartitionContainer partitionContainer=getPartitionContainer(i);
    CollectionContainer collectionContainer=partitionContainer.getCollectionContainer(proxyId);
    if (collectionContainer == null) {
      continue;
    }
    if (partition.getOwner().equals(thisAddress)) {
      lockedEntryCount+=collectionContainer.getLockedCount();
      for (      CollectionWrapper wrapper : collectionContainer.collections.values()) {
        hits+=wrapper.getHits();
        ownedEntryCount+=wrapper.getCollection().size();
      }
    }
 else {
      int backupCount=collectionContainer.config.getTotalBackupCount();
      for (int j=1; j <= backupCount; j++) {
        Address replicaAddress=partition.getReplicaAddress(j);
        int memberSize=nodeEngine.getClusterService().getMembers().size();
        int tryCount=3;
        while (memberSize > backupCount && replicaAddress == null && tryCount-- > 0) {
          try {
            Thread.sleep(1000);
          }
 catch (          InterruptedException e) {
            throw ExceptionUtil.rethrow(e);
          }
          replicaAddress=partition.getReplicaAddress(j);
        }
        if (replicaAddress != null && replicaAddress.equals(thisAddress)) {
          for (          CollectionWrapper wrapper : collectionContainer.collections.values()) {
            backupEntryCount+=wrapper.getCollection().size();
          }
        }
      }
    }
  }
  stats.setOwnedEntryCount(ownedEntryCount);
  stats.setBackupEntryCount(backupEntryCount);
  stats.setHits(hits);
  stats.setLockedEntryCount(lockedEntryCount);
  return stats;
}

Fixed version (ground truth):
public LocalMapStats createStats(CollectionProxyId proxyId){
  LocalMultiMapStatsImpl stats=getLocalMultiMapStatsImpl(proxyId);
  long ownedEntryCount=0;
  long backupEntryCount=0;
  long dirtyCount=0;
  long ownedEntryMemoryCost=0;
  long backupEntryMemoryCost=0;
  long hits=0;
  long lockedEntryCount=0;
  ClusterServiceImpl clusterService=(ClusterServiceImpl)nodeEngine.getClusterService();
  Address thisAddress=clusterService.getThisAddress();
  for (int i=0; i < nodeEngine.getPartitionService().getPartitionCount(); i++) {
    PartitionView partition=nodeEngine.getPartitionService().getPartition(i);
    CollectionPartitionContainer partitionContainer=getPartitionContainer(i);
    CollectionContainer collectionContainer=partitionContainer.getCollectionContainer(proxyId);
    if (collectionContainer == null) {
      continue;
    }
    if (partition.getOwner().equals(thisAddress)) {
      lockedEntryCount+=collectionContainer.getLockedCount();
      for (      CollectionWrapper wrapper : collectionContainer.collections.values()) {
        hits+=wrapper.getHits();
        ownedEntryCount+=wrapper.getCollection().size();
      }
    }
 else {
      int backupCount=collectionContainer.config.getTotalBackupCount();
      for (int j=1; j <= backupCount; j++) {
        Address replicaAddress=partition.getReplicaAddress(j);
        int memberSize=nodeEngine.getClusterService().getMembers().size();
        int tryCount=3;
        while (memberSize > backupCount && replicaAddress == null && tryCount-- > 0) {
          try {
            Thread.sleep(1000);
          }
 catch (          InterruptedException e) {
            throw ExceptionUtil.rethrow(e);
          }
          replicaAddress=partition.getReplicaAddress(j);
        }
        if (replicaAddress != null && replicaAddress.equals(thisAddress)) {
          for (          CollectionWrapper wrapper : collectionContainer.collections.values()) {
            backupEntryCount+=wrapper.getCollection().size();
          }
        }
      }
    }
  }
  stats.setOwnedEntryCount(ownedEntryCount);
  stats.setBackupEntryCount(backupEntryCount);
  stats.setHits(hits);
  stats.setLockedEntryCount(lockedEntryCount);
  return stats;
}