nus-yam/ex-repair huggingface dataset:
Program: 48787
Project: 48787
Buggy source:
public Map.Entry<Data,Data> getMapEntryData(Data dataKey){
  checkIfLoaded();
  Record record=records.get(dataKey);
  Object value;
  if (record == null) {
    if (mapContainer.getStore() != null) {
      value=mapContainer.getStore().load(mapService.toObject(dataKey));
      if (value != null) {
        record=mapService.createRecord(name,dataKey,value,-1);
        records.put(dataKey,record);
        saveIndex(record);
        updateSizeEstimator(calculateRecordSize(record));
      }
    }
  }
 else {
    accessRecord(record);
  }
  Data data=record != null ? mapService.toData(record.getValue()) : null;
  return new AbstractMap.SimpleImmutableEntry<Data,Data>(dataKey,data);
}

Fixed version (ground truth):
public Map.Entry<Data,Data> getMapEntryData(Data dataKey){
  checkIfLoaded();
  Record record=records.get(dataKey);
  if (record == null) {
    record=getRecordInternal(dataKey);
  }
 else {
    accessRecord(record);
  }
  final Data data=record != null ? mapService.toData(record.getValue()) : null;
  return new AbstractMap.SimpleImmutableEntry<Data,Data>(dataKey,data);
}
Program: 48788
Project: 48788
Buggy source:
public Map.Entry<Data,Object> getMapEntryObject(Data dataKey){
  checkIfLoaded();
  Record record=records.get(dataKey);
  Object value=record != null ? mapService.toObject(record.getValue()) : null;
  return new AbstractMap.SimpleImmutableEntry<Data,Object>(dataKey,value);
}

Fixed version (ground truth):
public Map.Entry<Data,Object> getMapEntryObject(Data dataKey){
  checkIfLoaded();
  Record record=records.get(dataKey);
  if (record == null) {
    record=getRecordInternal(dataKey);
  }
 else {
    accessRecord(record);
  }
  final Object value=record != null ? mapService.toObject(record.getValue()) : null;
  return new AbstractMap.SimpleImmutableEntry<Data,Object>(dataKey,value);
}
Program: 48789
Project: 48789
Buggy source:
public Map.Entry<Data,Data> getMapEntryData(Data dataKey){
  checkIfLoaded();
  Record record=records.get(dataKey);
  if (record == null) {
    record=getRecordInternal(dataKey);
  }
 else {
    accessRecord(record);
  }
  final Data data=record != null ? mapService.toData(record.getValue()) : null;
  return new AbstractMap.SimpleImmutableEntry<Data,Data>(dataKey,data);
}

Fixed version (ground truth):
public Map.Entry<Data,Data> getMapEntryData(Data dataKey){
  checkIfLoaded();
  Record record=records.get(dataKey);
  if (record == null) {
    record=getRecordInternal(dataKey,true);
  }
 else {
    accessRecord(record);
  }
  final Data data=record != null ? mapService.toData(record.getValue()) : null;
  return new AbstractMap.SimpleImmutableEntry<Data,Data>(dataKey,data);
}
Program: 48790
Project: 48790
Buggy source:
private Record getRecordInternal(Data dataKey){
  Record record=null;
  if (mapContainer.getStore() != null) {
    final Object value=mapContainer.getStore().load(mapService.toObject(dataKey));
    if (value != null) {
      record=mapService.createRecord(name,dataKey,value,-1);
      records.put(dataKey,record);
      saveIndex(record);
      updateSizeEstimator(calculateRecordSize(record));
    }
  }
  return record;
}

Fixed version (ground truth):
private Record getRecordInternal(Data dataKey,boolean enableIndex){
  Record record=null;
  if (mapContainer.getStore() != null) {
    final Object value=mapContainer.getStore().load(mapService.toObject(dataKey));
    if (value != null) {
      record=mapService.createRecord(name,dataKey,value,-1);
      records.put(dataKey,record);
      if (enableIndex) {
        saveIndex(record);
      }
      updateSizeEstimator(calculateRecordSize(record));
    }
  }
  return record;
}
Program: 48791
Project: 48791
Buggy source:
public Map.Entry<Data,Object> getMapEntryObject(Data dataKey){
  checkIfLoaded();
  Record record=records.get(dataKey);
  if (record == null) {
    record=getRecordInternal(dataKey);
  }
 else {
    accessRecord(record);
  }
  final Object value=record != null ? mapService.toObject(record.getValue()) : null;
  return new AbstractMap.SimpleImmutableEntry<Data,Object>(dataKey,value);
}

Fixed version (ground truth):
public Map.Entry<Data,Object> getMapEntryObject(Data dataKey){
  checkIfLoaded();
  Record record=records.get(dataKey);
  if (record == null) {
    record=getRecordInternal(dataKey,false);
  }
 else {
    accessRecord(record);
  }
  final Object value=record != null ? mapService.toObject(record.getValue()) : null;
  return new AbstractMap.SimpleImmutableEntry<Data,Object>(dataKey,value);
}
Program: 48792
Project: 48792
Buggy source:
public Map.Entry<Data,Data> getMapEntryData(Data dataKey){
  checkIfLoaded();
  Record record=records.get(dataKey);
  Object value;
  if (record == null) {
    if (mapContainer.getStore() != null) {
      value=mapContainer.getStore().load(mapService.toObject(dataKey));
      if (value != null) {
        record=mapService.createRecord(name,dataKey,value,-1);
        records.put(dataKey,record);
        saveIndex(record);
        updateSizeEstimator(calculateRecordSize(record));
      }
    }
  }
 else {
    accessRecord(record);
  }
  Data data=record != null ? mapService.toData(record.getValue()) : null;
  return new AbstractMap.SimpleImmutableEntry<Data,Data>(dataKey,data);
}

Fixed version (ground truth):
public Map.Entry<Data,Data> getMapEntryData(Data dataKey){
  checkIfLoaded();
  Record record=records.get(dataKey);
  if (record == null) {
    record=getRecordInternal(dataKey);
  }
 else {
    accessRecord(record);
  }
  final Data data=record != null ? mapService.toData(record.getValue()) : null;
  return new AbstractMap.SimpleImmutableEntry<Data,Data>(dataKey,data);
}
Program: 48793
Project: 48793
Buggy source:
public Map.Entry<Data,Object> getMapEntryObject(Data dataKey){
  checkIfLoaded();
  Record record=records.get(dataKey);
  Object value=record != null ? mapService.toObject(record.getValue()) : null;
  return new AbstractMap.SimpleImmutableEntry<Data,Object>(dataKey,value);
}

Fixed version (ground truth):
public Map.Entry<Data,Object> getMapEntryObject(Data dataKey){
  checkIfLoaded();
  Record record=records.get(dataKey);
  if (record == null) {
    record=getRecordInternal(dataKey);
  }
 else {
    accessRecord(record);
  }
  final Object value=record != null ? mapService.toObject(record.getValue()) : null;
  return new AbstractMap.SimpleImmutableEntry<Data,Object>(dataKey,value);
}
Program: 48794
Project: 48794
Buggy source:
/** 
 * Iterates through all bundles to get the available @link ScriptEngineFactory classes
 * @return the names of the available ScriptEngineFactory classes
 * @throws IOException
 */
private List<String> findFactoryCandidates(BundleContext context) throws IOException {
  Bundle[] bundles=context.getBundles();
  List<String> factoryCandidates=new ArrayList<String>();
  for (  Bundle bundle : bundles) {
    System.out.println(bundle.getSymbolicName());
    if (bundle.getSymbolicName().equals("String_Node_Str"))     continue;
    Enumeration urls=bundle.findEntries("String_Node_Str","String_Node_Str",false);
    if (urls == null)     continue;
    while (urls.hasMoreElements()) {
      URL u=(URL)urls.nextElement();
      BufferedReader reader=new BufferedReader(new InputStreamReader(u.openStream()));
      String line;
      while ((line=reader.readLine()) != null) {
        factoryCandidates.add(line.trim());
      }
    }
  }
  factoryCandidates.add("String_Node_Str");
  return factoryCandidates;
}

Fixed version (ground truth):
/** 
 * Iterates through all bundles to get the available @link ScriptEngineFactory classes
 * @return the names of the available ScriptEngineFactory classes
 * @throws IOException
 */
private List<String> findFactoryCandidates(BundleContext context) throws IOException {
  Bundle[] bundles=context.getBundles();
  List<String> factoryCandidates=new ArrayList<String>();
  for (  Bundle bundle : bundles) {
    if (bundle.getSymbolicName().equals("String_Node_Str"))     continue;
    Enumeration urls=bundle.findEntries("String_Node_Str","String_Node_Str",false);
    if (urls == null)     continue;
    while (urls.hasMoreElements()) {
      URL u=(URL)urls.nextElement();
      BufferedReader reader=new BufferedReader(new InputStreamReader(u.openStream()));
      String line;
      while ((line=reader.readLine()) != null) {
        factoryCandidates.add(line.trim());
      }
    }
  }
  factoryCandidates.add("String_Node_Str");
  return factoryCandidates;
}
Program: 48795
Project: 48795
Buggy source:
private Map<ScriptEngineManager,ClassLoader> findManagers(BundleContext context){
  Map<ScriptEngineManager,ClassLoader> managers=new HashMap<ScriptEngineManager,ClassLoader>();
  try {
    for (    String factoryName : findFactoryCandidates(context)) {
      ClassLoader factoryLoader=Class.forName(factoryName).getClassLoader();
      ScriptEngineManager manager=new ScriptEngineManager(factoryLoader);
      manager.setBindings(bindings);
      managers.put(manager,factoryLoader);
    }
    return managers;
  }
 catch (  IOException ioe) {
    throw new RuntimeException(ioe);
  }
catch (  ClassNotFoundException cnfe) {
    throw new RuntimeException(cnfe);
  }
}

Fixed version (ground truth):
private Map<ScriptEngineManager,ClassLoader> findManagers(BundleContext context){
  Map<ScriptEngineManager,ClassLoader> managers=new HashMap<ScriptEngineManager,ClassLoader>();
  try {
    for (    String factoryName : findFactoryCandidates(context)) {
      ClassLoader factoryLoader;
      try {
        factoryLoader=Class.forName(factoryName).getClassLoader();
      }
 catch (      ClassNotFoundException cnfe) {
        logger.warning("String_Node_Str" + factoryName + "String_Node_Str"+ cnfe);
        if (logger.isFinestEnabled()) {
          logger.finest(cnfe);
        }
        continue;
      }
      ScriptEngineManager manager=new ScriptEngineManager(factoryLoader);
      manager.setBindings(bindings);
      managers.put(manager,factoryLoader);
    }
    return managers;
  }
 catch (  IOException ioe) {
    throw new RuntimeException(ioe);
  }
}
Program: 48796
Project: 48796
Buggy source:
public void run(){
  final NodeEngine nodeEngine=mapService.getNodeEngine();
  Map values=mapContainer.getStore().loadAll(keys.values());
  MapEntrySet entrySet=new MapEntrySet();
  for (  Data dataKey : keys.keySet()) {
    Object key=keys.get(dataKey);
    Object value=values.get(key);
    if (value != null) {
      Data dataValue=mapService.toData(value);
      entrySet.add(dataKey,dataValue);
    }
  }
  PutAllOperation operation=new PutAllOperation(name,entrySet,true);
  operation.setNodeEngine(nodeEngine);
  operation.setResponseHandler(new ResponseHandler(){
    @Override public void sendResponse(    Object obj){
      if (!(obj instanceof Exception)) {
        loaded.set(true);
      }
 else {
        Exception e=(Exception)obj;
        nodeEngine.getLogger(RecordStore.class).finest(e.getMessage());
      }
    }
    public boolean isLocal(){
      return true;
    }
  }
);
  operation.setPartitionId(partitionId);
  OperationAccessor.setCallerAddress(operation,nodeEngine.getThisAddress());
  operation.setServiceName(MapService.SERVICE_NAME);
  nodeEngine.getOperationService().executeOperation(operation);
}

Fixed version (ground truth):
public void run(){
  final NodeEngine nodeEngine=mapService.getNodeEngine();
  Map values=mapContainer.getStore().loadAll(keys.values());
  if (values == null || values.isEmpty()) {
    loaded.set(true);
    return;
  }
  MapEntrySet entrySet=new MapEntrySet();
  for (  Data dataKey : keys.keySet()) {
    Object key=keys.get(dataKey);
    Object value=values.get(key);
    if (value != null) {
      Data dataValue=mapService.toData(value);
      entrySet.add(dataKey,dataValue);
    }
  }
  PutAllOperation operation=new PutAllOperation(name,entrySet,true);
  operation.setNodeEngine(nodeEngine);
  operation.setResponseHandler(new ResponseHandler(){
    @Override public void sendResponse(    Object obj){
      if (!(obj instanceof Exception)) {
        loaded.set(true);
      }
 else {
        Exception e=(Exception)obj;
        nodeEngine.getLogger(RecordStore.class).finest(e.getMessage());
      }
    }
    public boolean isLocal(){
      return true;
    }
  }
);
  operation.setPartitionId(partitionId);
  OperationAccessor.setCallerAddress(operation,nodeEngine.getThisAddress());
  operation.setServiceName(MapService.SERVICE_NAME);
  nodeEngine.getOperationService().executeOperation(operation);
}
Program: 48797
Project: 48797
Buggy source:
@Test public void testIssue1019(){
  Config config=new Config();
  MapStoreConfig mapStoreConfig=new MapStoreConfig();
  mapStoreConfig.setImplementation(new MapStoreAdapter<String,String>());
  config.getMapConfig("String_Node_Str").setMapStoreConfig(mapStoreConfig);
  HazelcastInstance instance=Hazelcast.newHazelcastInstance(config);
  HazelcastInstance instance2=Hazelcast.newHazelcastInstance(config);
  final IMap map=instance.getMap("String_Node_Str");
  for (int i=0; i < 1000; i++) {
    map.put(i,i);
  }
  for (int i=10000; i < 10100; i++) {
    map.get(i);
  }
  assertEquals(1000,map.values().size());
}

Fixed version (ground truth):
@Test public void testIssue1019(){
  Config config=new Config();
  MapStoreConfig mapStoreConfig=new MapStoreConfig();
  mapStoreConfig.setImplementation(new MapStoreAdapter<String,String>());
  config.getMapConfig("String_Node_Str").setMapStoreConfig(mapStoreConfig);
  TestHazelcastInstanceFactory nodeFactory=createHazelcastInstanceFactory(2);
  HazelcastInstance instance=nodeFactory.newHazelcastInstance(config);
  HazelcastInstance instance2=nodeFactory.newHazelcastInstance(config);
  final IMap map=instance.getMap("String_Node_Str");
  for (int i=0; i < 1000; i++) {
    map.put(i,i);
  }
  for (int i=10000; i < 10100; i++) {
    map.get(i);
  }
  assertEquals(1000,map.values().size());
}
Program: 48798
Project: 48798
Buggy source:
/** 
 * Iterates through all bundles to get the available @link ScriptEngineFactory classes
 * @return the names of the available ScriptEngineFactory classes
 * @throws IOException
 */
private List<String> findFactoryCandidates(BundleContext context) throws IOException {
  Bundle[] bundles=context.getBundles();
  List<String> factoryCandidates=new ArrayList<String>();
  for (  Bundle bundle : bundles) {
    System.out.println(bundle.getSymbolicName());
    if (bundle.getSymbolicName().equals("String_Node_Str"))     continue;
    Enumeration urls=bundle.findEntries("String_Node_Str","String_Node_Str",false);
    if (urls == null)     continue;
    while (urls.hasMoreElements()) {
      URL u=(URL)urls.nextElement();
      BufferedReader reader=new BufferedReader(new InputStreamReader(u.openStream()));
      String line;
      while ((line=reader.readLine()) != null) {
        factoryCandidates.add(line.trim());
      }
    }
  }
  factoryCandidates.add("String_Node_Str");
  return factoryCandidates;
}

Fixed version (ground truth):
/** 
 * Iterates through all bundles to get the available @link ScriptEngineFactory classes
 * @return the names of the available ScriptEngineFactory classes
 * @throws IOException
 */
private List<String> findFactoryCandidates(BundleContext context) throws IOException {
  Bundle[] bundles=context.getBundles();
  List<String> factoryCandidates=new ArrayList<String>();
  for (  Bundle bundle : bundles) {
    if (bundle.getSymbolicName().equals("String_Node_Str"))     continue;
    Enumeration urls=bundle.findEntries("String_Node_Str","String_Node_Str",false);
    if (urls == null)     continue;
    while (urls.hasMoreElements()) {
      URL u=(URL)urls.nextElement();
      BufferedReader reader=new BufferedReader(new InputStreamReader(u.openStream()));
      String line;
      while ((line=reader.readLine()) != null) {
        factoryCandidates.add(line.trim());
      }
    }
  }
  factoryCandidates.add("String_Node_Str");
  return factoryCandidates;
}
Program: 48799
Project: 48799
Buggy source:
private Map<ScriptEngineManager,ClassLoader> findManagers(BundleContext context){
  Map<ScriptEngineManager,ClassLoader> managers=new HashMap<ScriptEngineManager,ClassLoader>();
  try {
    for (    String factoryName : findFactoryCandidates(context)) {
      ClassLoader factoryLoader=Class.forName(factoryName).getClassLoader();
      ScriptEngineManager manager=new ScriptEngineManager(factoryLoader);
      manager.setBindings(bindings);
      managers.put(manager,factoryLoader);
    }
    return managers;
  }
 catch (  IOException ioe) {
    throw new RuntimeException(ioe);
  }
catch (  ClassNotFoundException cnfe) {
    throw new RuntimeException(cnfe);
  }
}

Fixed version (ground truth):
private Map<ScriptEngineManager,ClassLoader> findManagers(BundleContext context){
  Map<ScriptEngineManager,ClassLoader> managers=new HashMap<ScriptEngineManager,ClassLoader>();
  try {
    for (    String factoryName : findFactoryCandidates(context)) {
      ClassLoader factoryLoader;
      try {
        factoryLoader=Class.forName(factoryName).getClassLoader();
      }
 catch (      ClassNotFoundException cnfe) {
        logger.warning("String_Node_Str" + factoryName + "String_Node_Str"+ cnfe);
        if (logger.isFinestEnabled()) {
          logger.finest(cnfe);
        }
        continue;
      }
      ScriptEngineManager manager=new ScriptEngineManager(factoryLoader);
      manager.setBindings(bindings);
      managers.put(manager,factoryLoader);
    }
    return managers;
  }
 catch (  IOException ioe) {
    throw new RuntimeException(ioe);
  }
}
Program: 48800
Project: 48800
Buggy source:
public void init(boolean fromBackup){
  if (!fromBackup && store.isEnabled()) {
    Set<Long> keys=store.loadAllKeys();
    if (keys != null) {
      for (      Long key : keys) {
        QueueItem item=new QueueItem(this,key,null);
        getItemQueue().offer(item);
        nextId();
      }
    }
  }
}

Fixed version (ground truth):
public void init(boolean fromBackup){
  if (!fromBackup && store.isEnabled()) {
    Set<Long> keys=store.loadAllKeys();
    if (keys != null) {
      long maxId=-1;
      for (      Long key : keys) {
        QueueItem item=new QueueItem(this,key,null);
        getItemQueue().offer(item);
        maxId=Math.max(maxId,key);
      }
      idGenerator=maxId;
    }
  }
}
Program: 48801
Project: 48801
Buggy source:
public void init(boolean fromBackup){
  if (!fromBackup && store.isEnabled()) {
    Set<Long> keys=store.loadAllKeys();
    if (keys != null) {
      for (      Long key : keys) {
        QueueItem item=new QueueItem(this,key,null);
        getItemQueue().offer(item);
        nextId();
      }
    }
  }
}

Fixed version (ground truth):
public void init(boolean fromBackup){
  if (!fromBackup && store.isEnabled()) {
    Set<Long> keys=store.loadAllKeys();
    if (keys != null) {
      long maxId=-1;
      for (      Long key : keys) {
        QueueItem item=new QueueItem(this,key,null);
        getItemQueue().offer(item);
        maxId=Math.max(maxId,key);
      }
      idGenerator=maxId;
    }
  }
}
Program: 48802
Project: 48802
Buggy source:
public Set<MonitoredThread> getStats(){
  try {
    Set<MonitoredThread> monitoredThreads=new TreeSet<MonitoredThread>();
    int count=threadGroup.activeCount();
    Thread[] threads=new Thread[count];
    threadGroup.enumerate(threads);
    long now=System.nanoTime();
    for (    Thread thread : threads) {
      ThreadCpuInfo t=knownThreads.get(thread.getId());
      if (t == null) {
        t=new ThreadCpuInfo(thread);
        knownThreads.putIfAbsent(thread.getId(),t);
      }
      int percentage=(int)((t.setNewValue(threadMXBean.getThreadCpuTime(thread.getId()),now)) * 100);
      monitoredThreads.add(new MonitoredThread(thread.getName(),thread.getId(),percentage));
    }
    return monitoredThreads;
  }
 catch (  Exception e) {
    return null;
  }
}

Fixed version (ground truth):
public Set<MonitoredThread> getStats(){
  try {
    Set<MonitoredThread> monitoredThreads=new TreeSet<MonitoredThread>();
    int count=threadGroup.activeCount();
    Thread[] threads=new Thread[count];
    threadGroup.enumerate(threads);
    long now=System.nanoTime();
    for (    Thread thread : threads) {
      final ThreadCpuInfo t=ConcurrencyUtil.getOrPutIfAbsent(knownThreads,thread.getId(),new ThreadCpuInfoConstructor(thread));
      int percentage=(int)((t.setNewValue(threadMXBean.getThreadCpuTime(thread.getId()),now)) * 100);
      monitoredThreads.add(new MonitoredThread(thread.getName(),thread.getId(),percentage));
    }
    return monitoredThreads;
  }
 catch (  Exception e) {
    return null;
  }
}
Program: 48804
Project: 48804
Buggy source:
@Test public void testIssue1019(){
}

Fixed version (ground truth):
@Test public void testIssue1019() throws InterruptedException {
}
Program: 48806
Project: 48806
Buggy source:
@Test public void testIssue1110() throws InterruptedException {
  final int mapSize=10000;
  final String mapName="String_Node_Str";
  TestHazelcastInstanceFactory nodeFactory=createHazelcastInstanceFactory(2);
  Config cfg=new Config();
  cfg.setProperty(GroupProperties.PROP_MAP_LOAD_CHUNK_SIZE,"String_Node_Str");
  MapStoreConfig mapStoreConfig=new MapStoreConfig();
  mapStoreConfig.setEnabled(true);
  mapStoreConfig.setImplementation(new SimpleMapLoader(mapSize));
  cfg.getMapConfig(mapName).setMapStoreConfig(mapStoreConfig);
  HazelcastInstance instance1=nodeFactory.newHazelcastInstance(cfg);
  HazelcastInstance instance2=nodeFactory.newHazelcastInstance(cfg);
  IMap map=instance1.getMap(mapName);
  final CountDownLatch latch=new CountDownLatch(mapSize);
  map.addEntryListener(new EntryListener(){
    @Override public void entryAdded(    EntryEvent event){
      latch.countDown();
    }
    @Override public void entryRemoved(    EntryEvent event){
    }
    @Override public void entryUpdated(    EntryEvent event){
    }
    @Override public void entryEvicted(    EntryEvent event){
    }
  }
,true);
  map.size();
  latch.await();
  assertEquals(mapSize,map.size());
}

Fixed version (ground truth):
@Test public void testIssue1110() throws InterruptedException {
  final int mapSize=10;
  final String mapName="String_Node_Str";
  TestHazelcastInstanceFactory nodeFactory=createHazelcastInstanceFactory(2);
  Config cfg=new Config();
  cfg.setProperty(GroupProperties.PROP_MAP_LOAD_CHUNK_SIZE,"String_Node_Str");
  MapStoreConfig mapStoreConfig=new MapStoreConfig();
  mapStoreConfig.setEnabled(true);
  mapStoreConfig.setImplementation(new SimpleMapLoader(mapSize));
  cfg.getMapConfig(mapName).setMapStoreConfig(mapStoreConfig);
  HazelcastInstance instance1=nodeFactory.newHazelcastInstance(cfg);
  HazelcastInstance instance2=nodeFactory.newHazelcastInstance(cfg);
  IMap map=instance1.getMap(mapName);
  final CountDownLatch latch=new CountDownLatch(mapSize);
  map.addEntryListener(new EntryListener(){
    @Override public void entryAdded(    EntryEvent event){
      latch.countDown();
    }
    @Override public void entryRemoved(    EntryEvent event){
    }
    @Override public void entryUpdated(    EntryEvent event){
    }
    @Override public void entryEvicted(    EntryEvent event){
    }
  }
,true);
  map.size();
  latch.await();
  assertEquals(mapSize,map.size());
}
Program: 48808
Project: 48808
Buggy source:
@Test public void testIssue1019(){
}

Fixed version (ground truth):
@Test public void testIssue1019() throws InterruptedException {
}
Program: 48810
Project: 48810
Buggy source:
@Test public void testIssue1110() throws InterruptedException {
  final int mapSize=10000;
  final String mapName="String_Node_Str";
  TestHazelcastInstanceFactory nodeFactory=createHazelcastInstanceFactory(2);
  Config cfg=new Config();
  cfg.setProperty(GroupProperties.PROP_MAP_LOAD_CHUNK_SIZE,"String_Node_Str");
  MapStoreConfig mapStoreConfig=new MapStoreConfig();
  mapStoreConfig.setEnabled(true);
  mapStoreConfig.setImplementation(new SimpleMapLoader(mapSize));
  cfg.getMapConfig(mapName).setMapStoreConfig(mapStoreConfig);
  HazelcastInstance instance1=nodeFactory.newHazelcastInstance(cfg);
  HazelcastInstance instance2=nodeFactory.newHazelcastInstance(cfg);
  IMap map=instance1.getMap(mapName);
  final CountDownLatch latch=new CountDownLatch(mapSize);
  map.addEntryListener(new EntryListener(){
    @Override public void entryAdded(    EntryEvent event){
      latch.countDown();
    }
    @Override public void entryRemoved(    EntryEvent event){
    }
    @Override public void entryUpdated(    EntryEvent event){
    }
    @Override public void entryEvicted(    EntryEvent event){
    }
  }
,true);
  map.size();
  latch.await();
  assertEquals(mapSize,map.size());
}

Fixed version (ground truth):
@Test public void testIssue1110() throws InterruptedException {
  final int mapSize=10;
  final String mapName="String_Node_Str";
  TestHazelcastInstanceFactory nodeFactory=createHazelcastInstanceFactory(2);
  Config cfg=new Config();
  cfg.setProperty(GroupProperties.PROP_MAP_LOAD_CHUNK_SIZE,"String_Node_Str");
  MapStoreConfig mapStoreConfig=new MapStoreConfig();
  mapStoreConfig.setEnabled(true);
  mapStoreConfig.setImplementation(new SimpleMapLoader(mapSize));
  cfg.getMapConfig(mapName).setMapStoreConfig(mapStoreConfig);
  HazelcastInstance instance1=nodeFactory.newHazelcastInstance(cfg);
  HazelcastInstance instance2=nodeFactory.newHazelcastInstance(cfg);
  IMap map=instance1.getMap(mapName);
  final CountDownLatch latch=new CountDownLatch(mapSize);
  map.addEntryListener(new EntryListener(){
    @Override public void entryAdded(    EntryEvent event){
      latch.countDown();
    }
    @Override public void entryRemoved(    EntryEvent event){
    }
    @Override public void entryUpdated(    EntryEvent event){
    }
    @Override public void entryEvicted(    EntryEvent event){
    }
  }
,true);
  map.size();
  latch.await();
  assertEquals(mapSize,map.size());
}
Program: 48811
Project: 48811
Buggy source:
public Object getKey(){
  return key;
}

Fixed version (ground truth):
public Data getKey(){
  return key;
}
Program: 48812
Project: 48812
Buggy source:
public boolean eval(Object arg){
  return (key == null || key.equals(arg)) && predicate.apply((Map.Entry)arg);
}

Fixed version (ground truth):
public boolean eval(Object arg){
  final QueryEntry entry=(QueryEntry)arg;
  final Data keyData=entry.getKeyData();
  return (key == null || key.equals(keyData)) && predicate.apply((Map.Entry)arg);
}
Program: 48813
Project: 48813
Buggy source:
public void readPortable(PortableReader reader) throws IOException {
  name=reader.readUTF("String_Node_Str");
  includeValue=reader.readBoolean("String_Node_Str");
  boolean hasKey=reader.readBoolean("String_Node_Str");
  if (reader.readBoolean("String_Node_Str")) {
    final ObjectDataInput in=reader.getRawDataInput();
    predicate=in.readObject();
    if (hasKey) {
      key=in.readObject();
    }
  }
 else   if (hasKey) {
    final ObjectDataInput in=reader.getRawDataInput();
    key=in.readObject();
  }
}

Fixed version (ground truth):
public void readPortable(PortableReader reader) throws IOException {
  name=reader.readUTF("String_Node_Str");
  includeValue=reader.readBoolean("String_Node_Str");
  boolean hasKey=reader.readBoolean("String_Node_Str");
  if (reader.readBoolean("String_Node_Str")) {
    final ObjectDataInput in=reader.getRawDataInput();
    predicate=in.readObject();
    if (hasKey) {
      key=new Data();
      key.readData(in);
    }
  }
 else   if (hasKey) {
    final ObjectDataInput in=reader.getRawDataInput();
    key=new Data();
    key.readData(in);
  }
}
Program: 48814
Project: 48814
Buggy source:
public Object getKey(){
  return key;
}

Fixed version (ground truth):
public Data getKey(){
  return key;
}
Program: 48815
Project: 48815
Buggy source:
public boolean eval(Object arg){
  return (key == null || key.equals(arg)) && predicate.apply((Map.Entry)arg);
}

Fixed version (ground truth):
public boolean eval(Object arg){
  final QueryEntry entry=(QueryEntry)arg;
  final Data keyData=entry.getKeyData();
  return (key == null || key.equals(keyData)) && predicate.apply((Map.Entry)arg);
}
Program: 48816
Project: 48816
Buggy source:
private void cancelAssociatedSchedulers(Data key){
  mapContainer.getIdleEvictionScheduler().cancel(key);
  mapContainer.getTtlEvictionScheduler().cancel(key);
}

Fixed version (ground truth):
private void cancelAssociatedSchedulers(Set<Data> keySet){
  if (keySet == null || keySet.isEmpty())   return;
  for (  Data key : keySet) {
    cancelAssociatedSchedulers(key);
  }
}
Program: 48817
Project: 48817
Buggy source:
public void clear(){
  final LockService lockService=mapService.getNodeEngine().getSharedService(LockService.SERVICE_NAME);
  if (lockService != null) {
    lockService.clearLockStore(partitionId,new DefaultObjectNamespace(MapService.SERVICE_NAME,name));
  }
  final IndexService indexService=mapContainer.getIndexService();
  if (indexService.hasIndex()) {
    for (    Data key : records.keySet()) {
      indexService.removeEntryIndex(key);
    }
  }
  clearRecordsMap(Collections.<Data,Record>emptyMap());
  resetSizeEstimator();
}

Fixed version (ground truth):
public void clear(){
  final LockService lockService=mapService.getNodeEngine().getSharedService(LockService.SERVICE_NAME);
  if (lockService != null) {
    lockService.clearLockStore(partitionId,new DefaultObjectNamespace(MapService.SERVICE_NAME,name));
  }
  final IndexService indexService=mapContainer.getIndexService();
  if (indexService.hasIndex()) {
    for (    Data key : records.keySet()) {
      indexService.removeEntryIndex(key);
    }
  }
  clearRecordsMap(Collections.<Data,Record>emptyMap());
  resetSizeEstimator();
  cancelAssociatedSchedulers(records.keySet());
}
Program: 48818
Project: 48818
Buggy source:
public Object evict(Data dataKey){
  checkIfLoaded();
  Record record=records.get(dataKey);
  Object oldValue=null;
  if (record != null) {
    flush(dataKey);
    mapService.interceptRemove(name,record.getValue());
    oldValue=record.getValue();
    deleteRecord(dataKey);
    updateSizeEstimator(-calculateRecordSize(record));
    removeIndex(dataKey);
  }
  return oldValue;
}

Fixed version (ground truth):
public Object evict(Data dataKey){
  checkIfLoaded();
  Record record=records.get(dataKey);
  Object oldValue=null;
  if (record != null) {
    flush(dataKey);
    mapService.interceptRemove(name,record.getValue());
    oldValue=record.getValue();
    deleteRecord(dataKey);
    updateSizeEstimator(-calculateRecordSize(record));
    removeIndex(dataKey);
    cancelAssociatedSchedulers(dataKey);
  }
  return oldValue;
}
Program: 48819
Project: 48819
Buggy source:
public void reset(){
  checkIfLoaded();
  clearRecordsMap(Collections.<Data,Record>emptyMap());
  resetSizeEstimator();
}

Fixed version (ground truth):
public void reset(){
  checkIfLoaded();
  clearRecordsMap(Collections.<Data,Record>emptyMap());
  resetSizeEstimator();
  cancelAllSchedulers();
}
Program: 48820
Project: 48820
Buggy source:
public boolean remove(Data dataKey,Object testValue){
  checkIfLoaded();
  Record record=records.get(dataKey);
  Object oldValue=null;
  boolean removed=false;
  if (record == null) {
    if (mapContainer.getStore() != null) {
      oldValue=mapContainer.getStore().load(mapService.toObject(dataKey));
    }
    if (oldValue == null)     return false;
  }
 else {
    oldValue=record.getValue();
  }
  if (mapService.compare(name,testValue,oldValue)) {
    mapService.interceptRemove(name,oldValue);
    removeIndex(dataKey);
    mapStoreDelete(record,dataKey);
    deleteRecord(dataKey);
    updateSizeEstimator(-calculateRecordSize(record));
    removed=true;
  }
  return removed;
}

Fixed version (ground truth):
public boolean remove(Data dataKey,Object testValue){
  checkIfLoaded();
  Record record=records.get(dataKey);
  Object oldValue=null;
  boolean removed=false;
  if (record == null) {
    if (mapContainer.getStore() != null) {
      oldValue=mapContainer.getStore().load(mapService.toObject(dataKey));
    }
    if (oldValue == null)     return false;
  }
 else {
    oldValue=record.getValue();
  }
  if (mapService.compare(name,testValue,oldValue)) {
    mapService.interceptRemove(name,oldValue);
    removeIndex(dataKey);
    mapStoreDelete(record,dataKey);
    deleteRecord(dataKey);
    updateSizeEstimator(-calculateRecordSize(record));
    cancelAssociatedSchedulers(dataKey);
    removed=true;
  }
  return removed;
}
Program: 48821
Project: 48821
Buggy source:
public void clear(){
  checkIfLoaded();
  resetSizeEstimator();
  final Collection<Data> lockedKeys=lockStore != null ? lockStore.getLockedKeys() : Collections.<Data>emptySet();
  final Map<Data,Record> lockedRecords=new HashMap<Data,Record>(lockedKeys.size());
  for (  Data key : lockedKeys) {
    Record record=records.get(key);
    if (record != null) {
      lockedRecords.put(key,record);
      updateSizeEstimator(calculateRecordSize(record));
    }
  }
  Set<Data> keysToDelete=records.keySet();
  keysToDelete.removeAll(lockedRecords.keySet());
  final MapStoreWrapper store=mapContainer.getStore();
  Set<Object> keysObject=new HashSet<Object>();
  for (  Data key : keysToDelete) {
    removeIndex(key);
    keysObject.add(mapService.toObject(key));
  }
  if (store != null) {
    store.deleteAll(keysObject);
    toBeRemovedKeys.removeAll(keysToDelete);
  }
  clearRecordsMap(lockedRecords);
}

Fixed version (ground truth):
public void clear(){
  checkIfLoaded();
  resetSizeEstimator();
  final Collection<Data> lockedKeys=lockStore != null ? lockStore.getLockedKeys() : Collections.<Data>emptySet();
  final Map<Data,Record> lockedRecords=new HashMap<Data,Record>(lockedKeys.size());
  for (  Data key : lockedKeys) {
    Record record=records.get(key);
    if (record != null) {
      lockedRecords.put(key,record);
      updateSizeEstimator(calculateRecordSize(record));
    }
  }
  Set<Data> keysToDelete=records.keySet();
  keysToDelete.removeAll(lockedRecords.keySet());
  final MapStoreWrapper store=mapContainer.getStore();
  Set<Object> keysObject=new HashSet<Object>();
  for (  Data key : keysToDelete) {
    removeIndex(key);
    keysObject.add(mapService.toObject(key));
  }
  if (store != null) {
    store.deleteAll(keysObject);
    toBeRemovedKeys.removeAll(keysToDelete);
  }
  clearRecordsMap(lockedRecords);
  cancelAllSchedulers();
}
Program: 48822
Project: 48822
Buggy source:
public void clearPartition(){
  final LockService lockService=mapService.getNodeEngine().getSharedService(LockService.SERVICE_NAME);
  if (lockService != null) {
    lockService.clearLockStore(partitionId,new DefaultObjectNamespace(MapService.SERVICE_NAME,name));
  }
  final IndexService indexService=mapContainer.getIndexService();
  if (indexService.hasIndex()) {
    for (    Data key : records.keySet()) {
      indexService.removeEntryIndex(key);
    }
  }
  clearRecordsMap(Collections.<Data,Record>emptyMap());
  resetSizeEstimator();
}

Fixed version (ground truth):
public void clearPartition(){
  final LockService lockService=mapService.getNodeEngine().getSharedService(LockService.SERVICE_NAME);
  if (lockService != null) {
    lockService.clearLockStore(partitionId,new DefaultObjectNamespace(MapService.SERVICE_NAME,name));
  }
  final IndexService indexService=mapContainer.getIndexService();
  if (indexService.hasIndex()) {
    for (    Data key : records.keySet()) {
      indexService.removeEntryIndex(key);
    }
  }
  clearRecordsMap(Collections.<Data,Record>emptyMap());
  resetSizeEstimator();
  cancelAssociatedSchedulers(records.keySet());
}
Program: 48823
Project: 48823
Buggy source:
private void cancelAssociatedSchedulers(Data key){
  mapContainer.getIdleEvictionScheduler().cancel(key);
  mapContainer.getTtlEvictionScheduler().cancel(key);
}

Fixed version (ground truth):
private void cancelAssociatedSchedulers(Set<Data> keySet){
  if (keySet == null || keySet.isEmpty())   return;
  for (  Data key : keySet) {
    cancelAssociatedSchedulers(key);
  }
}
Program: 48824
Project: 48824
Buggy source:
public Object evict(Data dataKey){
  checkIfLoaded();
  Record record=records.get(dataKey);
  Object oldValue=null;
  if (record != null) {
    flush(dataKey);
    mapService.interceptRemove(name,record.getValue());
    oldValue=record.getValue();
    deleteRecord(dataKey);
    updateSizeEstimator(-calculateRecordSize(record));
    removeIndex(dataKey);
  }
  return oldValue;
}

Fixed version (ground truth):
public Object evict(Data dataKey){
  checkIfLoaded();
  Record record=records.get(dataKey);
  Object oldValue=null;
  if (record != null) {
    flush(dataKey);
    mapService.interceptRemove(name,record.getValue());
    oldValue=record.getValue();
    deleteRecord(dataKey);
    updateSizeEstimator(-calculateRecordSize(record));
    removeIndex(dataKey);
    cancelAssociatedSchedulers(dataKey);
  }
  return oldValue;
}
Program: 48825
Project: 48825
Buggy source:
public void removeAll(){
  checkIfLoaded();
  resetSizeEstimator();
  final Collection<Data> lockedKeys=lockStore != null ? lockStore.getLockedKeys() : Collections.<Data>emptySet();
  final Map<Data,Record> lockedRecords=new HashMap<Data,Record>(lockedKeys.size());
  for (  Data key : lockedKeys) {
    Record record=records.get(key);
    if (record != null) {
      lockedRecords.put(key,record);
      updateSizeEstimator(calculateRecordSize(record));
    }
  }
  Set<Data> keysToDelete=records.keySet();
  keysToDelete.removeAll(lockedRecords.keySet());
  final MapStoreWrapper store=mapContainer.getStore();
  Set<Object> keysObject=new HashSet<Object>();
  for (  Data key : keysToDelete) {
    removeIndex(key);
    keysObject.add(mapService.toObject(key));
  }
  if (store != null) {
    store.deleteAll(keysObject);
    toBeRemovedKeys.removeAll(keysToDelete);
  }
  clearRecordsMap(lockedRecords);
}

Fixed version (ground truth):
public void removeAll(){
  checkIfLoaded();
  resetSizeEstimator();
  final Collection<Data> lockedKeys=lockStore != null ? lockStore.getLockedKeys() : Collections.<Data>emptySet();
  final Map<Data,Record> lockedRecords=new HashMap<Data,Record>(lockedKeys.size());
  for (  Data key : lockedKeys) {
    Record record=records.get(key);
    if (record != null) {
      lockedRecords.put(key,record);
      updateSizeEstimator(calculateRecordSize(record));
    }
  }
  Set<Data> keysToDelete=records.keySet();
  keysToDelete.removeAll(lockedRecords.keySet());
  final MapStoreWrapper store=mapContainer.getStore();
  Set<Object> keysObject=new HashSet<Object>();
  for (  Data key : keysToDelete) {
    removeIndex(key);
    keysObject.add(mapService.toObject(key));
  }
  if (store != null) {
    store.deleteAll(keysObject);
    toBeRemovedKeys.removeAll(keysToDelete);
  }
  clearRecordsMap(lockedRecords);
  cancelAllSchedulers();
}
Program: 48826
Project: 48826
Buggy source:
public void reset(){
  checkIfLoaded();
  clearRecordsMap(Collections.<Data,Record>emptyMap());
  resetSizeEstimator();
}

Fixed version (ground truth):
public void reset(){
  checkIfLoaded();
  clearRecordsMap(Collections.<Data,Record>emptyMap());
  resetSizeEstimator();
  cancelAllSchedulers();
}
Program: 48827
Project: 48827
Buggy source:
public boolean remove(Data dataKey,Object testValue){
  checkIfLoaded();
  Record record=records.get(dataKey);
  Object oldValue=null;
  boolean removed=false;
  if (record == null) {
    if (mapContainer.getStore() != null) {
      oldValue=mapContainer.getStore().load(mapService.toObject(dataKey));
    }
    if (oldValue == null)     return false;
  }
 else {
    oldValue=record.getValue();
  }
  if (mapService.compare(name,testValue,oldValue)) {
    mapService.interceptRemove(name,oldValue);
    removeIndex(dataKey);
    mapStoreDelete(record,dataKey);
    deleteRecord(dataKey);
    updateSizeEstimator(-calculateRecordSize(record));
    removed=true;
  }
  return removed;
}

Fixed version (ground truth):
public boolean remove(Data dataKey,Object testValue){
  checkIfLoaded();
  Record record=records.get(dataKey);
  Object oldValue=null;
  boolean removed=false;
  if (record == null) {
    if (mapContainer.getStore() != null) {
      oldValue=mapContainer.getStore().load(mapService.toObject(dataKey));
    }
    if (oldValue == null)     return false;
  }
 else {
    oldValue=record.getValue();
  }
  if (mapService.compare(name,testValue,oldValue)) {
    mapService.interceptRemove(name,oldValue);
    removeIndex(dataKey);
    mapStoreDelete(record,dataKey);
    deleteRecord(dataKey);
    updateSizeEstimator(-calculateRecordSize(record));
    cancelAssociatedSchedulers(dataKey);
    removed=true;
  }
  return removed;
}
Program: 48829
Project: 48829
Buggy source:
public boolean init(int permitCount){
  if (available != 0) {
    return false;
  }
  available=permitCount;
  return true;
}

Fixed version (ground truth):
public boolean init(int permitCount){
  if (initialized || available != 0) {
    return false;
  }
  available=permitCount;
  initialized=true;
  return true;
}
Program: 48830
Project: 48830
Buggy source:
public void readData(ObjectDataInput in) throws IOException {
  available=in.readInt();
  partitionId=in.readInt();
  backupCount=in.readInt();
  asyncBackupCount=in.readInt();
  int size=in.readInt();
  attachMap=new HashMap<String,Integer>(size);
  for (int i=0; i < size; i++) {
    String caller=in.readUTF();
    Integer val=in.readInt();
    attachMap.put(caller,val);
  }
}

Fixed version (ground truth):
public void readData(ObjectDataInput in) throws IOException {
  initialized=in.readBoolean();
  available=in.readInt();
  partitionId=in.readInt();
  backupCount=in.readInt();
  asyncBackupCount=in.readInt();
  int size=in.readInt();
  attachMap=new HashMap<String,Integer>(size);
  for (int i=0; i < size; i++) {
    String caller=in.readUTF();
    Integer val=in.readInt();
    attachMap.put(caller,val);
  }
}
Program: 48831
Project: 48831
Buggy source:
public void writeData(ObjectDataOutput out) throws IOException {
  out.writeInt(available);
  out.writeInt(partitionId);
  out.writeInt(backupCount);
  out.writeInt(asyncBackupCount);
  out.writeInt(attachMap.size());
  for (  Map.Entry<String,Integer> entry : attachMap.entrySet()) {
    out.writeUTF(entry.getKey());
    out.writeInt(entry.getValue());
  }
}

Fixed version (ground truth):
public void writeData(ObjectDataOutput out) throws IOException {
  out.writeBoolean(initialized);
  out.writeInt(available);
  out.writeInt(partitionId);
  out.writeInt(backupCount);
  out.writeInt(asyncBackupCount);
  out.writeInt(attachMap.size());
  for (  Map.Entry<String,Integer> entry : attachMap.entrySet()) {
    out.writeUTF(entry.getKey());
    out.writeInt(entry.getValue());
  }
}
Program: 48832
Project: 48832
Buggy source:
@Test public void testSemaphoreWithFailuresAndJoin(){
  final Config config=new Config();
  final TestHazelcastInstanceFactory factory=createHazelcastInstanceFactory(3);
  final HazelcastInstance instance1=factory.newHazelcastInstance(config);
  final HazelcastInstance instance2=factory.newHazelcastInstance(config);
  final ISemaphore semaphore=instance1.getSemaphore("String_Node_Str");
  final CountDownLatch countDownLatch=new CountDownLatch(1);
  Assert.assertTrue(semaphore.init(0));
  final Thread thread=new Thread(){
    public void run(){
      for (int i=0; i < 2; i++) {
        try {
          semaphore.acquire();
        }
 catch (        InterruptedException e) {
          e.printStackTrace();
        }
      }
      countDownLatch.countDown();
    }
  }
;
  thread.start();
  instance2.getLifecycleService().shutdown();
  semaphore.release();
  HazelcastInstance instance3=factory.newHazelcastInstance(config);
  ISemaphore semaphore1=instance3.getSemaphore("String_Node_Str");
  semaphore1.release();
  try {
    Assert.assertTrue(countDownLatch.await(15,TimeUnit.SECONDS));
  }
 catch (  InterruptedException e) {
    e.printStackTrace();
  }
 finally {
    thread.interrupt();
  }
}

Fixed version (ground truth):
@Test public void testSemaphoreWithFailuresAndJoin(){
  final Config config=new Config();
  final TestHazelcastInstanceFactory factory=createHazelcastInstanceFactory(3);
  final HazelcastInstance instance1=factory.newHazelcastInstance(config);
  final HazelcastInstance instance2=factory.newHazelcastInstance(config);
  final ISemaphore semaphore=instance1.getSemaphore("String_Node_Str");
  final CountDownLatch countDownLatch=new CountDownLatch(1);
  assertTrue(semaphore.init(0));
  final Thread thread=new Thread(){
    public void run(){
      for (int i=0; i < 2; i++) {
        try {
          semaphore.acquire();
        }
 catch (        InterruptedException e) {
          e.printStackTrace();
        }
      }
      countDownLatch.countDown();
    }
  }
;
  thread.start();
  instance2.getLifecycleService().shutdown();
  semaphore.release();
  HazelcastInstance instance3=factory.newHazelcastInstance(config);
  ISemaphore semaphore1=instance3.getSemaphore("String_Node_Str");
  semaphore1.release();
  try {
    assertTrue(countDownLatch.await(15,TimeUnit.SECONDS));
  }
 catch (  InterruptedException e) {
    e.printStackTrace();
  }
 finally {
    thread.interrupt();
  }
}
Program: 48833
Project: 48833
Buggy source:
@Test public void testMutex(){
  final int k=5;
  final Config config=new Config();
  TestHazelcastInstanceFactory factory=createHazelcastInstanceFactory(k);
  final HazelcastInstance[] instances=factory.newInstances(config);
  final CountDownLatch latch=new CountDownLatch(k);
  final int loopCount=1000;
class Counter {
    int count=0;
    void inc(){
      count++;
    }
    int get(){
      return count;
    }
  }
  final Counter counter=new Counter();
  Assert.assertTrue(instances[0].getSemaphore("String_Node_Str").init(1));
  for (int i=0; i < k; i++) {
    final ISemaphore semaphore=instances[i].getSemaphore("String_Node_Str");
    new Thread(){
      public void run(){
        for (int j=0; j < loopCount; j++) {
          try {
            semaphore.acquire();
          }
 catch (          InterruptedException e) {
            System.err.println("String_Node_Str" + e.getMessage());
            return;
          }
          try {
            sleep((int)(Math.random() * 3));
            counter.inc();
          }
 catch (          InterruptedException e) {
            return;
          }
 finally {
            semaphore.release();
          }
        }
        latch.countDown();
      }
    }
.start();
  }
  try {
    Assert.assertTrue(latch.await(60,TimeUnit.SECONDS));
    Assert.assertEquals(loopCount * k,counter.get());
  }
 catch (  InterruptedException e) {
    e.printStackTrace();
    Assert.fail(e.getMessage());
  }
}

Fixed version (ground truth):
@Test public void testMutex(){
  final int k=5;
  final Config config=new Config();
  TestHazelcastInstanceFactory factory=createHazelcastInstanceFactory(k);
  final HazelcastInstance[] instances=factory.newInstances(config);
  final CountDownLatch latch=new CountDownLatch(k);
  final int loopCount=1000;
class Counter {
    int count=0;
    void inc(){
      count++;
    }
    int get(){
      return count;
    }
  }
  final Counter counter=new Counter();
  assertTrue(instances[0].getSemaphore("String_Node_Str").init(1));
  for (int i=0; i < k; i++) {
    final ISemaphore semaphore=instances[i].getSemaphore("String_Node_Str");
    new Thread(){
      public void run(){
        for (int j=0; j < loopCount; j++) {
          try {
            semaphore.acquire();
          }
 catch (          InterruptedException e) {
            System.err.println("String_Node_Str" + e.getMessage());
            return;
          }
          try {
            sleep((int)(Math.random() * 3));
            counter.inc();
          }
 catch (          InterruptedException e) {
            return;
          }
 finally {
            semaphore.release();
          }
        }
        latch.countDown();
      }
    }
.start();
  }
  try {
    assertTrue(latch.await(60,TimeUnit.SECONDS));
    Assert.assertEquals(loopCount * k,counter.get());
  }
 catch (  InterruptedException e) {
    e.printStackTrace();
    Assert.fail(e.getMessage());
  }
}
Program: 48835
Project: 48835
Buggy source:
@Override public boolean shouldBackup(){
  return successful;
}

Fixed version (ground truth):
@Override public boolean shouldBackup(){
  return true;
}
Program: 48836
Project: 48836
Buggy source:
@Override public boolean shouldBackup(){
  return successful;
}

Fixed version (ground truth):
@Override public boolean shouldBackup(){
  return true;
}
Program: 48837
Project: 48837
Buggy source:
public boolean init(int permitCount){
  if (available != 0) {
    return false;
  }
  available=permitCount;
  return true;
}

Fixed version (ground truth):
public boolean init(int permitCount){
  if (initialized || available != 0) {
    return false;
  }
  available=permitCount;
  initialized=true;
  return true;
}