Program: 50354
Project: 50354
Buggy source:
void startCleanup(){
  final long now=System.currentTimeMillis();
  if (locallyOwnedMap != null) {
    locallyOwnedMap.evict(now);
  }
  if (mapNearCache != null) {
    mapNearCache.evict(now,false);
  }
  final Map<Data,Data> entriesToStore=new HashMap<Data,Data>();
  final Collection<Data> keysToDelete=new HashSet<Data>();
  final Set<Record> recordsUnknown=new HashSet<Record>();
  final Set<Record> recordsToPurge=new HashSet<Record>();
  final Set<Record> recordsToEvict=new HashSet<Record>();
  final Set<Record> sortedRecords=new TreeSet<Record>(evictionComparator);
  final Collection<Record> records=mapRecords.values();
  final int clusterMemberSize=node.getClusterImpl().getMembers().size();
  final int memberCount=(clusterMemberSize == 0) ? 1 : clusterMemberSize;
  final int maxSizePerJVM=maxSize / memberCount;
  final boolean evictionAware=evictionComparator != null && maxSizePerJVM > 0;
  final PartitionServiceImpl partitionService=concurrentMapManager.partitionManager.partitionServiceImpl;
  int recordsStillOwned=0;
  int backupPurgeCount=0;
  for (  Record record : records) {
    PartitionServiceImpl.PartitionProxy partition=partitionService.getPartition(record.getBlockId());
    Member owner=partition.getOwner();
    if (owner != null && !partition.isMigrating()) {
      boolean owned=owner.localMember();
      if (owned) {
        if (store != null && record.isDirty()) {
          if (now > record.getWriteTime()) {
            if (record.getValue() != null) {
              entriesToStore.put(record.getKey(),record.getValue());
            }
 else {
              keysToDelete.add(record.getKey());
            }
            record.setDirty(false);
          }
        }
 else         if (shouldPurgeRecord(record,now)) {
          recordsToPurge.add(record);
        }
 else         if (record.isActive() && !record.isValid(now)) {
          recordsToEvict.add(record);
        }
 else         if (evictionAware && record.isActive() && record.isEvictable()) {
          sortedRecords.add(record);
          recordsStillOwned++;
        }
 else {
          recordsStillOwned++;
        }
      }
 else {
        Member ownerEventual=partition.getEventualOwner();
        boolean backup=false;
        if (ownerEventual != null && owner != null && !owner.localMember()) {
          int distance=node.getClusterImpl().getDistanceFrom(ownerEventual);
          backup=(distance != -1 && distance <= getBackupCount());
        }
        if (backup) {
          if (shouldPurgeRecord(record,now)) {
            recordsToPurge.add(record);
            backupPurgeCount++;
          }
        }
 else {
          recordsUnknown.add(record);
        }
      }
    }
  }
  if (evictionAware && maxSizePerJVM < recordsStillOwned) {
    int numberOfRecordsToEvict=(int)(recordsStillOwned * evictionRate);
    int evictedCount=0;
    for (    Record record : sortedRecords) {
      if (record.isActive() && record.isEvictable()) {
        recordsToEvict.add(record);
        if (++evictedCount >= numberOfRecordsToEvict) {
          break;
        }
      }
    }
  }
  Level levelLog=(concurrentMapManager.LOG_STATE) ? Level.INFO : Level.FINEST;
  logger.log(levelLog,name + "String_Node_Str" + "String_Node_Str"+ entriesToStore.size()+ "String_Node_Str"+ keysToDelete.size()+ "String_Node_Str"+ recordsToPurge.size()+ "String_Node_Str"+ recordsToEvict.size()+ "String_Node_Str"+ recordsUnknown.size()+ "String_Node_Str"+ recordsStillOwned+ "String_Node_Str"+ backupPurgeCount);
  executeStoreUpdate(entriesToStore,keysToDelete);
  executeEviction(recordsToEvict);
  executePurge(recordsToPurge);
  executePurgeUnknowns(recordsUnknown);
}

Fixed version (ground truth):
void startCleanup(){
  final long now=System.currentTimeMillis();
  if (locallyOwnedMap != null) {
    locallyOwnedMap.evict(now);
  }
  if (mapNearCache != null) {
    mapNearCache.evict(now,false);
  }
  final Set<Record> recordsDirty=new HashSet<Record>();
  final Set<Record> recordsUnknown=new HashSet<Record>();
  final Set<Record> recordsToPurge=new HashSet<Record>();
  final Set<Record> recordsToEvict=new HashSet<Record>();
  final Set<Record> sortedRecords=new TreeSet<Record>(evictionComparator);
  final Collection<Record> records=mapRecords.values();
  final int clusterMemberSize=node.getClusterImpl().getMembers().size();
  final int memberCount=(clusterMemberSize == 0) ? 1 : clusterMemberSize;
  final int maxSizePerJVM=maxSize / memberCount;
  final boolean evictionAware=evictionComparator != null && maxSizePerJVM > 0;
  final PartitionServiceImpl partitionService=concurrentMapManager.partitionManager.partitionServiceImpl;
  int recordsStillOwned=0;
  int backupPurgeCount=0;
  for (  Record record : records) {
    PartitionServiceImpl.PartitionProxy partition=partitionService.getPartition(record.getBlockId());
    Member owner=partition.getOwner();
    if (owner != null && !partition.isMigrating()) {
      boolean owned=owner.localMember();
      if (owned) {
        if (store != null && record.isDirty()) {
          if (now > record.getWriteTime()) {
            recordsDirty.add(record);
          }
        }
 else         if (shouldPurgeRecord(record,now)) {
          recordsToPurge.add(record);
        }
 else         if (record.isActive() && !record.isValid(now)) {
          recordsToEvict.add(record);
        }
 else         if (evictionAware && record.isActive() && record.isEvictable()) {
          sortedRecords.add(record);
          recordsStillOwned++;
        }
 else {
          recordsStillOwned++;
        }
      }
 else {
        Member ownerEventual=partition.getEventualOwner();
        boolean backup=false;
        if (ownerEventual != null && owner != null && !owner.localMember()) {
          int distance=node.getClusterImpl().getDistanceFrom(ownerEventual);
          backup=(distance != -1 && distance <= getBackupCount());
        }
        if (backup) {
          if (shouldPurgeRecord(record,now)) {
            recordsToPurge.add(record);
            backupPurgeCount++;
          }
        }
 else {
          recordsUnknown.add(record);
        }
      }
    }
  }
  if (evictionAware && maxSizePerJVM < recordsStillOwned) {
    int numberOfRecordsToEvict=(int)(recordsStillOwned * evictionRate);
    int evictedCount=0;
    for (    Record record : sortedRecords) {
      if (record.isActive() && record.isEvictable()) {
        recordsToEvict.add(record);
        if (++evictedCount >= numberOfRecordsToEvict) {
          break;
        }
      }
    }
  }
  Level levelLog=(concurrentMapManager.LOG_STATE) ? Level.INFO : Level.FINEST;
  logger.log(levelLog,name + "String_Node_Str" + "String_Node_Str"+ recordsDirty.size()+ "String_Node_Str"+ recordsToPurge.size()+ "String_Node_Str"+ recordsToEvict.size()+ "String_Node_Str"+ recordsUnknown.size()+ "String_Node_Str"+ recordsStillOwned+ "String_Node_Str"+ backupPurgeCount);
  executeStoreUpdate(recordsDirty);
  executeEviction(recordsToEvict);
  executePurge(recordsToPurge);
  executePurgeUnknowns(recordsUnknown);
}