nus-yam/ex-repair huggingface dataset:
Program: 49202
Project: 49202
Buggy source:
@Test @ClientCompatibleTest public void testAtomicLongSpawnNodeInParallel(){
  int total=6;
  int parallel=2;
  final TestHazelcastInstanceFactory nodeFactory=createHazelcastInstanceFactory(total + 1);
  final Config config=new Config();
  HazelcastInstance instance=nodeFactory.newHazelcastInstance(config);
  final String name="String_Node_Str";
  IAtomicLong atomicLong=instance.getAtomicLong(name);
  atomicLong.set(100);
  for (int i=0; i < total / parallel; i++) {
    final HazelcastInstance[] instances=new HazelcastInstance[parallel];
    final CountDownLatch countDownLatch=new CountDownLatch(parallel);
    for (int j=0; j < parallel; j++) {
      final int id=j;
      new Thread(){
        public void run(){
          instances[id]=nodeFactory.newHazelcastInstance(config);
          instances[id].getAtomicLong(name).incrementAndGet();
          countDownLatch.countDown();
        }
      }
.start();
    }
    try {
      countDownLatch.await(1,TimeUnit.MINUTES);
    }
 catch (    InterruptedException e) {
      e.printStackTrace();
    }
    IAtomicLong newAtomicLong=instance.getAtomicLong(name);
    Assert.assertEquals((long)100 + (i + 1) * parallel,newAtomicLong.get());
    instance.getLifecycleService().shutdown();
    instance=instances[0];
    for (int j=1; j < parallel; j++) {
      instances[j].getLifecycleService().shutdown();
    }
  }
}

Fixed version (ground truth):
@Test @ClientCompatibleTest public void testAtomicLongSpawnNodeInParallel() throws InterruptedException {
  int total=6;
  int parallel=2;
  final TestHazelcastInstanceFactory nodeFactory=createHazelcastInstanceFactory(total + 1);
  final Config config=new Config();
  HazelcastInstance instance=nodeFactory.newHazelcastInstance(config);
  final String name="String_Node_Str";
  IAtomicLong atomicLong=instance.getAtomicLong(name);
  atomicLong.set(100);
  final ExecutorService ex=Executors.newFixedThreadPool(parallel);
  try {
    for (int i=0; i < total / parallel; i++) {
      final HazelcastInstance[] instances=new HazelcastInstance[parallel];
      final CountDownLatch countDownLatch=new CountDownLatch(parallel);
      for (int j=0; j < parallel; j++) {
        final int id=j;
        ex.execute(new Runnable(){
          public void run(){
            instances[id]=nodeFactory.newHazelcastInstance(config);
            instances[id].getAtomicLong(name).incrementAndGet();
            countDownLatch.countDown();
          }
        }
);
      }
      assertTrue(countDownLatch.await(1,TimeUnit.MINUTES));
      IAtomicLong newAtomicLong=instance.getAtomicLong(name);
      Assert.assertEquals((long)100 + (i + 1) * parallel,newAtomicLong.get());
      instance.getLifecycleService().shutdown();
      instance=instances[0];
    }
  }
  finally {
    ex.shutdownNow();
  }
}
Program: 49203
Project: 49203
Buggy source:
public void run(){
  final HazelcastInstance h=instances[instanceIndex];
  h.getMap("String_Node_Str").size();
  counts.offer(getLocalPartitionsCount(h));
}

Fixed version (ground truth):
public void run(){
  final HazelcastInstance h=instances[instanceIndex];
  try {
    warmUpPartitions(h);
    counts.offer(getLocalPartitionsCount(h));
  }
 catch (  InterruptedException e) {
    e.printStackTrace();
  }
}
Program: 49204
Project: 49204
Buggy source:
private void testPartitionDistribution(final int partitionCount,final int nodeCount) throws InterruptedException {
  final Config config=new Config();
  config.setProperty(GroupProperties.PROP_PARTITION_COUNT,String.valueOf(partitionCount));
  TestHazelcastInstanceFactory factory=createHazelcastInstanceFactory(nodeCount);
  final BlockingQueue<Integer> counts=new ArrayBlockingQueue<Integer>(nodeCount);
  final HazelcastInstance[] instances=new HazelcastInstance[nodeCount];
  for (int i=0; i < nodeCount; i++) {
    instances[i]=factory.newHazelcastInstance(config);
  }
  for (int j=0; j < nodeCount; j++) {
    final int instanceIndex=j;
    new Thread(new Runnable(){
      public void run(){
        final HazelcastInstance h=instances[instanceIndex];
        h.getMap("String_Node_Str").size();
        counts.offer(getLocalPartitionsCount(h));
      }
    }
).start();
  }
  final int average=(partitionCount / nodeCount);
  int total=0;
  for (int i=0; i < nodeCount; i++) {
    final int c=counts.take();
    assertTrue("String_Node_Str" + i + "String_Node_Str"+ c+ "String_Node_Str"+ partitionCount+ "String_Node_Str"+ nodeCount,c >= average);
    total+=c;
  }
  assertEquals(partitionCount,total);
}

Fixed version (ground truth):
private void testPartitionDistribution(final int partitionCount,final int nodeCount) throws InterruptedException {
  final Config config=new Config();
  config.setProperty(GroupProperties.PROP_PARTITION_COUNT,String.valueOf(partitionCount));
  TestHazelcastInstanceFactory factory=createHazelcastInstanceFactory(nodeCount);
  final BlockingQueue<Integer> counts=new ArrayBlockingQueue<Integer>(nodeCount);
  final HazelcastInstance[] instances=new HazelcastInstance[nodeCount];
  for (int i=0; i < nodeCount; i++) {
    instances[i]=factory.newHazelcastInstance(config);
  }
  final ExecutorService ex=Executors.newCachedThreadPool();
  try {
    for (int j=0; j < nodeCount; j++) {
      final int instanceIndex=j;
      new Thread(new Runnable(){
        public void run(){
          final HazelcastInstance h=instances[instanceIndex];
          try {
            warmUpPartitions(h);
            counts.offer(getLocalPartitionsCount(h));
          }
 catch (          InterruptedException e) {
            e.printStackTrace();
          }
        }
      }
).start();
    }
    final int average=(partitionCount / nodeCount);
    int total=0;
    for (int i=0; i < nodeCount; i++) {
      final int c=counts.poll(1,TimeUnit.MINUTES);
      assertTrue("String_Node_Str" + c + "String_Node_Str"+ partitionCount+ "String_Node_Str"+ nodeCount,c >= average);
      total+=c;
    }
    assertEquals(partitionCount,total);
  }
  finally {
    ex.shutdownNow();
  }
}
Program: 49205
Project: 49205
Buggy source:
public void doJoin(AtomicBoolean joined){
  Address master=null;
  for (  Address address : addresses) {
    final NodeEngineImpl nodeEngine=nodes.get(address);
    if (nodeEngine != null && nodeEngine.getNode().isActive()) {
      master=address;
      break;
    }
  }
  node.setMasterAddress(master);
  if (node.getMasterAddress().equals(node.getThisAddress())) {
    node.setJoined();
  }
 else {
    for (int i=0; !node.joined() && i < 1000; i++) {
      try {
        node.clusterService.sendJoinRequest(node.getMasterAddress(),true);
        Thread.sleep(50);
      }
 catch (      InterruptedException e) {
        e.printStackTrace();
      }
    }
    if (!node.joined()) {
      throw new AssertionError("String_Node_Str" + thisAddress + "String_Node_Str"+ node.getMasterAddress());
    }
  }
}

Fixed version (ground truth):
public void doJoin(AtomicBoolean joined){
  NodeEngineImpl nodeEngine=null;
  for (  Address address : addresses) {
    NodeEngineImpl ne=nodes.get(address);
    if (ne != null && ne.getNode().isActive() && ne.getNode().joined()) {
      nodeEngine=ne;
      break;
    }
  }
  Address master=null;
  if (nodeEngine != null) {
    if (nodeEngine.getNode().isMaster()) {
      master=nodeEngine.getThisAddress();
    }
 else {
      master=nodeEngine.getMasterAddress();
    }
  }
  if (master == null) {
    master=node.getThisAddress();
  }
  node.setMasterAddress(master);
  if (node.getMasterAddress().equals(node.getThisAddress())) {
    node.setJoined();
  }
 else {
    for (int i=0; !node.joined() && i < 1000; i++) {
      try {
        node.clusterService.sendJoinRequest(node.getMasterAddress(),true);
        Thread.sleep(50);
      }
 catch (      InterruptedException e) {
        e.printStackTrace();
      }
    }
    if (!node.joined()) {
      throw new AssertionError("String_Node_Str" + thisAddress + "String_Node_Str"+ node.getMasterAddress());
    }
  }
}
Program: 49206
Project: 49206
Buggy source:
@Override public Object getKey(){
  return key;
}

Fixed version (ground truth):
@Override public Object getKey(){
  return new MapKey(name,key);
}
Program: 49207
Project: 49207
Buggy source:
@Test public void testIteratorContract(){
  TestHazelcastInstanceFactory nodeFactory=createHazelcastInstanceFactory(1);
  HazelcastInstance instance=nodeFactory.newHazelcastInstance(new Config());
  final IMap<String,ValueType> map=instance.getMap("String_Node_Str");
  map.put("String_Node_Str",new ValueType("String_Node_Str"));
  map.put("String_Node_Str",new ValueType("String_Node_Str"));
  map.put("String_Node_Str",new ValueType("String_Node_Str"));
  final Predicate predicate=new SqlPredicate("String_Node_Str");
  testIterator(map.keySet().iterator(),3);
  testIterator(map.keySet(predicate).iterator(),2);
  testIterator(map.entrySet().iterator(),3);
  testIterator(map.entrySet(predicate).iterator(),2);
  testIterator(map.values().iterator(),3);
  testIterator(map.values(predicate).iterator(),2);
}

Fixed version (ground truth):
@Test public void testIteratorContract(){
  TestHazelcastInstanceFactory nodeFactory=createHazelcastInstanceFactory(1);
  HazelcastInstance instance=nodeFactory.newHazelcastInstance(new Config());
  final IMap<String,ValueType> map=instance.getMap("String_Node_Str");
  map.put("String_Node_Str",new ValueType("String_Node_Str"));
  map.put("String_Node_Str",new ValueType("String_Node_Str"));
  map.put("String_Node_Str",new ValueType("String_Node_Str"));
  final Predicate predicate=new SqlPredicate("String_Node_Str");
  Collection<ValueType> values=map.values(predicate);
  assertEquals(2,map.values(predicate).size());
  assertEquals(2,map.keySet(predicate).size());
  testIterator(map.keySet().iterator(),3);
  testIterator(map.keySet(predicate).iterator(),2);
  testIterator(map.entrySet().iterator(),3);
  testIterator(map.entrySet(predicate).iterator(),2);
  testIterator(map.values().iterator(),3);
  testIterator(map.values(predicate).iterator(),2);
}
Program: 49208
Project: 49208
Buggy source:
/** 
 * Test for issue 711
 */
@Test public void testPredicateWithEntryKeyObject(){
  Config cfg=new Config();
  TestHazelcastInstanceFactory nodeFactory=createHazelcastInstanceFactory(1);
  HazelcastInstance instance=nodeFactory.newHazelcastInstance(cfg);
  IMap map=instance.getMap("String_Node_Str");
  map.put("String_Node_Str",11);
  map.put("String_Node_Str",22);
  map.put("String_Node_Str",33);
  Predicate predicate=new PredicateBuilder().getEntryObject().key().equal("String_Node_Str");
  assertEquals(1,map.values(predicate).size());
  predicate=new PredicateBuilder().getEntryObject().key().in("String_Node_Str","String_Node_Str");
  assertEquals(2,map.keySet(predicate).size());
}

Fixed version (ground truth):
/** 
 * Test for issue 711
 */
@Test public void testPredicateWithEntryKeyObject(){
  Config cfg=new Config();
  TestHazelcastInstanceFactory nodeFactory=createHazelcastInstanceFactory(1);
  HazelcastInstance instance=nodeFactory.newHazelcastInstance(cfg);
  IMap map=instance.getMap("String_Node_Str");
  map.put("String_Node_Str",11);
  map.put("String_Node_Str",22);
  map.put("String_Node_Str",33);
  map.put("String_Node_Str",44);
  map.put("String_Node_Str",55);
  map.put("String_Node_Str",66);
  Predicate predicate=new PredicateBuilder().getEntryObject().key().equal("String_Node_Str");
  assertEquals(1,map.values(predicate).size());
  predicate=new PredicateBuilder().getEntryObject().key().in("String_Node_Str","String_Node_Str");
  assertEquals(2,map.keySet(predicate).size());
  predicate=new PredicateBuilder().getEntryObject().key().in("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str");
  assertEquals(4,map.keySet(predicate).size());
}
Program: 49209
Project: 49209
Buggy source:
protected Comparable convert(Map.Entry mapEntry,Comparable entryValue,Comparable attributeValue){
  if (attributeValue == null) {
    return null;
  }
  if (attributeType == null) {
    QueryableEntry queryableEntry=(QueryableEntry)mapEntry;
    attributeType=queryableEntry.getAttributeType(attribute);
  }
  if (attributeType == AttributeType.ENUM) {
    return attributeType.getConverter().convert(attributeValue);
  }
 else {
    if (entryValue != null && entryValue.getClass().isAssignableFrom(attributeValue.getClass())) {
      return attributeValue;
    }
 else     if (attributeType != null) {
      return attributeType.getConverter().convert(attributeValue);
    }
 else {
      throw new QueryException("String_Node_Str" + attributeValue.getClass());
    }
  }
}

Fixed version (ground truth):
protected Comparable convert(Map.Entry mapEntry,Comparable entryValue,Comparable attributeValue){
  if (attributeValue == null) {
    return null;
  }
  AttributeType type=attributeType;
  if (type == null) {
    QueryableEntry queryableEntry=(QueryableEntry)mapEntry;
    type=queryableEntry.getAttributeType(attribute);
    attributeType=type;
  }
  if (type == AttributeType.ENUM) {
    return type.getConverter().convert(attributeValue);
  }
 else {
    if (entryValue != null && entryValue.getClass().isAssignableFrom(attributeValue.getClass())) {
      return attributeValue;
    }
 else     if (type != null) {
      return type.getConverter().convert(attributeValue);
    }
 else {
      throw new QueryException("String_Node_Str" + attributeValue.getClass());
    }
  }
}
Program: 49210
Project: 49210
Buggy source:
public void incrementRemoves(long latency){
  removeCount.incrementAndGet();
  maxRemoveLatency.set(Math.max(maxRemoveLatency.get(),latency));
}

Fixed version (ground truth):
public void incrementRemoves(long latency){
  removeCount.incrementAndGet();
  totalRemoveLatencies.addAndGet(latency);
  maxRemoveLatency.set(Math.max(maxRemoveLatency.get(),latency));
}
Program: 49211
Project: 49211
Buggy source:
public boolean checkHeartBeat(final Connection connection){
  if ((Clock.currentTimeMillis() - connection.getLastReadTime()) > connectionTimeout / 2) {
    final CountDownLatch latch=new CountDownLatch(1);
    executionService.execute(new Runnable(){
      public void run(){
        try {
          connection.write(ping);
          latch.countDown();
        }
 catch (        IOException e) {
          e.printStackTrace();
        }
      }
    }
);
    try {
      return latch.await(5,TimeUnit.SECONDS);
    }
 catch (    InterruptedException e) {
      return false;
    }
  }
 else {
    return true;
  }
}

Fixed version (ground truth):
public boolean checkHeartBeat(final Connection connection){
  if ((Clock.currentTimeMillis() - connection.getLastReadTime()) > connectionTimeout / 2) {
    final CountDownLatch latch=new CountDownLatch(1);
    executionService.execute(new Runnable(){
      public void run(){
        try {
          connection.write(ping);
          connection.read();
          latch.countDown();
        }
 catch (        IOException e) {
          e.printStackTrace();
        }
      }
    }
);
    try {
      return latch.await(5,TimeUnit.SECONDS);
    }
 catch (    InterruptedException e) {
      return false;
    }
  }
 else {
    return true;
  }
}
Program: 49212
Project: 49212
Buggy source:
public void run(){
  try {
    connection.write(ping);
    latch.countDown();
  }
 catch (  IOException e) {
    e.printStackTrace();
  }
}

Fixed version (ground truth):
public void run(){
  try {
    connection.write(ping);
    connection.read();
    latch.countDown();
  }
 catch (  IOException e) {
    e.printStackTrace();
  }
}
Program: 49213
Project: 49213
Buggy source:
private void check(Callable task){
  if (task == null) {
    throw new NullPointerException();
  }
  if (isShutdown()) {
    throw new RejectedExecutionException(getRejectionMessage());
  }
}

Fixed version (ground truth):
private void check(Callable task){
  if (task == null) {
    throw new NullPointerException();
  }
}
Program: 49214
Project: 49214
Buggy source:
private void listenMembershipEvents() throws IOException {
  final SerializationService serializationService=getSerializationService();
  while (!Thread.currentThread().isInterrupted()) {
    final Data eventData=conn.read();
    final ClientMembershipEvent event=(ClientMembershipEvent)serializationService.toObject(eventData);
    final MemberImpl member=(MemberImpl)event.getMember();
    if (event.getEventType() == MembershipEvent.MEMBER_ADDED) {
      members.add(member);
    }
 else {
      members.remove(member);
    }
    updateMembersRef();
    getConnectionManager().removeConnectionPool(member.getAddress());
    fireMembershipEvent(event);
  }
}

Fixed version (ground truth):
private void listenMembershipEvents() throws IOException {
  final SerializationService serializationService=getSerializationService();
  while (!Thread.currentThread().isInterrupted()) {
    final Data eventData=conn.read();
    final ClientMembershipEvent event=(ClientMembershipEvent)serializationService.toObject(eventData);
    final MemberImpl member=(MemberImpl)event.getMember();
    if (event.getEventType() == MembershipEvent.MEMBER_ADDED) {
      members.add(member);
    }
 else {
      members.remove(member);
      getConnectionManager().removeConnectionPool(member.getAddress());
    }
    updateMembersRef();
    fireMembershipEvent(event);
  }
}
Program: 49215
Project: 49215
Buggy source:
@Override public int hashCode(){
  return indexKey.hashCode();
}

Fixed version (ground truth):
@Override public int hashCode(){
  return indexKey != null ? indexKey.hashCode() : 0;
}
Program: 49216
Project: 49216
Buggy source:
@Override public boolean equals(Object o){
  if (this == o)   return true;
  if (o == null || getClass() != o.getClass())   return false;
  QueryResultEntryImpl that=(QueryResultEntryImpl)o;
  if (!indexKey.equals(that.indexKey))   return false;
  return true;
}

Fixed version (ground truth):
@Override public boolean equals(Object o){
  if (this == o)   return true;
  if (o == null || getClass() != o.getClass())   return false;
  QueryResultEntryImpl that=(QueryResultEntryImpl)o;
  if (indexKey != null ? !indexKey.equals(that.indexKey) : that.indexKey != null)   return false;
  return true;
}
Program: 49217
Project: 49217
Buggy source:
public synchronized boolean add(QueryResultEntry entry){
  if (!set || keys.add(entry.getIndexKey())) {
    q.offer(entry);
    size++;
    return true;
  }
  return false;
}

Fixed version (ground truth):
public synchronized boolean add(QueryResultEntry entry){
  if (!started) {
    started=true;
  }
  if (!set || keys.add(entry.getIndexKey())) {
    q.offer(entry);
    size++;
    return true;
  }
  return false;
}
Program: 49218
Project: 49218
Buggy source:
@Override public int size(){
synchronized (endLock) {
    while (!ended) {
      try {
        endLock.wait();
      }
 catch (      InterruptedException e) {
        return size;
      }
    }
    return size;
  }
}

Fixed version (ground truth):
@Override public int size(){
  if (!started) {
    return 0;
  }
synchronized (endLock) {
    while (!ended) {
      try {
        endLock.wait();
      }
 catch (      InterruptedException e) {
        return size;
      }
    }
    return size;
  }
}
Program: 49219
Project: 49219
Buggy source:
public static HazelcastInstance newHazelcastClient(ClientConfig config){
  if (config == null) {
    config=new ClientConfig();
  }
  final HazelcastClient client=new HazelcastClient(config);
  final HazelcastClientProxy proxy=new HazelcastClientProxy(client);
  CLIENTS.put(client.id,proxy);
  return proxy;
}

Fixed version (ground truth):
public static HazelcastInstance newHazelcastClient(ClientConfig config){
  if (config == null) {
    config=new XmlClientConfigBuilder().build();
  }
  final HazelcastClient client=new HazelcastClient(config);
  final HazelcastClientProxy proxy=new HazelcastClientProxy(client);
  CLIENTS.put(client.id,proxy);
  return proxy;
}
Program: 49220
Project: 49220
Buggy source:
public ClientClusterServiceImpl(HazelcastClient client){
  this.client=client;
  clusterThread=new ClusterListenerThread(client.getThreadGroup(),client.getName() + "String_Node_Str");
  final ClientConfig clientConfig=getClientConfig();
  redoOperation=clientConfig.isRedoOperation();
  credentials=clientConfig.getCredentials();
  final Collection<EventListener> listeners=client.getClientConfig().getListeners();
  if (listeners != null && !listeners.isEmpty()) {
    for (    EventListener listener : listeners) {
      if (listener instanceof MembershipListener) {
        addMembershipListener((MembershipListener)listener);
      }
    }
  }
}

Fixed version (ground truth):
public ClientClusterServiceImpl(HazelcastClient client){
  this.client=client;
  clusterThread=new ClusterListenerThread(client.getThreadGroup(),client.getName() + "String_Node_Str");
  final ClientConfig clientConfig=getClientConfig();
  redoOperation=clientConfig.isRedoOperation();
  credentials=clientConfig.getCredentials();
  final Collection<EventListener> listenersList=client.getClientConfig().getListeners();
  if (listenersList != null && !listenersList.isEmpty()) {
    for (    EventListener listener : listenersList) {
      if (listener instanceof MembershipListener) {
        addMembershipListener((MembershipListener)listener);
      }
    }
  }
}
Program: 49221
Project: 49221
Buggy source:
public void readData(ObjectDataInput in) throws IOException {
  Member member=new MemberImpl();
  member.readData(in);
}

Fixed version (ground truth):
public void readData(ObjectDataInput in) throws IOException {
  member=new MemberImpl();
  member.readData(in);
}
Program: 49222
Project: 49222
Buggy source:
protected final void invalidateNearCaches(){
  final MapService mapService=getService();
  final MapContainer mapContainer=mapService.getMapContainer(name);
  if (mapContainer.isNearCacheEnabled() && mapContainer.getMapConfig().getNearCacheConfig().isInvalidateOnChange()) {
    mapService.invalidateAllNearCaches(name,dataKey);
  }
}

Fixed version (ground truth):
protected final void invalidateNearCaches(){
  if (mapContainer.isNearCacheEnabled() && mapContainer.getMapConfig().getNearCacheConfig().isInvalidateOnChange()) {
    mapService.invalidateAllNearCaches(name,dataKey);
  }
}
Program: 49223
Project: 49223
Buggy source:
@Override protected Object reduce(Map<Integer,Object> map){
  MapEntrySet resultSet=new MapEntrySet();
  MapService mapService=getService();
  for (  Map.Entry<Integer,Object> entry : map.entrySet()) {
    MapEntrySet mapEntrySet=(MapEntrySet)mapService.toObject(entry.getValue());
    Set<Map.Entry<Data,Data>> entrySet=mapEntrySet.getEntrySet();
    for (    Map.Entry<Data,Data> dataEntry : entrySet) {
      resultSet.add(dataEntry);
    }
  }
  return resultSet;
}

Fixed version (ground truth):
@Override protected Object reduce(Map<Integer,Object> map){
  MapEntrySet resultSet=new MapEntrySet();
  MapService mapService=getService();
  for (  Map.Entry<Integer,Object> entry : map.entrySet()) {
    MapEntrySet mapEntrySet=(MapEntrySet)mapService.toObject(entry.getValue());
    Set<Map.Entry<Data,Data>> set=mapEntrySet.getEntrySet();
    for (    Map.Entry<Data,Data> dataEntry : set) {
      resultSet.add(dataEntry);
    }
  }
  return resultSet;
}
Program: 49224
Project: 49224
Buggy source:
public Map<Long,Data> addAll(Collection<Data> dataList){
  Map<Long,Data> dataMap=new HashMap<Long,Data>(dataList.size());
  for (  Data data : dataList) {
    QueueItem item=new QueueItem(this,nextId(),null);
    if (!store.isEnabled() || store.getMemoryLimit() > getItemQueue().size()) {
      item.setData(data);
    }
    getItemQueue().offer(item);
    dataMap.put(item.getItemId(),data);
  }
  if (store.isEnabled()) {
    try {
      store.storeAll(dataMap);
    }
 catch (    Exception e) {
      for (int i=0; i < dataList.size(); i++) {
        getItemQueue().poll();
      }
      throw new HazelcastException(e);
    }
  }
  return dataMap;
}

Fixed version (ground truth):
public Map<Long,Data> addAll(Collection<Data> dataList){
  Map<Long,Data> map=new HashMap<Long,Data>(dataList.size());
  for (  Data data : dataList) {
    QueueItem item=new QueueItem(this,nextId(),null);
    if (!store.isEnabled() || store.getMemoryLimit() > getItemQueue().size()) {
      item.setData(data);
    }
    getItemQueue().offer(item);
    map.put(item.getItemId(),data);
  }
  if (store.isEnabled()) {
    try {
      store.storeAll(map);
    }
 catch (    Exception e) {
      for (int i=0; i < dataList.size(); i++) {
        getItemQueue().poll();
      }
      throw new HazelcastException(e);
    }
  }
  return map;
}
Program: 49225
Project: 49225
Buggy source:
public Connection getConnection(Address address) throws IOException {
  checkLive();
  if (address == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  final ObjectPool<ConnectionWrapper> pool=getConnectionPool(address);
  if (pool == null) {
    return null;
  }
  Connection connection=null;
  try {
    connection=pool.take();
  }
 catch (  Exception e) {
  }
  if (connection != null && !heartbeat.checkHeartBeat(connection)) {
    connection.close();
    connection=null;
  }
  return connection;
}

Fixed version (ground truth):
public Connection getConnection(Address address) throws IOException {
  checkLive();
  if (address == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  final ObjectPool<ConnectionWrapper> pool=getConnectionPool(address);
  if (pool == null) {
    return null;
  }
  Connection connection=null;
  try {
    connection=pool.take();
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
  if (connection != null && !heartbeat.checkHeartBeat(connection)) {
    connection.close();
    connection=null;
  }
  return connection;
}
Program: 49226
Project: 49226
Buggy source:
public void handle(final ResponseStream stream) throws Exception {
  stream.read();
  lastStream=stream;
  while (active && !Thread.currentThread().isInterrupted()) {
    try {
      final Object event=stream.read();
      handler.handle(event);
    }
 catch (    Exception e) {
      try {
        stream.end();
      }
 catch (      IOException ignored) {
      }
      if (!(e instanceof IOException)) {
        active=false;
      }
 else {
        throw e;
      }
    }
  }
}

Fixed version (ground truth):
public void handle(final ResponseStream stream) throws Exception {
  stream.read();
  lastStream=stream;
  latch.countDown();
  while (active && !Thread.currentThread().isInterrupted()) {
    try {
      final Object event=stream.read();
      handler.handle(event);
    }
 catch (    Exception e) {
      try {
        stream.end();
      }
 catch (      IOException ignored) {
      }
      if (!(e instanceof IOException)) {
        active=false;
      }
 else {
        throw e;
      }
    }
  }
}
Program: 49227
Project: 49227
Buggy source:
public String listen(){
  future=context.getExecutionService().submit(new Runnable(){
    public void run(){
      while (active && !Thread.currentThread().isInterrupted()) {
        try {
          EventResponseHandler eventResponseHandler=new EventResponseHandler();
          if (key == null) {
            context.getInvocationService().invokeOnRandomTarget(registrationRequest,eventResponseHandler);
          }
 else {
            context.getInvocationService().invokeOnKeyOwner(registrationRequest,key,eventResponseHandler);
          }
        }
 catch (        Exception ignored) {
        }
      }
    }
  }
);
  return UUID.randomUUID().toString();
}

Fixed version (ground truth):
public String listen(){
  future=context.getExecutionService().submit(new Runnable(){
    public void run(){
      while (active && !Thread.currentThread().isInterrupted()) {
        try {
          EventResponseHandler eventResponseHandler=new EventResponseHandler();
          if (key == null) {
            context.getInvocationService().invokeOnRandomTarget(registrationRequest,eventResponseHandler);
          }
 else {
            context.getInvocationService().invokeOnKeyOwner(registrationRequest,key,eventResponseHandler);
          }
        }
 catch (        Exception ignored) {
        }
      }
    }
  }
);
  try {
    if (!latch.await(1,TimeUnit.MINUTES)) {
      throw new ClientException("String_Node_Str");
    }
  }
 catch (  InterruptedException e) {
  }
  return UUID.randomUUID().toString();
}
Program: 49228
Project: 49228
Buggy source:
private Object authenticate(Connection connection,Credentials credentials,ClientPrincipal principal,boolean reAuth) throws IOException {
  AuthenticationRequest auth=new AuthenticationRequest(credentials,principal);
  auth.setReAuth(reAuth);
  final SerializationService serializationService=getSerializationService();
  connection.write(serializationService.toData(auth));
  final Data addressData=connection.read();
  Address address=(Address)serializationService.toObject(addressData);
  connection.setEndpoint(address);
  final Data data=connection.read();
  Object response=serializationService.toObject(data);
  if (response instanceof GenericError) {
    throw new AuthenticationException(((GenericError)response).getMessage());
  }
  return response;
}

Fixed version (ground truth):
private Object authenticate(Connection connection,Credentials credentials,ClientPrincipal principal,boolean reAuth,boolean firstConnection) throws IOException {
  AuthenticationRequest auth=new AuthenticationRequest(credentials,principal);
  auth.setReAuth(reAuth);
  auth.setFirstConnection(firstConnection);
  final SerializationService serializationService=getSerializationService();
  connection.write(serializationService.toData(auth));
  final Data addressData=connection.read();
  Address address=(Address)serializationService.toObject(addressData);
  connection.setEndpoint(address);
  final Data data=connection.read();
  Object response=serializationService.toObject(data);
  if (response instanceof GenericError) {
    throw new AuthenticationException(((GenericError)response).getMessage());
  }
  return response;
}
Program: 49229
Project: 49229
Buggy source:
public void auth(Connection connection) throws AuthenticationException, IOException {
  authenticate(connection,credentials,principal,false);
}

Fixed version (ground truth):
public void auth(Connection connection) throws AuthenticationException, IOException {
  authenticate(connection,credentials,principal,false,false);
}
Program: 49230
Project: 49230
Buggy source:
private Connection getConnection(Address address) throws IOException {
  if (!client.getLifecycleService().isRunning()) {
    throw new HazelcastInstanceNotActiveException();
  }
  Connection connection=null;
  int retryCount=RETRY_COUNT;
  while (connection == null && retryCount > 0) {
    if (address != null) {
      connection=client.getConnectionManager().getConnection(address);
    }
 else {
      connection=client.getConnectionManager().getRandomConnection();
    }
    if (connection == null) {
      retryCount--;
      try {
        Thread.sleep(RETRY_WAIT_TIME);
      }
 catch (      InterruptedException e) {
        e.printStackTrace();
      }
    }
  }
  if (connection == null) {
    throw new HazelcastException("String_Node_Str");
  }
  return connection;
}

Fixed version (ground truth):
private Connection getConnection(Address address) throws IOException {
  if (!client.getLifecycleService().isRunning()) {
    throw new HazelcastInstanceNotActiveException();
  }
  Connection connection=null;
  int retryCount=RETRY_COUNT;
  while (connection == null && retryCount > 0) {
    if (address != null) {
      connection=client.getConnectionManager().getConnection(address);
    }
 else {
      connection=client.getConnectionManager().getRandomConnection();
    }
    if (connection == null) {
      retryCount--;
      try {
        Thread.sleep(RETRY_WAIT_TIME);
      }
 catch (      InterruptedException e) {
        e.printStackTrace();
      }
    }
    address=null;
  }
  if (connection == null) {
    throw new HazelcastException("String_Node_Str");
  }
  return connection;
}
Program: 49231
Project: 49231
Buggy source:
void rollback(){
  try {
    if (state == NO_TXN || state == ROLLED_BACK) {
      throw new IllegalStateException("String_Node_Str");
    }
    checkThread();
    try {
      sendAndReceive(new RollbackTransactionRequest());
    }
 catch (    Exception e) {
    }
    state=ROLLED_BACK;
  }
  finally {
    closeConnection();
  }
}

Fixed version (ground truth):
void rollback(){
  try {
    if (state == NO_TXN || state == ROLLED_BACK) {
      throw new IllegalStateException("String_Node_Str");
    }
    if (state == ROLLING_BACK) {
      state=ROLLED_BACK;
      return;
    }
    checkThread();
    try {
      sendAndReceive(new RollbackTransactionRequest());
    }
 catch (    Exception e) {
    }
    state=ROLLED_BACK;
  }
  finally {
    closeConnection();
  }
}
Program: 49232
Project: 49232
Buggy source:
void commit(){
  try {
    if (state != ACTIVE) {
      throw new TransactionNotActiveException("String_Node_Str");
    }
    checkThread();
    checkTimeout();
    sendAndReceive(new CommitTransactionRequest());
    state=COMMITTED;
  }
  finally {
    closeConnection();
  }
}

Fixed version (ground truth):
void commit(){
  try {
    if (state != ACTIVE) {
      throw new TransactionNotActiveException("String_Node_Str");
    }
    checkThread();
    checkTimeout();
    sendAndReceive(new CommitTransactionRequest());
    state=COMMITTED;
  }
 catch (  Exception e) {
    state=ROLLING_BACK;
    ExceptionUtil.rethrow(e);
  }
 finally {
    closeConnection();
  }
}
Program: 49233
Project: 49233
Buggy source:
private void closeConnection(){
  try {
    connection.close();
  }
 catch (  IOException e) {
    e.printStackTrace();
  }
}

Fixed version (ground truth):
private void closeConnection(){
  threadFlag.set(null);
  try {
    connection.close();
  }
 catch (  IOException e) {
    e.printStackTrace();
  }
}
Program: 49234
Project: 49234
Buggy source:
@Test public void testPutIfAbsentTtl() throws Exception {
  assertNull(map.putIfAbsent("String_Node_Str","String_Node_Str",1,TimeUnit.SECONDS));
  assertEquals("String_Node_Str",map.putIfAbsent("String_Node_Str","String_Node_Str",1,TimeUnit.SECONDS));
  Thread.sleep(2000);
  assertNull(map.putIfAbsent("String_Node_Str","String_Node_Str",1,TimeUnit.SECONDS));
  assertEquals("String_Node_Str",map.putIfAbsent("String_Node_Str","String_Node_Str",1,TimeUnit.SECONDS));
}

Fixed version (ground truth):
@Test public void testPutIfAbsentTtl() throws Exception {
  assertNull(map.putIfAbsent("String_Node_Str","String_Node_Str",1,TimeUnit.SECONDS));
  assertEquals("String_Node_Str",map.putIfAbsent("String_Node_Str","String_Node_Str",1,TimeUnit.SECONDS));
  Thread.sleep(2000);
  assertNull(map.putIfAbsent("String_Node_Str","String_Node_Str",1,TimeUnit.SECONDS));
  assertEquals("String_Node_Str",map.putIfAbsent("String_Node_Str","String_Node_Str",1,TimeUnit.SECONDS));
  Thread.sleep(2000);
}
Program: 49235
Project: 49235
Buggy source:
@Test public void testOfferPoll() throws IOException, InterruptedException {
  for (int i=0; i < 10; i++) {
    boolean result=q.offer("String_Node_Str");
    if (i < 6) {
      assertTrue(result);
    }
 else {
      assertFalse(result);
    }
  }
  assertEquals(6,q.size());
  new Thread(){
    public void run(){
      try {
        Thread.sleep(2 * 1000);
      }
 catch (      InterruptedException e) {
        e.printStackTrace();
      }
      q.poll();
    }
  }
.start();
  boolean result=q.offer("String_Node_Str",5,TimeUnit.SECONDS);
  assertTrue(result);
  for (int i=0; i < 10; i++) {
    Object o=q.poll();
    if (i < 6) {
      assertNotNull(o);
    }
 else {
      assertNull(o);
    }
  }
  assertEquals(0,q.size());
  new Thread(){
    public void run(){
      try {
        Thread.sleep(2 * 1000);
      }
 catch (      InterruptedException e) {
        e.printStackTrace();
      }
      q.offer("String_Node_Str");
    }
  }
.start();
  Object o=q.poll(5,TimeUnit.SECONDS);
  assertEquals("String_Node_Str",o);
}

Fixed version (ground truth):
@Test public void testOfferPoll() throws IOException, InterruptedException {
  for (int i=0; i < 10; i++) {
    boolean result=q.offer("String_Node_Str");
    if (i < 6) {
      assertTrue(result);
    }
 else {
      assertFalse(result);
    }
  }
  assertEquals(6,q.size());
  final Thread t1=new Thread(){
    public void run(){
      try {
        Thread.sleep(2 * 1000);
      }
 catch (      InterruptedException e) {
        e.printStackTrace();
      }
      q.poll();
    }
  }
;
  t1.start();
  boolean result=q.offer("String_Node_Str",5,TimeUnit.SECONDS);
  assertTrue(result);
  for (int i=0; i < 10; i++) {
    Object o=q.poll();
    if (i < 6) {
      assertNotNull(o);
    }
 else {
      assertNull(o);
    }
  }
  assertEquals(0,q.size());
  final Thread t2=new Thread(){
    public void run(){
      try {
        Thread.sleep(2 * 1000);
      }
 catch (      InterruptedException e) {
        e.printStackTrace();
      }
      q.offer("String_Node_Str");
    }
  }
;
  t2.start();
  Object o=q.poll(5,TimeUnit.SECONDS);
  assertEquals("String_Node_Str",o);
  t1.join(10000);
  t2.join(10000);
}
Program: 49237
Project: 49237
Buggy source:
@Override public void writePortable(PortableWriter writer) throws IOException {
  writer.writePortable("String_Node_Str",(Portable)credentials);
  if (principal != null) {
    writer.writePortable("String_Node_Str",principal);
  }
 else {
    writer.writeNullPortable("String_Node_Str",ClientPortableHook.ID,ClientPortableHook.PRINCIPAL);
  }
  writer.writeBoolean("String_Node_Str",reAuth);
}

Fixed version (ground truth):
@Override public void writePortable(PortableWriter writer) throws IOException {
  writer.writePortable("String_Node_Str",(Portable)credentials);
  if (principal != null) {
    writer.writePortable("String_Node_Str",principal);
  }
 else {
    writer.writeNullPortable("String_Node_Str",ClientPortableHook.ID,ClientPortableHook.PRINCIPAL);
  }
  writer.writeBoolean("String_Node_Str",reAuth);
  writer.writeBoolean("String_Node_Str",firstConnection);
}
Program: 49238
Project: 49238
Buggy source:
@Override public void readPortable(PortableReader reader) throws IOException {
  credentials=(Credentials)reader.readPortable("String_Node_Str");
  principal=reader.readPortable("String_Node_Str");
  reAuth=reader.readBoolean("String_Node_Str");
}

Fixed version (ground truth):
@Override public void readPortable(PortableReader reader) throws IOException {
  credentials=(Credentials)reader.readPortable("String_Node_Str");
  principal=reader.readPortable("String_Node_Str");
  reAuth=reader.readBoolean("String_Node_Str");
  firstConnection=reader.readBoolean("String_Node_Str");
}
Program: 49239
Project: 49239
Buggy source:
void authenticated(ClientPrincipal principal){
  this.principal=principal;
  this.uuid=principal.getUuid();
  authenticated=true;
}

Fixed version (ground truth):
void authenticated(ClientPrincipal principal,boolean firstConnection){
  this.principal=principal;
  this.uuid=principal.getUuid();
  this.firstConnection=firstConnection;
  authenticated=true;
}
Program: 49240
Project: 49240
Buggy source:
void destroy() throws LoginException {
  final LoginContext lc=loginContext;
  if (lc != null) {
    lc.logout();
  }
  final TransactionContext context=transactionContext;
  if (context != null) {
    transactionContext=null;
  }
  authenticated=false;
}

Fixed version (ground truth):
void destroy() throws LoginException {
  final LoginContext lc=loginContext;
  if (lc != null) {
    lc.logout();
  }
  final TransactionContext context=transactionContext;
  if (context != null) {
    try {
      context.rollbackTransaction();
    }
 catch (    Exception e) {
      e.printStackTrace();
    }
    transactionContext=null;
  }
  authenticated=false;
}
Program: 49241
Project: 49241
Buggy source:
@Override public String toString(){
  final StringBuilder sb=new StringBuilder("String_Node_Str");
  sb.append("String_Node_Str").append(conn);
  sb.append("String_Node_Str").append(uuid).append('\'');
  sb.append("String_Node_Str").append(authenticated);
  sb.append('}');
  return sb.toString();
}

Fixed version (ground truth):
@Override public String toString(){
  final StringBuilder sb=new StringBuilder("String_Node_Str");
  sb.append("String_Node_Str").append(conn);
  sb.append("String_Node_Str").append(uuid).append('\'');
  sb.append("String_Node_Str").append(firstConnection);
  sb.append("String_Node_Str").append(authenticated);
  sb.append('}');
  return sb.toString();
}
Program: 49242
Project: 49242
Buggy source:
public void connectionRemoved(Connection connection){
  if (connection.isClient() && connection instanceof TcpIpConnection) {
    final ClientEndpoint endpoint=endpoints.get(connection);
    if (endpoint != null && node.getLocalMember().getUuid().equals(endpoint.getPrincipal().getOwnerUuid())) {
      removeEndpoint(connection,true);
      NodeEngine nodeEngine=node.nodeEngine;
      final Collection<MemberImpl> memberList=nodeEngine.getClusterService().getMemberList();
      for (      MemberImpl member : memberList) {
        final ClientDisconnectionOperation op=new ClientDisconnectionOperation(endpoint.getUuid());
        op.setNodeEngine(nodeEngine).setServiceName(SERVICE_NAME).setService(this).setResponseHandler(ResponseHandlerFactory.createEmptyResponseHandler());
        if (member.localMember()) {
          nodeEngine.getOperationService().runOperation(op);
        }
 else {
          nodeEngine.getOperationService().send(op,member.getAddress());
        }
      }
    }
  }
}

Fixed version (ground truth):
public void connectionRemoved(Connection connection){
  if (connection.isClient() && connection instanceof TcpIpConnection) {
    final ClientEndpoint endpoint=endpoints.get(connection);
    if (endpoint != null && node.getLocalMember().getUuid().equals(endpoint.getPrincipal().getOwnerUuid())) {
      removeEndpoint(connection,true);
      if (!endpoint.isFirstConnection()) {
        return;
      }
      NodeEngine nodeEngine=node.nodeEngine;
      final Collection<MemberImpl> memberList=nodeEngine.getClusterService().getMemberList();
      for (      MemberImpl member : memberList) {
        final ClientDisconnectionOperation op=new ClientDisconnectionOperation(endpoint.getUuid());
        op.setNodeEngine(nodeEngine).setServiceName(SERVICE_NAME).setService(this).setResponseHandler(ResponseHandlerFactory.createEmptyResponseHandler());
        if (member.localMember()) {
          nodeEngine.getOperationService().runOperation(op);
        }
 else {
          nodeEngine.getOperationService().send(op,member.getAddress());
        }
      }
    }
  }
}
Program: 49243
Project: 49243
Buggy source:
public ClientReAuthOperation(String clientUuid){
  this.clientUuid=clientUuid;
}

Fixed version (ground truth):
public ClientReAuthOperation(String clientUuid,boolean firstConnection){
  this.clientUuid=clientUuid;
  this.firstConnection=firstConnection;
}
Program: 49244
Project: 49244
Buggy source:
public void run() throws Exception {
  ClientEngineImpl service=getService();
  final ClientEndpoint endpoint=service.getEndpoint(clientUuid);
  if (endpoint != null) {
    endpoint.authenticated(new ClientPrincipal(clientUuid,getCallerUuid()));
  }
}

Fixed version (ground truth):
public void run() throws Exception {
  ClientEngineImpl service=getService();
  final ClientEndpoint endpoint=service.getEndpoint(clientUuid);
  if (endpoint != null) {
    endpoint.authenticated(new ClientPrincipal(clientUuid,getCallerUuid()),firstConnection);
  }
}
Program: 49245
Project: 49245
Buggy source:
@Override protected void readInternal(ObjectDataInput in) throws IOException {
  super.readInternal(in);
  clientUuid=in.readUTF();
}

Fixed version (ground truth):
@Override protected void readInternal(ObjectDataInput in) throws IOException {
  super.readInternal(in);
  clientUuid=in.readUTF();
  firstConnection=in.readBoolean();
}
Program: 49246
Project: 49246
Buggy source:
@Override protected void writeInternal(ObjectDataOutput out) throws IOException {
  super.writeInternal(out);
  out.writeUTF(clientUuid);
}

Fixed version (ground truth):
@Override protected void writeInternal(ObjectDataOutput out) throws IOException {
  super.writeInternal(out);
  out.writeUTF(clientUuid);
  out.writeBoolean(firstConnection);
}
Program: 49247
Project: 49247
Buggy source:
public boolean cancel(String uuid,boolean interrupt){
  final CallableProcessor processor=submittedTasks.remove(uuid);
  if (processor != null && processor.cancel(interrupt)) {
    processor.responseHandler.sendResponse(new CancellationException());
    getLocalExecutorStats(processor.name).cancelExecution();
    return true;
  }
  return false;
}

Fixed version (ground truth):
public boolean cancel(String uuid,boolean interrupt){
  final CallableProcessor processor=submittedTasks.remove(uuid);
  if (processor != null && processor.cancel(interrupt)) {
    processor.sendResponse(new CancellationException());
    getLocalExecutorStats(processor.name).cancelExecution();
    return true;
  }
  return false;
}
Program: 49248
Project: 49248
Buggy source:
public void run(){
  final long start=Clock.currentTimeMillis();
  startExecution(name,start - creationTime);
  Object result=null;
  try {
    super.run();
    result=get();
  }
 catch (  Exception e) {
    final ILogger logger=getLogger();
    logger.log(Level.FINEST,"String_Node_Str" + callableToString,e);
    result=e;
  }
 finally {
    if (uuid != null) {
      submittedTasks.remove(uuid);
    }
    final boolean cancelled=isCancelled();
    try {
      responseHandler.sendResponse(result);
    }
 catch (    ResponseAlreadySentException e) {
      if (!cancelled) {
        final ILogger logger=getLogger();
        logger.log(Level.SEVERE,e.getMessage(),e);
      }
    }
    if (!cancelled) {
      finishExecution(name,Clock.currentTimeMillis() - start);
    }
  }
}

Fixed version (ground truth):
public void run(){
  final long start=Clock.currentTimeMillis();
  startExecution(name,start - creationTime);
  Object result=null;
  try {
    super.run();
    result=get();
  }
 catch (  Exception e) {
    final ILogger logger=getLogger();
    logger.log(Level.FINEST,"String_Node_Str" + callableToString,e);
    result=e;
  }
 finally {
    if (uuid != null) {
      submittedTasks.remove(uuid);
    }
    sendResponse(result);
    if (!isCancelled()) {
      finishExecution(name,Clock.currentTimeMillis() - start);
    }
  }
}