Program: 49387
Project: 49387
Buggy source:
public void run(){
  for (int i=0; i < nodeEngine.getPartitionService().getPartitionCount(); i++) {
    if ((i % ExecutorConfig.DEFAULT_POOL_SIZE) != mod) {
      continue;
    }
    Address owner=nodeEngine.getPartitionService().getPartitionOwner(i);
    if (nodeEngine.getThisAddress().equals(owner)) {
      PartitionContainer pc=partitionContainers[i];
      final RecordStore recordStore=pc.getRecordStore(mapName);
      SortedSet sortedRecords=new TreeSet(comparator);
      Set<Map.Entry<Data,Record>> recordEntries=recordStore.getRecords().entrySet();
      for (      Map.Entry<Data,Record> entry : recordEntries) {
        sortedRecords.add(entry.getValue());
      }
      int evictSize=0;
      if (maxSizePolicy == MaxSizeConfig.MaxSizePolicy.PER_NODE || maxSizePolicy == MaxSizeConfig.MaxSizePolicy.PER_PARTITION) {
        evictSize=sortedRecords.size() - targetSizePerPartition;
      }
 else {
        evictSize=sortedRecords.size() * evictionPercentage / 100;
      }
      if (evictSize == 0)       continue;
      Set<Data> keySet=new HashSet();
      Iterator iterator=sortedRecords.iterator();
      while (iterator.hasNext() && evictSize-- > 0) {
        Record rec=(Record)iterator.next();
        keySet.add(rec.getKey());
      }
      ClearOperation clearOperation=new ClearOperation(mapName,keySet);
      clearOperation.setNodeEngine(nodeEngine);
      clearOperation.setServiceName(SERVICE_NAME);
      clearOperation.setResponseHandler(ResponseHandlerFactory.createEmptyResponseHandler());
      clearOperation.setPartitionId(i);
      nodeEngine.getOperationService().runOperation(clearOperation);
    }
  }
}

Fixed version (ground truth):
public void run(){
  for (int i=0; i < nodeEngine.getPartitionService().getPartitionCount(); i++) {
    if ((i % ExecutorConfig.DEFAULT_POOL_SIZE) != mod) {
      continue;
    }
    Address owner=nodeEngine.getPartitionService().getPartitionOwner(i);
    if (nodeEngine.getThisAddress().equals(owner)) {
      PartitionContainer pc=partitionContainers[i];
      final RecordStore recordStore=pc.getRecordStore(mapName);
      List<Record> sortedRecords=new ArrayList<Record>(recordStore.getRecords().values());
      Collections.sort(sortedRecords,comparator);
      int evictSize=0;
      if (maxSizePolicy == MaxSizeConfig.MaxSizePolicy.PER_NODE || maxSizePolicy == MaxSizeConfig.MaxSizePolicy.PER_PARTITION) {
        evictSize=Math.max((sortedRecords.size() - targetSizePerPartition),(sortedRecords.size() * evictionPercentage / 100 + 1));
      }
 else {
        evictSize=sortedRecords.size() * evictionPercentage / 100;
      }
      if (evictSize == 0)       continue;
      Set<Data> keySet=new HashSet();
      Iterator iterator=sortedRecords.iterator();
      while (iterator.hasNext() && evictSize-- > 0) {
        Record rec=(Record)iterator.next();
        keySet.add(rec.getKey());
      }
      ClearOperation clearOperation=new ClearOperation(mapName,keySet);
      clearOperation.setNodeEngine(nodeEngine);
      clearOperation.setServiceName(SERVICE_NAME);
      clearOperation.setResponseHandler(ResponseHandlerFactory.createEmptyResponseHandler());
      clearOperation.setPartitionId(i);
      nodeEngine.getOperationService().runOperation(clearOperation);
    }
  }
}