Program: 48955
Project: 48955
Buggy source:
private boolean checkLimits(MapContainer mapContainer){
  MaxSizeConfig maxSizeConfig=mapContainer.getMapConfig().getMaxSizeConfig();
  MaxSizeConfig.MaxSizePolicy maxSizePolicy=maxSizeConfig.getMaxSizePolicy();
  String mapName=mapContainer.getName();
  int maxSize=maxSizeConfig.getSize() * 95 / 100;
  if (maxSizePolicy == MaxSizeConfig.MaxSizePolicy.PER_NODE || maxSizePolicy == MaxSizeConfig.MaxSizePolicy.PER_PARTITION) {
    int totalSize=0;
    for (int i=0; i < nodeEngine.getPartitionService().getPartitionCount(); i++) {
      Address owner=nodeEngine.getPartitionService().getPartitionOwner(i);
      if (nodeEngine.getThisAddress().equals(owner)) {
        final PartitionContainer container=partitionContainers[i];
        if (container == null) {
          return false;
        }
        int size=container.getRecordStore(mapName).getRecords().size();
        if (maxSizePolicy == MaxSizeConfig.MaxSizePolicy.PER_PARTITION) {
          if (size >= maxSize) {
            return true;
          }
        }
 else {
          totalSize+=size;
        }
      }
    }
    return maxSizePolicy == MaxSizeConfig.MaxSizePolicy.PER_NODE && totalSize >= maxSize;
  }
  if (maxSizePolicy == MaxSizeConfig.MaxSizePolicy.USED_HEAP_SIZE || maxSizePolicy == MaxSizeConfig.MaxSizePolicy.USED_HEAP_PERCENTAGE) {
    final long total=Runtime.getRuntime().totalMemory();
    final long used=mapContainer.getSizeEstimator().getSize();
    if (maxSizePolicy == MaxSizeConfig.MaxSizePolicy.USED_HEAP_SIZE) {
      return maxSize < (used / 1024 / 1024);
    }
 else {
      return maxSize < (used / total);
    }
  }
  return false;
}

Fixed version (ground truth):
private boolean checkLimits(MapContainer mapContainer){
  MaxSizeConfig maxSizeConfig=mapContainer.getMapConfig().getMaxSizeConfig();
  MaxSizeConfig.MaxSizePolicy maxSizePolicy=maxSizeConfig.getMaxSizePolicy();
  String mapName=mapContainer.getName();
  int maxSize=maxSizeConfig.getSize() * 95 / 100;
  if (maxSizePolicy == MaxSizeConfig.MaxSizePolicy.PER_NODE || maxSizePolicy == MaxSizeConfig.MaxSizePolicy.PER_PARTITION) {
    int totalSize=0;
    for (int i=0; i < nodeEngine.getPartitionService().getPartitionCount(); i++) {
      Address owner=nodeEngine.getPartitionService().getPartitionOwner(i);
      if (nodeEngine.getThisAddress().equals(owner)) {
        final PartitionContainer container=partitionContainers[i];
        if (container == null) {
          return false;
        }
        int size=container.getRecordStore(mapName).getRecords().size();
        if (maxSizePolicy == MaxSizeConfig.MaxSizePolicy.PER_PARTITION) {
          if (size >= maxSize) {
            return true;
          }
        }
 else {
          totalSize+=size;
        }
      }
    }
    return maxSizePolicy == MaxSizeConfig.MaxSizePolicy.PER_NODE && totalSize >= maxSize;
  }
  if (maxSizePolicy == MaxSizeConfig.MaxSizePolicy.USED_HEAP_SIZE || maxSizePolicy == MaxSizeConfig.MaxSizePolicy.USED_HEAP_PERCENTAGE) {
    final long total=Runtime.getRuntime().totalMemory();
    final long used=mapContainer.getSizeEstimator().getSize();
    if (maxSizePolicy == MaxSizeConfig.MaxSizePolicy.USED_HEAP_SIZE) {
      return maxSize < (used / 1024 / 1024);
    }
 else {
      return maxSize < (100d * used / total);
    }
  }
  return false;
}