nus-yam/ex-repair huggingface dataset:
Program: 47117
Project: 47117
Buggy source:
@Test public void testUpdateImbalance() throws Exception {
  MigratableHandler handler1=mock(MigratableHandler.class);
  when(handler1.getEventCount()).thenReturn(0l).thenReturn(100l);
  when(handler1.getOwner()).thenReturn(selector1);
  loadTracker.addHandler(handler1);
  MigratableHandler handler2=mock(MigratableHandler.class);
  when(handler2.getEventCount()).thenReturn(0l).thenReturn(200l);
  when(handler2.getOwner()).thenReturn(selector2);
  loadTracker.addHandler(handler2);
  MigratableHandler handler3=mock(MigratableHandler.class);
  when(handler3.getEventCount()).thenReturn(0l).thenReturn(100l);
  when(handler3.getOwner()).thenReturn(selector2);
  loadTracker.addHandler(handler3);
  LoadImbalance loadImbalance=loadTracker.updateImbalance();
  assertEquals(0,loadImbalance.minimumEvents);
  assertEquals(0,loadImbalance.maximumEvents);
  loadTracker.updateImbalance();
  assertEquals(100,loadImbalance.minimumEvents);
  assertEquals(300,loadImbalance.maximumEvents);
  assertEquals(selector1,loadImbalance.destinationSelector);
  assertEquals(selector2,loadImbalance.sourceSelector);
}

Fixed version (ground truth):
@Test public void testUpdateImbalance() throws Exception {
  MigratableHandler selector1Handler1=mock(MigratableHandler.class);
  when(selector1Handler1.getEventCount()).thenReturn(0l).thenReturn(100l);
  when(selector1Handler1.getOwner()).thenReturn(selector1);
  loadTracker.addHandler(selector1Handler1);
  MigratableHandler selector2Handler1=mock(MigratableHandler.class);
  when(selector2Handler1.getEventCount()).thenReturn(0l).thenReturn(200l);
  when(selector2Handler1.getOwner()).thenReturn(selector2);
  loadTracker.addHandler(selector2Handler1);
  MigratableHandler selector2Handler3=mock(MigratableHandler.class);
  when(selector2Handler3.getEventCount()).thenReturn(0l).thenReturn(100l);
  when(selector2Handler3.getOwner()).thenReturn(selector2);
  loadTracker.addHandler(selector2Handler3);
  LoadImbalance loadImbalance=loadTracker.updateImbalance();
  assertEquals(0,loadImbalance.minimumEvents);
  assertEquals(0,loadImbalance.maximumEvents);
  loadTracker.updateImbalance();
  assertEquals(100,loadImbalance.minimumEvents);
  assertEquals(300,loadImbalance.maximumEvents);
  assertEquals(selector1,loadImbalance.destinationSelector);
  assertEquals(selector2,loadImbalance.sourceSelector);
}
Program: 47118
Project: 47118
Buggy source:
public InSelectorImpl[] getInSelectors(){
  return inSelectors;
}

Fixed version (ground truth):
@edu.umd.cs.findbugs.annotations.SuppressWarnings({"String_Node_Str"}) public InSelectorImpl[] getInSelectors(){
  return inSelectors;
}
Program: 47119
Project: 47119
Buggy source:
public OutSelectorImpl[] getOutSelectors(){
  return outSelectors;
}

Fixed version (ground truth):
@edu.umd.cs.findbugs.annotations.SuppressWarnings({"String_Node_Str"}) public OutSelectorImpl[] getOutSelectors(){
  return outSelectors;
}
Program: 47120
Project: 47120
Buggy source:
protected void markRecordStoreExpirable(long ttl){
  if (ttl > 0L) {
    hasEntryWithCustomTTL=true;
  }
}

Fixed version (ground truth):
protected void markRecordStoreExpirable(long ttl){
  if (ttl > 0L && ttl < Long.MAX_VALUE) {
    hasEntryWithCustomTTL=true;
  }
}
Program: 47122
Project: 47122
Buggy source:
private void createDataIn(HazelcastInstance[] cluster,String mapName,int start,int end){
  HazelcastInstance node=getNode(cluster);
  IMap m=node.getMap(mapName);
  for (; start < end; start++) {
    m.put(start,node.getConfig().getGroupConfig().getName() + start);
  }
}

Fixed version (ground truth):
private void createDataIn(HazelcastInstance[] cluster,String mapName,int start,int end,long ttl,TimeUnit timeUnit){
  HazelcastInstance node=getNode(cluster);
  IMap m=node.getMap(mapName);
  for (; start < end; start++) {
    m.put(start,node.getConfig().getGroupConfig().getName() + start,ttl,timeUnit);
  }
}
Program: 47123
Project: 47123
Buggy source:
protected void markRecordStoreExpirable(long ttl){
  if (ttl > 0L) {
    hasEntryWithCustomTTL=true;
  }
}

Fixed version (ground truth):
protected void markRecordStoreExpirable(long ttl){
  if (ttl > 0L && ttl < Long.MAX_VALUE) {
    hasEntryWithCustomTTL=true;
  }
}
Program: 47125
Project: 47125
Buggy source:
private void createDataIn(HazelcastInstance[] cluster,String mapName,int start,int end){
  HazelcastInstance node=getNode(cluster);
  IMap m=node.getMap(mapName);
  for (; start < end; start++) {
    m.put(start,node.getConfig().getGroupConfig().getName() + start);
  }
}

Fixed version (ground truth):
private void createDataIn(HazelcastInstance[] cluster,String mapName,int start,int end,long ttl,TimeUnit timeUnit){
  HazelcastInstance node=getNode(cluster);
  IMap m=node.getMap(mapName);
  for (; start < end; start++) {
    m.put(start,node.getConfig().getGroupConfig().getName() + start,ttl,timeUnit);
  }
}
Program: 47126
Project: 47126
Buggy source:
public static int getMaxSizePerNode(MaxSizeConfig maxSizeConfig){
  int maxSizePerNode=getApproximateMaxSize(maxSizeConfig,MaxSizePolicy.PER_NODE);
  if (maxSizePerNode == MaxSizeConfig.DEFAULT_MAX_SIZE) {
    return -1;
  }
  return maxSizePerNode;
}

Fixed version (ground truth):
public static int getMaxSizePerNode(MaxSizeConfig maxSizeConfig){
  double maxSizePerNode=getApproximateMaxSize(maxSizeConfig,MaxSizePolicy.PER_NODE);
  if (maxSizePerNode == MaxSizeConfig.DEFAULT_MAX_SIZE) {
    return -1;
  }
  return (int)maxSizePerNode;
}
Program: 47127
Project: 47127
Buggy source:
private boolean isEvictablePerPartition(final MapContainer mapContainer,int partitionId){
  final MapServiceContext mapServiceContext=mapContainer.getMapServiceContext();
  final MaxSizeConfig maxSizeConfig=mapContainer.getMapConfig().getMaxSizeConfig();
  final int maxSize=getApproximateMaxSize(maxSizeConfig.getSize());
  final String mapName=mapContainer.getName();
  final PartitionContainer container=mapServiceContext.getPartitionContainer(partitionId);
  if (container == null) {
    return false;
  }
  final int size=getRecordStoreSize(mapName,container);
  return size >= maxSize;
}

Fixed version (ground truth):
private boolean isEvictablePerPartition(final MapContainer mapContainer,int partitionId){
  final MapServiceContext mapServiceContext=mapContainer.getMapServiceContext();
  final MaxSizeConfig maxSizeConfig=mapContainer.getMapConfig().getMaxSizeConfig();
  final double maxSize=getApproximateMaxSize(maxSizeConfig.getSize());
  final String mapName=mapContainer.getName();
  final PartitionContainer container=mapServiceContext.getPartitionContainer(partitionId);
  if (container == null) {
    return false;
  }
  final int size=getRecordStoreSize(mapName,container);
  return size >= maxSize;
}
Program: 47128
Project: 47128
Buggy source:
/** 
 * Get max size setting form config for given policy
 * @return max size or -1 if policy is different or not set
 */
public static int getApproximateMaxSize(MaxSizeConfig maxSizeConfig,MaxSizePolicy policy){
  if (maxSizeConfig.getMaxSizePolicy() == policy) {
    return getApproximateMaxSize(maxSizeConfig.getSize());
  }
  return -1;
}

Fixed version (ground truth):
/** 
 * Get max size setting form config for given policy
 * @return max size or -1 if policy is different or not set
 */
public static double getApproximateMaxSize(MaxSizeConfig maxSizeConfig,MaxSizePolicy policy){
  if (maxSizeConfig.getMaxSizePolicy() == policy) {
    return getApproximateMaxSize(maxSizeConfig.getSize());
  }
  return -1D;
}
Program: 47129
Project: 47129
Buggy source:
private boolean isEvictableFreeHeapPercentage(final MapContainer mapContainer){
  final long currentFreeHeapSize=getAvailableMemory();
  final MaxSizeConfig maxSizeConfig=mapContainer.getMapConfig().getMaxSizeConfig();
  final int freeHeapPercentage=getApproximateMaxSize(maxSizeConfig.getSize());
  final long total=getTotalMemory();
  return freeHeapPercentage > (1D * ONE_HUNDRED_PERCENT * currentFreeHeapSize / total);
}

Fixed version (ground truth):
private boolean isEvictableFreeHeapPercentage(final MapContainer mapContainer){
  final long currentFreeHeapSize=getAvailableMemory();
  final MaxSizeConfig maxSizeConfig=mapContainer.getMapConfig().getMaxSizeConfig();
  final double freeHeapPercentage=getApproximateMaxSize(maxSizeConfig.getSize());
  final long total=getTotalMemory();
  return freeHeapPercentage > (1D * ONE_HUNDRED_PERCENT * currentFreeHeapSize / total);
}
Program: 47130
Project: 47130
Buggy source:
private boolean isEvictablePerNode(MapContainer mapContainer){
  int nodeTotalSize=0;
  final MaxSizeConfig maxSizeConfig=mapContainer.getMapConfig().getMaxSizeConfig();
  final int maxSize=getApproximateMaxSize(maxSizeConfig.getSize());
  final String mapName=mapContainer.getName();
  final MapServiceContext mapServiceContext=mapContainer.getMapServiceContext();
  final List<Integer> partitionIds=findPartitionIds();
  for (  int partitionId : partitionIds) {
    final PartitionContainer container=mapServiceContext.getPartitionContainer(partitionId);
    if (container == null) {
      continue;
    }
    nodeTotalSize+=getRecordStoreSize(mapName,container);
    if (nodeTotalSize >= maxSize) {
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
private boolean isEvictablePerNode(MapContainer mapContainer){
  long nodeTotalSize=0;
  final MaxSizeConfig maxSizeConfig=mapContainer.getMapConfig().getMaxSizeConfig();
  final double maxSize=getApproximateMaxSize(maxSizeConfig.getSize());
  final String mapName=mapContainer.getName();
  final MapServiceContext mapServiceContext=mapContainer.getMapServiceContext();
  final List<Integer> partitionIds=findPartitionIds();
  for (  int partitionId : partitionIds) {
    final PartitionContainer container=mapServiceContext.getPartitionContainer(partitionId);
    if (container == null) {
      continue;
    }
    nodeTotalSize+=getRecordStoreSize(mapName,container);
    if (nodeTotalSize >= maxSize) {
      return true;
    }
  }
  return false;
}
Program: 47131
Project: 47131
Buggy source:
private boolean isEvictableHeapSize(final MapContainer mapContainer){
  final long usedHeapSize=getUsedHeapSize(mapContainer);
  if (usedHeapSize == -1L) {
    return false;
  }
  final MaxSizeConfig maxSizeConfig=mapContainer.getMapConfig().getMaxSizeConfig();
  final int maxSize=getApproximateMaxSize(maxSizeConfig.getSize());
  return maxSize < (usedHeapSize / ONE_MEGABYTE);
}

Fixed version (ground truth):
private boolean isEvictableHeapSize(final MapContainer mapContainer){
  final long usedHeapSize=getUsedHeapSize(mapContainer);
  if (usedHeapSize == -1L) {
    return false;
  }
  final MaxSizeConfig maxSizeConfig=mapContainer.getMapConfig().getMaxSizeConfig();
  final double maxSize=getApproximateMaxSize(maxSizeConfig.getSize());
  return maxSize < (1D * usedHeapSize / ONE_MEGABYTE);
}
Program: 47132
Project: 47132
Buggy source:
private boolean isEvictableHeapPercentage(final MapContainer mapContainer){
  final long usedHeapSize=getUsedHeapSize(mapContainer);
  if (usedHeapSize == -1L) {
    return false;
  }
  final MaxSizeConfig maxSizeConfig=mapContainer.getMapConfig().getMaxSizeConfig();
  final int maxSize=getApproximateMaxSize(maxSizeConfig.getSize());
  final long total=getTotalMemory();
  return maxSize < (1D * ONE_HUNDRED_PERCENT * usedHeapSize / total);
}

Fixed version (ground truth):
private boolean isEvictableHeapPercentage(final MapContainer mapContainer){
  final long usedHeapSize=getUsedHeapSize(mapContainer);
  if (usedHeapSize == -1L) {
    return false;
  }
  final MaxSizeConfig maxSizeConfig=mapContainer.getMapConfig().getMaxSizeConfig();
  final double maxSize=getApproximateMaxSize(maxSizeConfig.getSize());
  final long total=getTotalMemory();
  return maxSize < (1D * ONE_HUNDRED_PERCENT * usedHeapSize / total);
}
Program: 47133
Project: 47133
Buggy source:
private boolean isEvictableFreeHeapSize(final MapContainer mapContainer){
  final long currentFreeHeapSize=getAvailableMemory();
  final MaxSizeConfig maxSizeConfig=mapContainer.getMapConfig().getMaxSizeConfig();
  final int minFreeHeapSize=getApproximateMaxSize(maxSizeConfig.getSize());
  return minFreeHeapSize > (currentFreeHeapSize / ONE_MEGABYTE);
}

Fixed version (ground truth):
private boolean isEvictableFreeHeapSize(final MapContainer mapContainer){
  final long currentFreeHeapSize=getAvailableMemory();
  final MaxSizeConfig maxSizeConfig=mapContainer.getMapConfig().getMaxSizeConfig();
  final double minFreeHeapSize=getApproximateMaxSize(maxSizeConfig.getSize());
  return minFreeHeapSize > (1D * currentFreeHeapSize / ONE_MEGABYTE);
}
Program: 47134
Project: 47134
Buggy source:
@Test public void testUsedHeapPercentagePolicy(){
  final int maxUsedHeapPercentage=60;
  final int nodeCount=1;
  final int putCount=1000;
  final String mapName=randomMapName();
  final Config config=createConfig(MaxSizeConfig.MaxSizePolicy.USED_HEAP_PERCENTAGE,maxUsedHeapPercentage,mapName);
  final Collection<IMap> maps=createMaps(mapName,config,nodeCount);
  final long oneEntryHeapCostInMegaBytes=1 << 30;
  setTestSizeEstimator(maps,oneEntryHeapCostInMegaBytes);
  populateMaps(maps,putCount);
  assertUsedHeapPercentagePolicyTriggersEviction(maps,putCount);
}

Fixed version (ground truth):
@Test public void testUsedHeapPercentagePolicy(){
  final int maxUsedHeapPercentage=60;
  final int nodeCount=1;
  final int putCount=1000;
  final String mapName=randomMapName();
  final Config config=createConfig(MaxSizeConfig.MaxSizePolicy.USED_HEAP_PERCENTAGE,maxUsedHeapPercentage,mapName);
  final Collection<IMap> maps=createMaps(mapName,config,nodeCount);
  final long oneEntryHeapCostInMegaBytes=1 << 30;
  setTestSizeEstimator(maps,MemoryUnit.MEGABYTES.toBytes(oneEntryHeapCostInMegaBytes));
  populateMaps(maps,putCount);
  assertUsedHeapPercentagePolicyTriggersEviction(maps,putCount);
}
Program: 47135
Project: 47135
Buggy source:
@Test public void testUsedHeapSizePolicy(){
  final int perNodeHeapMaxSizeInMegaBytes=10;
  final int nodeCount=1;
  final String mapName=randomMapName();
  final Config config=createConfig(MaxSizeConfig.MaxSizePolicy.USED_HEAP_SIZE,perNodeHeapMaxSizeInMegaBytes,mapName);
  final Collection<IMap> maps=createMaps(mapName,config,nodeCount);
  setTestSizeEstimator(maps,1);
  populateMaps(maps,100);
  assertUsedHeapSizePolicyWorks(maps,perNodeHeapMaxSizeInMegaBytes);
}

Fixed version (ground truth):
@Test public void testUsedHeapSizePolicy(){
  final int perNodeHeapMaxSizeInMegaBytes=10;
  final int nodeCount=1;
  final String mapName=randomMapName();
  final Config config=createConfig(MaxSizeConfig.MaxSizePolicy.USED_HEAP_SIZE,perNodeHeapMaxSizeInMegaBytes,mapName);
  final Collection<IMap> maps=createMaps(mapName,config,nodeCount);
  setTestSizeEstimator(maps,MemoryUnit.MEGABYTES.toBytes(1));
  populateMaps(maps,100);
  assertUsedHeapSizePolicyWorks(maps,perNodeHeapMaxSizeInMegaBytes);
}
Program: 47136
Project: 47136
Buggy source:
@Override public long getCost(Object record){
  return MemoryUnit.MEGABYTES.toBytes(oneEntryHeapCostInMegaBytes);
}

Fixed version (ground truth):
@Override public long getCost(Object record){
  return oneEntryHeapCostInBytes;
}
Program: 47137
Project: 47137
Buggy source:
private void setTestSizeEstimator(IMap map,final long oneEntryHeapCostInMegaBytes){
  final MapProxyImpl mapProxy=(MapProxyImpl)map;
  final MapService mapService=(MapService)mapProxy.getService();
  final MapServiceContext mapServiceContext=mapService.getMapServiceContext();
  final NodeEngine nodeEngine=mapServiceContext.getNodeEngine();
  final InternalPartitionService partitionService=nodeEngine.getPartitionService();
  for (int i=0; i < partitionService.getPartitionCount(); i++) {
    final Address owner=partitionService.getPartitionOwner(i);
    if (nodeEngine.getThisAddress().equals(owner)) {
      final PartitionContainer container=mapServiceContext.getPartitionContainer(i);
      if (container == null) {
        continue;
      }
      final RecordStore recordStore=container.getRecordStore(map.getName());
      final DefaultRecordStore defaultRecordStore=(DefaultRecordStore)recordStore;
      defaultRecordStore.setSizeEstimator(new SizeEstimator(){
        long size;
        @Override public long getSize(){
          return size;
        }
        @Override public void add(        long size){
          this.size+=size;
        }
        @Override public long getCost(        Object record){
          return MemoryUnit.MEGABYTES.toBytes(oneEntryHeapCostInMegaBytes);
        }
        @Override public void reset(){
          size=0;
        }
      }
);
    }
  }
}

Fixed version (ground truth):
private void setTestSizeEstimator(IMap map,final long oneEntryHeapCostInBytes){
  final MapProxyImpl mapProxy=(MapProxyImpl)map;
  final MapService mapService=(MapService)mapProxy.getService();
  final MapServiceContext mapServiceContext=mapService.getMapServiceContext();
  final NodeEngine nodeEngine=mapServiceContext.getNodeEngine();
  final InternalPartitionService partitionService=nodeEngine.getPartitionService();
  for (int i=0; i < partitionService.getPartitionCount(); i++) {
    final Address owner=partitionService.getPartitionOwner(i);
    if (nodeEngine.getThisAddress().equals(owner)) {
      final PartitionContainer container=mapServiceContext.getPartitionContainer(i);
      if (container == null) {
        continue;
      }
      final RecordStore recordStore=container.getRecordStore(map.getName());
      final DefaultRecordStore defaultRecordStore=(DefaultRecordStore)recordStore;
      defaultRecordStore.setSizeEstimator(new SizeEstimator(){
        long size;
        @Override public long getSize(){
          return size;
        }
        @Override public void add(        long size){
          this.size+=size;
        }
        @Override public long getCost(        Object record){
          return oneEntryHeapCostInBytes;
        }
        @Override public void reset(){
          size=0;
        }
      }
);
    }
  }
}
Program: 47138
Project: 47138
Buggy source:
private Record isTTLExpired(Record record,long now,boolean backup){
  if (record == null) {
    return null;
  }
  final long ttl=record.getTtl();
  if (ttl < 1L) {
    return record;
  }
  final long lastUpdateTime=record.getLastUpdateTime();
  final long ttlMillis=calculateExpirationWithDelay(ttl,backupExpiryDelayMillis,backup);
  final long elapsedMillis=now - lastUpdateTime;
  return elapsedMillis >= ttlMillis ? null : record;
}

Fixed version (ground truth):
private Record isTTLExpired(Record record,long now,boolean backup){
  if (record == null) {
    return null;
  }
  final long ttl=record.getTtl();
  if (ttl < 1L) {
    return record;
  }
  final long lastUpdateTime=record.getLastUpdateTime();
  final long ttlMillis=calculateExpirationWithDelay(ttl,getBackupExpiryDelayMillis(),backup);
  final long elapsedMillis=now - lastUpdateTime;
  return elapsedMillis >= ttlMillis ? null : record;
}
Program: 47139
Project: 47139
Buggy source:
protected AbstractEvictableRecordStore(MapContainer mapContainer,int partitionId){
  super(mapContainer,partitionId);
  final MapConfig mapConfig=mapContainer.getMapConfig();
  this.minEvictionCheckMillis=mapConfig.getMinEvictionCheckMillis();
  this.evictionPolicy=mapContainer.getMapConfig().getEvictionPolicy();
  this.evictionEnabled=!EvictionPolicy.NONE.equals(evictionPolicy);
  this.expirable=isRecordStoreExpirable();
  this.backupExpiryDelayMillis=getBackupExpiryDelayMillis();
}

Fixed version (ground truth):
protected AbstractEvictableRecordStore(MapContainer mapContainer,int partitionId){
  super(mapContainer,partitionId);
}
Program: 47140
Project: 47140
Buggy source:
/** 
 * Eviction waits at least   {@link #minEvictionCheckMillis} milliseconds to run.
 * @return <code>true</code> if in that time window,otherwise <code>false</code>
 */
private boolean inEvictableTimeWindow(long now){
  return minEvictionCheckMillis == 0L || (now - lastEvictionTime) > minEvictionCheckMillis;
}

Fixed version (ground truth):
/** 
 * Eviction waits at least   {@link MapConfig#minEvictionCheckMillis} milliseconds to run.
 * @return <code>true</code> if in that time window,otherwise <code>false</code>
 */
private boolean inEvictableTimeWindow(long now){
  long minEvictionCheckMillis=getMinEvictionCheckMillis();
  return minEvictionCheckMillis == 0L || (now - lastEvictionTime) > minEvictionCheckMillis;
}
Program: 47141
Project: 47141
Buggy source:
/** 
 * If there is no clean-up caused by puts after some time, try to clean-up from gets.
 * @param now now.
 */
protected void postReadCleanUp(long now,boolean backup){
  if (evictionEnabled) {
    readCountBeforeCleanUp++;
    if ((readCountBeforeCleanUp & POST_READ_CHECK_POINT) == 0) {
      cleanUp(now,backup);
    }
  }
}

Fixed version (ground truth):
/** 
 * If there is no clean-up caused by puts after some time, try to clean-up from gets.
 * @param now now.
 */
protected void postReadCleanUp(long now,boolean backup){
  if (isEvictionEnabled()) {
    readCountBeforeCleanUp++;
    if ((readCountBeforeCleanUp & POST_READ_CHECK_POINT) == 0) {
      cleanUp(now,backup);
    }
  }
}
Program: 47142
Project: 47142
Buggy source:
protected boolean shouldEvict(long now){
  return evictionEnabled && inEvictableTimeWindow(now) && isEvictable();
}

Fixed version (ground truth):
protected boolean shouldEvict(long now){
  return isEvictionEnabled() && inEvictableTimeWindow(now) && isEvictable();
}
Program: 47143
Project: 47143
Buggy source:
protected void markRecordStoreExpirable(long ttl){
  if (ttl > 0L) {
    expirable=true;
  }
}

Fixed version (ground truth):
protected void markRecordStoreExpirable(long ttl){
  if (ttl > 0L) {
    hasEntryWithCustomTTL=true;
  }
}
Program: 47144
Project: 47144
Buggy source:
private boolean isRecordStoreExpirable(){
  final MapConfig mapConfig=mapContainer.getMapConfig();
  return mapConfig.getMaxIdleSeconds() > 0 || mapConfig.getTimeToLiveSeconds() > 0;
}

Fixed version (ground truth):
/** 
 * Returns   {@code true} if this record store has at least one candidate entryfor expiration (idle or tll) otherwise returns  {@code false}.
 */
private boolean isRecordStoreExpirable(){
  final MapConfig mapConfig=mapContainer.getMapConfig();
  return hasEntryWithCustomTTL || mapConfig.getMaxIdleSeconds() > 0 || mapConfig.getTimeToLiveSeconds() > 0;
}
Program: 47145
Project: 47145
Buggy source:
/** 
 * Check if record is reachable according to ttl or idle times. If not reachable return null.
 * @param record {@link com.hazelcast.map.impl.record.Record}
 * @return null if evictable.
 */
protected Record getOrNullIfExpired(Record record,long now,boolean backup){
  if (!expirable) {
    return record;
  }
  if (record == null) {
    return null;
  }
  final Data key=record.getKey();
  if (isLocked(key)) {
    return record;
  }
  if (!isExpired(record,now,backup)) {
    return record;
  }
  final Object value=record.getValue();
  evictInternal(key,backup);
  if (!backup) {
    doPostExpirationOperations(key,value);
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Check if record is reachable according to ttl or idle times. If not reachable return null.
 * @param record {@link com.hazelcast.map.impl.record.Record}
 * @return null if evictable.
 */
protected Record getOrNullIfExpired(Record record,long now,boolean backup){
  if (!isRecordStoreExpirable()) {
    return record;
  }
  if (record == null) {
    return null;
  }
  final Data key=record.getKey();
  if (isLocked(key)) {
    return record;
  }
  if (!isExpired(record,now,backup)) {
    return record;
  }
  final Object value=record.getValue();
  evictInternal(key,backup);
  if (!backup) {
    doPostExpirationOperations(key,value);
  }
  return null;
}
Program: 47146
Project: 47146
Buggy source:
private Record isIdleExpired(Record record,long now,boolean backup){
  if (record == null) {
    return null;
  }
  final long lastAccessTime=record.getLastAccessTime();
  final long maxIdleMillis=mapContainer.getMaxIdleMillis();
  final long idleMillis=calculateExpirationWithDelay(maxIdleMillis,backupExpiryDelayMillis,backup);
  final long elapsedMillis=now - lastAccessTime;
  return elapsedMillis >= idleMillis ? null : record;
}

Fixed version (ground truth):
private Record isIdleExpired(Record record,long now,boolean backup){
  if (record == null) {
    return null;
  }
  final long lastAccessTime=record.getLastAccessTime();
  final long maxIdleMillis=calculateMaxIdleMillis(mapContainer.getMapConfig());
  final long idleMillis=calculateExpirationWithDelay(maxIdleMillis,getBackupExpiryDelayMillis(),backup);
  final long elapsedMillis=now - lastAccessTime;
  return elapsedMillis >= idleMillis ? null : record;
}
Program: 47147
Project: 47147
Buggy source:
@Override public boolean isExpirable(){
  return expirable;
}

Fixed version (ground truth):
@Override public boolean isExpirable(){
  return isRecordStoreExpirable();
}
Program: 47148
Project: 47148
Buggy source:
@Override protected void accessRecord(Record record,long now){
  super.accessRecord(record,now);
  increaseRecordEvictionCriteriaNumber(record,evictionPolicy);
  final long maxIdleMillis=mapContainer.getMaxIdleMillis();
  setExpirationTime(record,maxIdleMillis);
}

Fixed version (ground truth):
@Override protected void accessRecord(Record record,long now){
  super.accessRecord(record,now);
  increaseRecordEvictionCriteriaNumber(record,getEvictionPolicy());
  final long maxIdleMillis=calculateMaxIdleMillis(mapContainer.getMapConfig());
  setExpirationTime(record,maxIdleMillis);
}
Program: 47149
Project: 47149
Buggy source:
/** 
 * TODO make checkEvictable fast by carrying threshold logic to partition. This cleanup adds some latency to write operations. But it sweeps records much better under high write loads. <p/>
 * @param now now in time.
 */
public void evictEntries(long now,boolean backup){
  if (evictionEnabled) {
    cleanUp(now,backup);
  }
}

Fixed version (ground truth):
/** 
 * TODO make checkEvictable fast by carrying threshold logic to partition. This cleanup adds some latency to write operations. But it sweeps records much better under high write loads. <p/>
 * @param now now in time.
 */
public void evictEntries(long now,boolean backup){
  if (isEvictionEnabled()) {
    cleanUp(now,backup);
  }
}
Program: 47150
Project: 47150
Buggy source:
@Override public void putTransient(Data key,Object value,long ttl){
  checkIfLoaded();
  final long now=getNow();
  markRecordStoreExpirable(ttl);
  Record record=getRecordOrNull(key,now,false);
  if (record == null) {
    value=mapServiceContext.interceptPut(name,null,value);
    record=createRecord(key,value,ttl,now);
    records.put(key,record);
    updateSizeEstimator(calculateRecordHeapCost(record));
  }
 else {
    value=mapServiceContext.interceptPut(name,record.getValue(),value);
    updateSizeEstimator(-calculateRecordHeapCost(record));
    updateRecord(record,value,now);
    updateSizeEstimator(calculateRecordHeapCost(record));
    updateExpiryTime(record,ttl,mapContainer.getMaxIdleMillis());
  }
  saveIndex(record);
  mapDataStore.addTransient(key,now);
}

Fixed version (ground truth):
@Override public void putTransient(Data key,Object value,long ttl){
  checkIfLoaded();
  final long now=getNow();
  markRecordStoreExpirable(ttl);
  Record record=getRecordOrNull(key,now,false);
  if (record == null) {
    value=mapServiceContext.interceptPut(name,null,value);
    record=createRecord(key,value,ttl,now);
    records.put(key,record);
    updateSizeEstimator(calculateRecordHeapCost(record));
  }
 else {
    value=mapServiceContext.interceptPut(name,record.getValue(),value);
    updateSizeEstimator(-calculateRecordHeapCost(record));
    updateRecord(record,value,now);
    updateSizeEstimator(calculateRecordHeapCost(record));
    updateExpiryTime(record,ttl,mapContainer.getMapConfig());
  }
  saveIndex(record);
  mapDataStore.addTransient(key,now);
}
Program: 47151
Project: 47151
Buggy source:
@Override public Object put(Data key,Object value,long ttl){
  checkIfLoaded();
  final long now=getNow();
  markRecordStoreExpirable(ttl);
  Record record=getRecordOrNull(key,now,false);
  Object oldValue;
  if (record == null) {
    oldValue=mapDataStore.load(key);
    value=mapServiceContext.interceptPut(name,null,value);
    value=mapDataStore.add(key,value,now);
    record=createRecord(key,value,ttl,now);
    records.put(key,record);
    updateSizeEstimator(calculateRecordHeapCost(record));
    saveIndex(record);
  }
 else {
    oldValue=record.getValue();
    value=mapServiceContext.interceptPut(name,oldValue,value);
    value=mapDataStore.add(key,value,now);
    onStore(record);
    updateSizeEstimator(-calculateRecordHeapCost(record));
    updateRecord(record,value,now);
    updateSizeEstimator(calculateRecordHeapCost(record));
    updateExpiryTime(record,ttl,mapContainer.getMaxIdleMillis());
    saveIndex(record);
  }
  return oldValue;
}

Fixed version (ground truth):
@Override public Object put(Data key,Object value,long ttl){
  checkIfLoaded();
  final long now=getNow();
  markRecordStoreExpirable(ttl);
  Record record=getRecordOrNull(key,now,false);
  Object oldValue;
  if (record == null) {
    oldValue=mapDataStore.load(key);
    value=mapServiceContext.interceptPut(name,null,value);
    value=mapDataStore.add(key,value,now);
    record=createRecord(key,value,ttl,now);
    records.put(key,record);
    updateSizeEstimator(calculateRecordHeapCost(record));
    saveIndex(record);
  }
 else {
    oldValue=record.getValue();
    value=mapServiceContext.interceptPut(name,oldValue,value);
    value=mapDataStore.add(key,value,now);
    onStore(record);
    updateSizeEstimator(-calculateRecordHeapCost(record));
    updateRecord(record,value,now);
    updateSizeEstimator(calculateRecordHeapCost(record));
    updateExpiryTime(record,ttl,mapContainer.getMapConfig());
    saveIndex(record);
  }
  return oldValue;
}
Program: 47152
Project: 47152
Buggy source:
@Override public Object putFromLoad(Data key,Object value,long ttl){
  final long now=getNow();
  if (shouldEvict(now)) {
    return null;
  }
  markRecordStoreExpirable(ttl);
  Record record=getRecordOrNull(key,now,false);
  Object oldValue=null;
  if (record == null) {
    value=mapServiceContext.interceptPut(name,null,value);
    record=createRecord(key,value,ttl,now);
    records.put(key,record);
    updateSizeEstimator(calculateRecordHeapCost(record));
  }
 else {
    oldValue=record.getValue();
    value=mapServiceContext.interceptPut(name,record.getValue(),value);
    updateSizeEstimator(-calculateRecordHeapCost(record));
    updateRecord(record,value,now);
    updateSizeEstimator(calculateRecordHeapCost(record));
    updateExpiryTime(record,ttl,mapContainer.getMaxIdleMillis());
  }
  saveIndex(record);
  return oldValue;
}

Fixed version (ground truth):
@Override public Object putFromLoad(Data key,Object value,long ttl){
  final long now=getNow();
  if (shouldEvict(now)) {
    return null;
  }
  markRecordStoreExpirable(ttl);
  Record record=getRecordOrNull(key,now,false);
  Object oldValue=null;
  if (record == null) {
    value=mapServiceContext.interceptPut(name,null,value);
    record=createRecord(key,value,ttl,now);
    records.put(key,record);
    updateSizeEstimator(calculateRecordHeapCost(record));
  }
 else {
    oldValue=record.getValue();
    value=mapServiceContext.interceptPut(name,record.getValue(),value);
    updateSizeEstimator(-calculateRecordHeapCost(record));
    updateRecord(record,value,now);
    updateSizeEstimator(calculateRecordHeapCost(record));
    updateExpiryTime(record,ttl,mapContainer.getMapConfig());
  }
  saveIndex(record);
  return oldValue;
}
Program: 47153
Project: 47153
Buggy source:
@Override public boolean tryPut(Data key,Object value,long ttl){
  checkIfLoaded();
  final long now=getNow();
  markRecordStoreExpirable(ttl);
  Record record=getRecordOrNull(key,now,false);
  if (record == null) {
    value=mapServiceContext.interceptPut(name,null,value);
    value=mapDataStore.add(key,value,now);
    record=createRecord(key,value,ttl,now);
    records.put(key,record);
    updateSizeEstimator(calculateRecordHeapCost(record));
  }
 else {
    value=mapServiceContext.interceptPut(name,record.getValue(),value);
    value=mapDataStore.add(key,value,now);
    onStore(record);
    updateSizeEstimator(-calculateRecordHeapCost(record));
    updateRecord(record,value,now);
    updateSizeEstimator(calculateRecordHeapCost(record));
    updateExpiryTime(record,ttl,mapContainer.getMaxIdleMillis());
  }
  saveIndex(record);
  return true;
}

Fixed version (ground truth):
@Override public boolean tryPut(Data key,Object value,long ttl){
  checkIfLoaded();
  final long now=getNow();
  markRecordStoreExpirable(ttl);
  Record record=getRecordOrNull(key,now,false);
  if (record == null) {
    value=mapServiceContext.interceptPut(name,null,value);
    value=mapDataStore.add(key,value,now);
    record=createRecord(key,value,ttl,now);
    records.put(key,record);
    updateSizeEstimator(calculateRecordHeapCost(record));
  }
 else {
    value=mapServiceContext.interceptPut(name,record.getValue(),value);
    value=mapDataStore.add(key,value,now);
    onStore(record);
    updateSizeEstimator(-calculateRecordHeapCost(record));
    updateRecord(record,value,now);
    updateSizeEstimator(calculateRecordHeapCost(record));
    updateExpiryTime(record,ttl,mapContainer.getMapConfig());
  }
  saveIndex(record);
  return true;
}
Program: 47154
Project: 47154
Buggy source:
@Override public boolean set(Data key,Object value,long ttl){
  checkIfLoaded();
  final long now=getNow();
  markRecordStoreExpirable(ttl);
  Record record=getRecordOrNull(key,now,false);
  boolean newRecord=false;
  if (record == null) {
    value=mapServiceContext.interceptPut(name,null,value);
    value=mapDataStore.add(key,value,now);
    record=createRecord(key,value,ttl,now);
    records.put(key,record);
    updateSizeEstimator(calculateRecordHeapCost(record));
    newRecord=true;
  }
 else {
    value=mapServiceContext.interceptPut(name,record.getValue(),value);
    value=mapDataStore.add(key,value,now);
    onStore(record);
    updateSizeEstimator(-calculateRecordHeapCost(record));
    updateRecord(record,value,now);
    updateSizeEstimator(calculateRecordHeapCost(record));
    updateExpiryTime(record,ttl,mapContainer.getMaxIdleMillis());
  }
  saveIndex(record);
  return newRecord;
}

Fixed version (ground truth):
@Override public boolean set(Data key,Object value,long ttl){
  checkIfLoaded();
  final long now=getNow();
  markRecordStoreExpirable(ttl);
  Record record=getRecordOrNull(key,now,false);
  boolean newRecord=false;
  if (record == null) {
    value=mapServiceContext.interceptPut(name,null,value);
    value=mapDataStore.add(key,value,now);
    record=createRecord(key,value,ttl,now);
    records.put(key,record);
    updateSizeEstimator(calculateRecordHeapCost(record));
    newRecord=true;
  }
 else {
    value=mapServiceContext.interceptPut(name,record.getValue(),value);
    value=mapDataStore.add(key,value,now);
    onStore(record);
    updateSizeEstimator(-calculateRecordHeapCost(record));
    updateRecord(record,value,now);
    updateSizeEstimator(calculateRecordHeapCost(record));
    updateExpiryTime(record,ttl,mapContainer.getMapConfig());
  }
  saveIndex(record);
  return newRecord;
}
Program: 47155
Project: 47155
Buggy source:
@Override public Object putIfAbsent(Data key,Object value,long ttl){
  checkIfLoaded();
  final long now=getNow();
  markRecordStoreExpirable(ttl);
  Record record=getRecordOrNull(key,now,false);
  Object oldValue;
  if (record == null) {
    oldValue=mapDataStore.load(key);
    if (oldValue != null) {
      record=createRecord(key,oldValue,now);
      records.put(key,record);
      updateSizeEstimator(calculateRecordHeapCost(record));
    }
  }
 else {
    accessRecord(record,now);
    oldValue=record.getValue();
  }
  if (oldValue == null) {
    value=mapServiceContext.interceptPut(name,null,value);
    value=mapDataStore.add(key,value,now);
    onStore(record);
    record=createRecord(key,value,ttl,now);
    records.put(key,record);
    updateSizeEstimator(calculateRecordHeapCost(record));
    updateExpiryTime(record,ttl,mapContainer.getMaxIdleMillis());
  }
  saveIndex(record);
  return oldValue;
}

Fixed version (ground truth):
@Override public Object putIfAbsent(Data key,Object value,long ttl){
  checkIfLoaded();
  final long now=getNow();
  markRecordStoreExpirable(ttl);
  Record record=getRecordOrNull(key,now,false);
  Object oldValue;
  if (record == null) {
    oldValue=mapDataStore.load(key);
    if (oldValue != null) {
      record=createRecord(key,oldValue,now);
      records.put(key,record);
      updateSizeEstimator(calculateRecordHeapCost(record));
    }
  }
 else {
    accessRecord(record,now);
    oldValue=record.getValue();
  }
  if (oldValue == null) {
    value=mapServiceContext.interceptPut(name,null,value);
    value=mapDataStore.add(key,value,now);
    onStore(record);
    record=createRecord(key,value,ttl,now);
    records.put(key,record);
    updateSizeEstimator(calculateRecordHeapCost(record));
    updateExpiryTime(record,ttl,mapContainer.getMapConfig());
  }
  saveIndex(record);
  return oldValue;
}
Program: 47156
Project: 47156
Buggy source:
/** 
 * Updates records TTL and expiration time.
 */
public static void updateExpiryTime(Record record,long ttl,long maxIdleMillis){
  if (ttl < 0) {
    return;
  }
  ttl=checkedTime(ttl);
  record.setTtl(ttl);
  setExpirationTime(record,maxIdleMillis);
}

Fixed version (ground truth):
/** 
 * Updates records TTL and expiration time.
 */
public static void updateExpiryTime(Record record,long ttl,MapConfig mapConfig){
  if (ttl < 0) {
    return;
  }
  ttl=checkedTime(ttl);
  record.setTtl(ttl);
  long maxIdleMillis=calculateMaxIdleMillis(mapConfig);
  setExpirationTime(record,maxIdleMillis);
}
Program: 47157
Project: 47157
Buggy source:
/** 
 * Operations which are done in this constructor should obey the rules defined in the method comment   {@link com.hazelcast.spi.PostJoinAwareService#getPostJoinOperation()}Otherwise undesired situations, like deadlocks, may appear.
 */
public MapContainer(final String name,final MapConfig mapConfig,final MapServiceContext mapServiceContext){
  this.name=name;
  this.mapConfig=mapConfig;
  this.maxIdleMillis=calculateMaxIdleMillis(mapConfig);
  this.ttlMillisFromConfig=calculateTTLMillis(mapConfig);
  this.mapServiceContext=mapServiceContext;
  this.partitioningStrategy=createPartitioningStrategy();
  this.quorumName=mapConfig.getQuorumName();
  final NodeEngine nodeEngine=mapServiceContext.getNodeEngine();
  recordFactory=createRecordFactory(nodeEngine);
  initWanReplication(nodeEngine);
  interceptors=new CopyOnWriteArrayList<MapInterceptor>();
  interceptorMap=new ConcurrentHashMap<String,MapInterceptor>();
  nearCacheSizeEstimator=createNearCacheSizeEstimator();
  mapStoreContext=createMapStoreContext(this);
  mapStoreContext.start();
}

Fixed version (ground truth):
/** 
 * Operations which are done in this constructor should obey the rules defined in the method comment   {@link com.hazelcast.spi.PostJoinAwareService#getPostJoinOperation()}Otherwise undesired situations, like deadlocks, may appear.
 */
public MapContainer(final String name,final MapConfig mapConfig,final MapServiceContext mapServiceContext){
  this.name=name;
  this.mapConfig=mapConfig;
  this.mapServiceContext=mapServiceContext;
  this.partitioningStrategy=createPartitioningStrategy();
  this.quorumName=mapConfig.getQuorumName();
  final NodeEngine nodeEngine=mapServiceContext.getNodeEngine();
  recordFactory=createRecordFactory(nodeEngine);
  initWanReplication(nodeEngine);
  interceptors=new CopyOnWriteArrayList<MapInterceptor>();
  interceptorMap=new ConcurrentHashMap<String,MapInterceptor>();
  nearCacheSizeEstimator=createNearCacheSizeEstimator();
  mapStoreContext=createMapStoreContext(this);
  mapStoreContext.start();
}
Program: 47158
Project: 47158
Buggy source:
public Record createRecord(Data key,Object value,long ttlMillis,long now){
  Record record=getRecordFactory().newRecord(key,value);
  record.setLastAccessTime(now);
  record.setLastUpdateTime(now);
  record.setCreationTime(now);
  final long ttlMillisFromConfig=getTtlMillisFromConfig();
  final long ttl=pickTTL(ttlMillis,ttlMillisFromConfig);
  record.setTtl(ttl);
  final long maxIdleMillis=getMaxIdleMillis();
  setExpirationTime(record,maxIdleMillis);
  return record;
}

Fixed version (ground truth):
public Record createRecord(Data key,Object value,long ttlMillis,long now){
  Record record=getRecordFactory().newRecord(key,value);
  record.setLastAccessTime(now);
  record.setLastUpdateTime(now);
  record.setCreationTime(now);
  final long ttlMillisFromConfig=calculateTTLMillis(mapConfig);
  final long ttl=pickTTL(ttlMillis,ttlMillisFromConfig);
  record.setTtl(ttl);
  final long maxIdleMillis=calculateMaxIdleMillis(mapConfig);
  setExpirationTime(record,maxIdleMillis);
  return record;
}
Program: 47159
Project: 47159
Buggy source:
public static int getMaxSizePerNode(MaxSizeConfig maxSizeConfig){
  int maxSizePerNode=getApproximateMaxSize(maxSizeConfig,MaxSizePolicy.PER_NODE);
  if (maxSizePerNode == MaxSizeConfig.DEFAULT_MAX_SIZE) {
    return -1;
  }
  return maxSizePerNode;
}

Fixed version (ground truth):
public static int getMaxSizePerNode(MaxSizeConfig maxSizeConfig){
  double maxSizePerNode=getApproximateMaxSize(maxSizeConfig,MaxSizePolicy.PER_NODE);
  if (maxSizePerNode == MaxSizeConfig.DEFAULT_MAX_SIZE) {
    return -1;
  }
  return (int)maxSizePerNode;
}
Program: 47160
Project: 47160
Buggy source:
private boolean isEvictablePerPartition(final MapContainer mapContainer,int partitionId){
  final MapServiceContext mapServiceContext=mapContainer.getMapServiceContext();
  final MaxSizeConfig maxSizeConfig=mapContainer.getMapConfig().getMaxSizeConfig();
  final int maxSize=getApproximateMaxSize(maxSizeConfig.getSize());
  final String mapName=mapContainer.getName();
  final PartitionContainer container=mapServiceContext.getPartitionContainer(partitionId);
  if (container == null) {
    return false;
  }
  final int size=getRecordStoreSize(mapName,container);
  return size >= maxSize;
}

Fixed version (ground truth):
private boolean isEvictablePerPartition(final MapContainer mapContainer,int partitionId){
  final MapServiceContext mapServiceContext=mapContainer.getMapServiceContext();
  final MaxSizeConfig maxSizeConfig=mapContainer.getMapConfig().getMaxSizeConfig();
  final double maxSize=getApproximateMaxSize(maxSizeConfig.getSize());
  final String mapName=mapContainer.getName();
  final PartitionContainer container=mapServiceContext.getPartitionContainer(partitionId);
  if (container == null) {
    return false;
  }
  final int size=getRecordStoreSize(mapName,container);
  return size >= maxSize;
}
Program: 47161
Project: 47161
Buggy source:
/** 
 * Get max size setting form config for given policy
 * @return max size or -1 if policy is different or not set
 */
public static int getApproximateMaxSize(MaxSizeConfig maxSizeConfig,MaxSizePolicy policy){
  if (maxSizeConfig.getMaxSizePolicy() == policy) {
    return getApproximateMaxSize(maxSizeConfig.getSize());
  }
  return -1;
}

Fixed version (ground truth):
/** 
 * Get max size setting form config for given policy
 * @return max size or -1 if policy is different or not set
 */
public static double getApproximateMaxSize(MaxSizeConfig maxSizeConfig,MaxSizePolicy policy){
  if (maxSizeConfig.getMaxSizePolicy() == policy) {
    return getApproximateMaxSize(maxSizeConfig.getSize());
  }
  return -1D;
}
Program: 47162
Project: 47162
Buggy source:
private boolean isEvictableFreeHeapPercentage(final MapContainer mapContainer){
  final long currentFreeHeapSize=getAvailableMemory();
  final MaxSizeConfig maxSizeConfig=mapContainer.getMapConfig().getMaxSizeConfig();
  final int freeHeapPercentage=getApproximateMaxSize(maxSizeConfig.getSize());
  final long total=getTotalMemory();
  return freeHeapPercentage > (1D * ONE_HUNDRED_PERCENT * currentFreeHeapSize / total);
}

Fixed version (ground truth):
private boolean isEvictableFreeHeapPercentage(final MapContainer mapContainer){
  final long currentFreeHeapSize=getAvailableMemory();
  final MaxSizeConfig maxSizeConfig=mapContainer.getMapConfig().getMaxSizeConfig();
  final double freeHeapPercentage=getApproximateMaxSize(maxSizeConfig.getSize());
  final long total=getTotalMemory();
  return freeHeapPercentage > (1D * ONE_HUNDRED_PERCENT * currentFreeHeapSize / total);
}
Program: 47163
Project: 47163
Buggy source:
private boolean isEvictablePerNode(MapContainer mapContainer){
  int nodeTotalSize=0;
  final MaxSizeConfig maxSizeConfig=mapContainer.getMapConfig().getMaxSizeConfig();
  final int maxSize=getApproximateMaxSize(maxSizeConfig.getSize());
  final String mapName=mapContainer.getName();
  final MapServiceContext mapServiceContext=mapContainer.getMapServiceContext();
  final List<Integer> partitionIds=findPartitionIds();
  for (  int partitionId : partitionIds) {
    final PartitionContainer container=mapServiceContext.getPartitionContainer(partitionId);
    if (container == null) {
      continue;
    }
    nodeTotalSize+=getRecordStoreSize(mapName,container);
    if (nodeTotalSize >= maxSize) {
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
private boolean isEvictablePerNode(MapContainer mapContainer){
  long nodeTotalSize=0;
  final MaxSizeConfig maxSizeConfig=mapContainer.getMapConfig().getMaxSizeConfig();
  final double maxSize=getApproximateMaxSize(maxSizeConfig.getSize());
  final String mapName=mapContainer.getName();
  final MapServiceContext mapServiceContext=mapContainer.getMapServiceContext();
  final List<Integer> partitionIds=findPartitionIds();
  for (  int partitionId : partitionIds) {
    final PartitionContainer container=mapServiceContext.getPartitionContainer(partitionId);
    if (container == null) {
      continue;
    }
    nodeTotalSize+=getRecordStoreSize(mapName,container);
    if (nodeTotalSize >= maxSize) {
      return true;
    }
  }
  return false;
}
Program: 47164
Project: 47164
Buggy source:
private boolean isEvictableHeapSize(final MapContainer mapContainer){
  final long usedHeapSize=getUsedHeapSize(mapContainer);
  if (usedHeapSize == -1L) {
    return false;
  }
  final MaxSizeConfig maxSizeConfig=mapContainer.getMapConfig().getMaxSizeConfig();
  final int maxSize=getApproximateMaxSize(maxSizeConfig.getSize());
  return maxSize < (usedHeapSize / ONE_MEGABYTE);
}

Fixed version (ground truth):
private boolean isEvictableHeapSize(final MapContainer mapContainer){
  final long usedHeapSize=getUsedHeapSize(mapContainer);
  if (usedHeapSize == -1L) {
    return false;
  }
  final MaxSizeConfig maxSizeConfig=mapContainer.getMapConfig().getMaxSizeConfig();
  final double maxSize=getApproximateMaxSize(maxSizeConfig.getSize());
  return maxSize < (1D * usedHeapSize / ONE_MEGABYTE);
}
Program: 47165
Project: 47165
Buggy source:
private boolean isEvictableHeapPercentage(final MapContainer mapContainer){
  final long usedHeapSize=getUsedHeapSize(mapContainer);
  if (usedHeapSize == -1L) {
    return false;
  }
  final MaxSizeConfig maxSizeConfig=mapContainer.getMapConfig().getMaxSizeConfig();
  final int maxSize=getApproximateMaxSize(maxSizeConfig.getSize());
  final long total=getTotalMemory();
  return maxSize < (1D * ONE_HUNDRED_PERCENT * usedHeapSize / total);
}

Fixed version (ground truth):
private boolean isEvictableHeapPercentage(final MapContainer mapContainer){
  final long usedHeapSize=getUsedHeapSize(mapContainer);
  if (usedHeapSize == -1L) {
    return false;
  }
  final MaxSizeConfig maxSizeConfig=mapContainer.getMapConfig().getMaxSizeConfig();
  final double maxSize=getApproximateMaxSize(maxSizeConfig.getSize());
  final long total=getTotalMemory();
  return maxSize < (1D * ONE_HUNDRED_PERCENT * usedHeapSize / total);
}
Program: 47166
Project: 47166
Buggy source:
private boolean isEvictableFreeHeapSize(final MapContainer mapContainer){
  final long currentFreeHeapSize=getAvailableMemory();
  final MaxSizeConfig maxSizeConfig=mapContainer.getMapConfig().getMaxSizeConfig();
  final int minFreeHeapSize=getApproximateMaxSize(maxSizeConfig.getSize());
  return minFreeHeapSize > (currentFreeHeapSize / ONE_MEGABYTE);
}

Fixed version (ground truth):
private boolean isEvictableFreeHeapSize(final MapContainer mapContainer){
  final long currentFreeHeapSize=getAvailableMemory();
  final MaxSizeConfig maxSizeConfig=mapContainer.getMapConfig().getMaxSizeConfig();
  final double minFreeHeapSize=getApproximateMaxSize(maxSizeConfig.getSize());
  return minFreeHeapSize > (1D * currentFreeHeapSize / ONE_MEGABYTE);
}