nus-yam/ex-repair huggingface dataset:
Program: 49160
Project: 49160
Buggy source:
@Test public void testMapPutTtlWithListener() throws InterruptedException {
  Config cfg=new Config();
  TestHazelcastInstanceFactory factory=createHazelcastInstanceFactory(2);
  final HazelcastInstance[] instances=factory.newInstances(cfg);
  warmUpPartitions(instances);
  final int k=10;
  final int putCount=10000;
  final CountDownLatch latch=new CountDownLatch(k * putCount);
  final IMap map=instances[0].getMap("String_Node_Str");
  final ExecutorService ex=Executors.newFixedThreadPool(k * 2);
  final AtomicBoolean error=new AtomicBoolean(false);
  final Set<Long> times=Collections.newSetFromMap(new ConcurrentHashMap<Long,Boolean>());
  map.addEntryListener(new EntryAdapter(){
    public void entryEvicted(    final EntryEvent event){
      ex.execute(new Runnable(){
        public void run(){
          final Long expectedEvictionTime=(Long)(event.getOldValue());
          long timeDifference=System.currentTimeMillis() - expectedEvictionTime;
          if (timeDifference > 5000) {
            error.set(true);
            times.add(timeDifference);
          }
          latch.countDown();
        }
      }
);
    }
  }
,true);
  for (int i=0; i < k; i++) {
    final int threadId=i;
    ex.execute(new Runnable(){
      public void run(){
        int ttl=(int)(Math.random() * 5000 + 3000);
        for (int j=0; j < putCount; j++) {
          final long expectedEvictionTime=ttl + System.currentTimeMillis();
          map.put(j + putCount * threadId,expectedEvictionTime,ttl,TimeUnit.MILLISECONDS);
        }
      }
    }
);
  }
  try {
    assertTrue(latch.await(1,TimeUnit.MINUTES));
    assertFalse("String_Node_Str" + times,error.get());
  }
  finally {
    ex.shutdownNow();
  }
}

Fixed version (ground truth):
@Test public void testMapPutTtlWithListener() throws InterruptedException {
  Config cfg=new Config();
  TestHazelcastInstanceFactory factory=createHazelcastInstanceFactory(2);
  final HazelcastInstance[] instances=factory.newInstances(cfg);
  warmUpPartitions(instances);
  final int k=10;
  final int putCount=10000;
  final CountDownLatch latch=new CountDownLatch(k * putCount);
  final IMap map=instances[0].getMap("String_Node_Str");
  final AtomicBoolean error=new AtomicBoolean(false);
  final Set<Long> times=Collections.newSetFromMap(new ConcurrentHashMap<Long,Boolean>());
  map.addEntryListener(new EntryAdapter(){
    public void entryEvicted(    final EntryEvent event){
      final Long expectedEvictionTime=(Long)(event.getOldValue());
      long timeDifference=System.currentTimeMillis() - expectedEvictionTime;
      if (timeDifference > 5000) {
        error.set(true);
        times.add(timeDifference);
      }
      latch.countDown();
    }
  }
,true);
  for (int i=0; i < k; i++) {
    final int threadId=i;
    int ttl=(int)(Math.random() * 5000 + 3000);
    for (int j=0; j < putCount; j++) {
      final long expectedEvictionTime=ttl + System.currentTimeMillis();
      map.put(j + putCount * threadId,expectedEvictionTime,ttl,TimeUnit.MILLISECONDS);
    }
  }
  assertTrue(latch.await(1,TimeUnit.MINUTES));
  assertFalse("String_Node_Str" + times,error.get());
}
Program: 49161
Project: 49161
Buggy source:
protected void invalidateValueCache(){
  if (cmap.isCacheValue()) {
    valueObject=null;
  }
}

Fixed version (ground truth):
protected void invalidateValueCache(){
  if (cmap.isCacheValue()) {
synchronized (this) {
      valueObject=null;
    }
  }
}
Program: 49163
Project: 49163
Buggy source:
public Set<Data> localKeySet(CollectionProxyId proxyId){
  Set<Data> keySet=new HashSet<Data>();
  ClusterServiceImpl clusterService=(ClusterServiceImpl)nodeEngine.getClusterService();
  Address thisAddress=clusterService.getThisAddress();
  for (int i=0; i < nodeEngine.getPartitionService().getPartitionCount(); i++) {
    PartitionView partition=nodeEngine.getPartitionService().getPartitionView(i);
    CollectionPartitionContainer partitionContainer=getPartitionContainer(i);
    CollectionContainer collectionContainer=partitionContainer.getCollectionContainer(proxyId);
    if (collectionContainer == null) {
      continue;
    }
    if (partition.getOwner().equals(thisAddress)) {
      keySet.addAll(collectionContainer.keySet());
    }
  }
  getLocalMultiMapStatsImpl(proxyId).incrementOtherOperations();
  return keySet;
}

Fixed version (ground truth):
public Set<Data> localKeySet(CollectionProxyId proxyId){
  Set<Data> keySet=new HashSet<Data>();
  ClusterServiceImpl clusterService=(ClusterServiceImpl)nodeEngine.getClusterService();
  Address thisAddress=clusterService.getThisAddress();
  for (int i=0; i < nodeEngine.getPartitionService().getPartitionCount(); i++) {
    PartitionView partition=nodeEngine.getPartitionService().getPartition(i);
    CollectionPartitionContainer partitionContainer=getPartitionContainer(i);
    CollectionContainer collectionContainer=partitionContainer.getCollectionContainer(proxyId);
    if (collectionContainer == null) {
      continue;
    }
    if (partition.getOwner().equals(thisAddress)) {
      keySet.addAll(collectionContainer.keySet());
    }
  }
  getLocalMultiMapStatsImpl(proxyId).incrementOtherOperations();
  return keySet;
}
Program: 49165
Project: 49165
Buggy source:
private void onOwnerDisconnected(final String caller){
  for (  String name : permitMap.keySet()) {
    int partitionId=nodeEngine.getPartitionService().getPartitionId(name);
    PartitionView info=nodeEngine.getPartitionService().getPartitionView(partitionId);
    if (nodeEngine.getThisAddress().equals(info.getOwner())) {
      Operation op=new SemaphoreDeadMemberOperation(name,caller).setPartitionId(partitionId).setResponseHandler(ResponseHandlerFactory.createEmptyResponseHandler()).setService(this).setNodeEngine(nodeEngine).setServiceName(SERVICE_NAME);
      nodeEngine.getOperationService().executeOperation(op);
    }
  }
}

Fixed version (ground truth):
private void onOwnerDisconnected(final String caller){
  for (  String name : permitMap.keySet()) {
    int partitionId=nodeEngine.getPartitionService().getPartitionId(name);
    PartitionView info=nodeEngine.getPartitionService().getPartition(partitionId);
    if (nodeEngine.getThisAddress().equals(info.getOwner())) {
      Operation op=new SemaphoreDeadMemberOperation(name,caller).setPartitionId(partitionId).setResponseHandler(ResponseHandlerFactory.createEmptyResponseHandler()).setService(this).setNodeEngine(nodeEngine).setServiceName(SERVICE_NAME);
      nodeEngine.getOperationService().executeOperation(op);
    }
  }
}
Program: 49166
Project: 49166
Buggy source:
public void readData(ObjectDataInput in) throws IOException {
  partitionId=in.readInt();
  oldOwner=new MemberImpl();
  oldOwner.readData(in);
  newOwner=new MemberImpl();
  newOwner.readData(in);
  status=MigrationStatus.readFrom(in);
}

Fixed version (ground truth):
public void readData(ObjectDataInput in) throws IOException {
  partitionId=in.readInt();
  oldOwner=in.readObject();
  newOwner=in.readObject();
  status=MigrationStatus.readFrom(in);
}
Program: 49167
Project: 49167
Buggy source:
@Override public String toString(){
  return "String_Node_Str" + "String_Node_Str" + partitionId + "String_Node_Str"+ oldOwner+ "String_Node_Str"+ newOwner+ '}';
}

Fixed version (ground truth):
@Override public String toString(){
  final StringBuilder sb=new StringBuilder("String_Node_Str");
  sb.append("String_Node_Str").append(partitionId);
  sb.append("String_Node_Str").append(status);
  sb.append("String_Node_Str").append(oldOwner);
  sb.append("String_Node_Str").append(newOwner);
  sb.append('}');
  return sb.toString();
}
Program: 49168
Project: 49168
Buggy source:
public void writeData(ObjectDataOutput out) throws IOException {
  out.writeInt(partitionId);
  oldOwner.writeData(out);
  newOwner.writeData(out);
  MigrationStatus.writeTo(status,out);
}

Fixed version (ground truth):
public void writeData(ObjectDataOutput out) throws IOException {
  out.writeInt(partitionId);
  out.writeObject(oldOwner);
  out.writeObject(newOwner);
  MigrationStatus.writeTo(status,out);
}
Program: 49169
Project: 49169
Buggy source:
public void rollbackMigration(PartitionMigrationEvent event){
  logger.log(Level.FINEST,"String_Node_Str" + event);
  if (event.getMigrationEndpoint() == MigrationEndpoint.DESTINATION) {
    clearPartitionData(event.getPartitionId());
  }
  ownedPartitions.set(nodeEngine.getPartitionService().getMemberPartitions(nodeEngine.getThisAddress()));
}

Fixed version (ground truth):
public void rollbackMigration(PartitionMigrationEvent event){
  if (event.getMigrationEndpoint() == MigrationEndpoint.DESTINATION) {
    clearPartitionData(event.getPartitionId());
  }
  ownedPartitions.set(nodeEngine.getPartitionService().getMemberPartitions(nodeEngine.getThisAddress()));
}
Program: 49170
Project: 49170
Buggy source:
private void migrateIndex(PartitionMigrationEvent event){
  final PartitionContainer container=partitionContainers[event.getPartitionId()];
  for (  PartitionRecordStore mapPartition : container.getMaps().values()) {
    final MapContainer mapContainer=getMapContainer(mapPartition.name);
    final IndexService indexService=mapContainer.getIndexService();
    if (indexService.hasIndex()) {
      for (      Record record : mapPartition.getRecords().values()) {
        if (event.getMigrationEndpoint() == MigrationEndpoint.SOURCE) {
          indexService.removeEntryIndex(record.getKey());
        }
 else {
          indexService.saveEntryIndex(new QueryEntry(getSerializationService(),record.getKey(),record.getKey(),record.getValue()));
        }
      }
    }
  }
}

Fixed version (ground truth):
private void migrateIndex(PartitionMigrationEvent event){
  final PartitionContainer container=partitionContainers[event.getPartitionId()];
  for (  PartitionRecordStore recordStore : container.getMaps().values()) {
    final MapContainer mapContainer=getMapContainer(recordStore.name);
    final IndexService indexService=mapContainer.getIndexService();
    if (indexService.hasIndex()) {
      for (      Record record : recordStore.getRecords().values()) {
        if (event.getMigrationEndpoint() == MigrationEndpoint.SOURCE) {
          indexService.removeEntryIndex(record.getKey());
        }
 else {
          indexService.saveEntryIndex(new QueryEntry(getSerializationService(),record.getKey(),record.getKey(),record.getValue()));
        }
      }
    }
  }
}
Program: 49171
Project: 49171
Buggy source:
public Operation prepareReplicationOperation(PartitionReplicationEvent event){
  logger.log(Level.FINEST,"String_Node_Str" + event);
  final PartitionContainer container=partitionContainers[event.getPartitionId()];
  final MapReplicationOperation operation=new MapReplicationOperation(container,event.getPartitionId(),event.getReplicaIndex());
  return operation.isEmpty() ? null : operation;
}

Fixed version (ground truth):
public Operation prepareReplicationOperation(PartitionReplicationEvent event){
  final PartitionContainer container=partitionContainers[event.getPartitionId()];
  final MapReplicationOperation operation=new MapReplicationOperation(container,event.getPartitionId(),event.getReplicaIndex());
  return operation.isEmpty() ? null : operation;
}
Program: 49173
Project: 49173
Buggy source:
private void clearPartitionData(final int partitionId){
  logger.log(Level.FINEST,"String_Node_Str" + partitionId);
  final PartitionContainer container=partitionContainers[partitionId];
  if (container != null) {
    for (    PartitionRecordStore mapPartition : container.getMaps().values()) {
      mapPartition.clear();
    }
    container.getMaps().clear();
  }
}

Fixed version (ground truth):
private void clearPartitionData(final int partitionId){
  final PartitionContainer container=partitionContainers[partitionId];
  if (container != null) {
    for (    PartitionRecordStore mapPartition : container.getMaps().values()) {
      mapPartition.clear();
    }
    container.getMaps().clear();
  }
}
Program: 49174
Project: 49174
Buggy source:
public void commitMigration(PartitionMigrationEvent event){
  logger.log(Level.FINEST,"String_Node_Str" + event);
  if (event.getMigrationEndpoint() == MigrationEndpoint.SOURCE) {
    migrateIndex(event);
    clearPartitionData(event.getPartitionId());
  }
 else {
    migrateIndex(event);
  }
  ownedPartitions.set(nodeEngine.getPartitionService().getMemberPartitions(nodeEngine.getThisAddress()));
}

Fixed version (ground truth):
public void commitMigration(PartitionMigrationEvent event){
  if (event.getMigrationEndpoint() == MigrationEndpoint.SOURCE) {
    migrateIndex(event);
    clearPartitionData(event.getPartitionId());
  }
 else {
    migrateIndex(event);
  }
  ownedPartitions.set(nodeEngine.getPartitionService().getMemberPartitions(nodeEngine.getThisAddress()));
}
Program: 49176
Project: 49176
Buggy source:
private Collection<Operation> prepareMigrationTasks(){
  NodeEngineImpl nodeEngine=(NodeEngineImpl)getNodeEngine();
  final PartitionReplicationEvent replicationEvent=new PartitionReplicationEvent(migrationInfo.getPartitionId(),0);
  final PartitionMigrationEvent migrationEvent=new PartitionMigrationEvent(MigrationEndpoint.SOURCE,migrationInfo.getPartitionId());
  final Collection<Operation> tasks=new LinkedList<Operation>();
  for (  ServiceInfo serviceInfo : nodeEngine.getServiceInfos(MigrationAwareService.class)) {
    MigrationAwareService service=(MigrationAwareService)serviceInfo.getService();
    final Operation op=service.prepareReplicationOperation(replicationEvent);
    if (op != null) {
      op.setServiceName(serviceInfo.getName());
      service.beforeMigration(migrationEvent);
      tasks.add(op);
    }
  }
  return tasks;
}

Fixed version (ground truth):
private Collection<Operation> prepareMigrationTasks(){
  NodeEngineImpl nodeEngine=(NodeEngineImpl)getNodeEngine();
  final PartitionReplicationEvent replicationEvent=new PartitionReplicationEvent(migrationInfo.getPartitionId(),0);
  final PartitionMigrationEvent migrationEvent=new PartitionMigrationEvent(MigrationEndpoint.SOURCE,migrationInfo.getPartitionId());
  final Collection<Operation> tasks=new LinkedList<Operation>();
  for (  ServiceInfo serviceInfo : nodeEngine.getServiceInfos(MigrationAwareService.class)) {
    MigrationAwareService service=(MigrationAwareService)serviceInfo.getService();
    service.beforeMigration(migrationEvent);
    final Operation op=service.prepareReplicationOperation(replicationEvent);
    if (op != null) {
      op.setServiceName(serviceInfo.getName());
      tasks.add(op);
    }
  }
  return tasks;
}
Program: 49177
Project: 49177
Buggy source:
public void run(){
  final BufferObjectDataOutput out=serializationService.createObjectDataOutput(1024 * 32);
  try {
    out.writeInt(tasks.size());
    for (    Operation task : tasks) {
      serializationService.writeObject(out,task);
    }
    final byte[] data=IOUtil.compress(out.toByteArray());
    final MigrationOperation migrationOperation=new MigrationOperation(migrationInfo,replicaVersions,data,tasks.size());
    Invocation inv=nodeEngine.getOperationService().createInvocationBuilder(PartitionServiceImpl.SERVICE_NAME,migrationOperation,to).setTryPauseMillis(1000).setReplicaIndex(getReplicaIndex()).build();
    Future future=inv.invoke();
    Boolean result=(Boolean)nodeEngine.toObject(future.get(timeout,TimeUnit.SECONDS));
    responseHandler.sendResponse(result);
  }
 catch (  Throwable e) {
    responseHandler.sendResponse(Boolean.FALSE);
    if (e instanceof ExecutionException) {
      e=e.getCause() != null ? e.getCause() : e;
    }
    Level level=(e instanceof MemberLeftException || e instanceof InterruptedException) || !getNodeEngine().isActive() ? Level.INFO : Level.WARNING;
    getLogger().log(level,e.getMessage(),e);
  }
 finally {
    IOUtil.closeResource(out);
  }
}

Fixed version (ground truth):
public void run(){
  final BufferObjectDataOutput out=serializationService.createObjectDataOutput(1024 * 32);
  try {
    out.writeInt(tasks.size());
    for (    Operation task : tasks) {
      serializationService.writeObject(out,task);
    }
    final byte[] data=IOUtil.compress(out.toByteArray());
    final MigrationOperation migrationOperation=new MigrationOperation(migrationInfo,replicaVersions,data,tasks.size());
    Invocation inv=nodeEngine.getOperationService().createInvocationBuilder(PartitionServiceImpl.SERVICE_NAME,migrationOperation,destination).setTryPauseMillis(1000).setReplicaIndex(getReplicaIndex()).build();
    Future future=inv.invoke();
    Boolean result=(Boolean)nodeEngine.toObject(future.get(timeout,TimeUnit.SECONDS));
    responseHandler.sendResponse(result);
  }
 catch (  Throwable e) {
    responseHandler.sendResponse(Boolean.FALSE);
    if (e instanceof ExecutionException) {
      e=e.getCause() != null ? e.getCause() : e;
    }
    Level level=(e instanceof MemberLeftException || e instanceof InterruptedException) || !getNodeEngine().isActive() ? Level.INFO : Level.WARNING;
    getLogger().log(level,e.getMessage(),e);
  }
 finally {
    IOUtil.closeResource(out);
  }
}
Program: 49179
Project: 49179
Buggy source:
public static void main(String[] args) throws Exception {
  final String baseDir="String_Node_Str";
  final String sourceDir=baseDir + "String_Node_Str";
  Server server=new Server();
  SelectChannelConnector connector=new SelectChannelConnector();
  connector.setPort(8080);
  server.addConnector(connector);
  WebAppContext context=new WebAppContext();
  context.setResourceBase(sourceDir);
  context.setDescriptor(sourceDir + "String_Node_Str");
  context.setLogUrlOnStart(true);
  context.setContextPath("String_Node_Str");
  context.setParentLoaderPriority(true);
  server.setHandler(context);
  server.start();
  server.join();
}

Fixed version (ground truth):
public static void main(String[] args) throws Exception {
  final String baseDir=args.length > 0 ? args[0] : "String_Node_Str";
  final String sourceDir=baseDir + "String_Node_Str";
  Server server=new Server();
  SelectChannelConnector connector=new SelectChannelConnector();
  connector.setPort(8080);
  server.addConnector(connector);
  WebAppContext context=new WebAppContext();
  context.setResourceBase(sourceDir);
  context.setDescriptor(sourceDir + "String_Node_Str");
  context.setLogUrlOnStart(true);
  context.setContextPath("String_Node_Str");
  context.setParentLoaderPriority(true);
  server.setHandler(context);
  server.start();
  server.join();
}
Program: 49180
Project: 49180
Buggy source:
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();
  return ErrorHandler.returnResultOrThrowException(serializationService.toObject(data));
}

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=ErrorHandler.returnResultOrThrowException(serializationService.toObject(addressData));
  connection.setEndpoint(address);
  final Data data=connection.read();
  return ErrorHandler.returnResultOrThrowException(serializationService.toObject(data));
}
Program: 49181
Project: 49181
Buggy source:
private void start(){
  try {
    clusterService.start();
  }
 catch (  IllegalStateException e) {
    lifecycleService.shutdown();
    throw e;
  }
  partitionService.start();
  lifecycleService.setStarted();
}

Fixed version (ground truth):
private void start(){
  lifecycleService.setStarted();
  try {
    clusterService.start();
  }
 catch (  IllegalStateException e) {
    lifecycleService.shutdown();
    throw e;
  }
  partitionService.start();
}
Program: 49182
Project: 49182
Buggy source:
public static <T>Iterator<T> iterator(final Class<T> clazz,final String factoryId,final ClassLoader classLoader) throws Exception {
  final Set<ServiceDefinition> classDefinitions=parse(factoryId,classLoader);
  if (classLoader != null && ServiceLoader.class.getClassLoader() != classLoader) {
    classDefinitions.addAll(parse(factoryId,ServiceLoader.class.getClassLoader()));
  }
  return new Iterator<T>(){
    final Iterator<ServiceDefinition> classIter=classDefinitions.iterator();
    public boolean hasNext(){
      return classIter.hasNext();
    }
    public T next(){
      final ServiceDefinition classDefinition=classIter.next();
      try {
        String className=classDefinition.className;
        ClassLoader classLoader=classDefinition.classLoader;
        return clazz.cast(ClassLoaderUtil.newInstance(classLoader,className));
      }
 catch (      Exception e) {
        throw new HazelcastException(e);
      }
    }
    public void remove(){
      throw new UnsupportedOperationException();
    }
  }
;
}

Fixed version (ground truth):
public static <T>Iterator<T> iterator(final Class<T> clazz,final String factoryId,final ClassLoader classLoader) throws Exception {
  final Set<ServiceDefinition> classDefinitions=parse(factoryId,classLoader);
  final ClassLoader systemClassLoader=ServiceLoader.class.getClassLoader();
  if (classLoader != null && systemClassLoader != classLoader) {
    final Set<ServiceDefinition> systemDefinitions=parse(factoryId,systemClassLoader);
    classDefinitions.addAll(systemDefinitions);
  }
  return new Iterator<T>(){
    final Iterator<ServiceDefinition> classIter=classDefinitions.iterator();
    public boolean hasNext(){
      return classIter.hasNext();
    }
    public T next(){
      final ServiceDefinition classDefinition=classIter.next();
      try {
        String className=classDefinition.className;
        ClassLoader classLoader=classDefinition.classLoader;
        return clazz.cast(ClassLoaderUtil.newInstance(classLoader,className));
      }
 catch (      Exception e) {
        throw new HazelcastException(e);
      }
    }
    public void remove(){
      throw new UnsupportedOperationException();
    }
  }
;
}
Program: 49183
Project: 49183
Buggy source:
@Test public void testTimestamp(){
  final long now=System.currentTimeMillis();
  final Timestamp date1=new Timestamp(now);
  final Timestamp date2=DateHelper.parseTimeStamp(date1.toString());
  Calendar cal1=Calendar.getInstance(Locale.US);
  cal1.setTimeInMillis(date1.getTime());
  Calendar cal2=Calendar.getInstance(Locale.US);
  cal2.setTimeInMillis(date2.getTime());
  Assert.assertEquals(cal1.get(Calendar.YEAR),cal2.get(Calendar.YEAR));
  Assert.assertEquals(cal1.get(Calendar.MONTH),cal2.get(Calendar.MONTH));
  Assert.assertEquals(cal1.get(Calendar.DAY_OF_MONTH),cal2.get(Calendar.DAY_OF_MONTH));
  Assert.assertEquals(cal1.get(Calendar.HOUR_OF_DAY),cal2.get(Calendar.HOUR_OF_DAY));
  Assert.assertEquals(cal1.get(Calendar.MINUTE),cal2.get(Calendar.MINUTE));
  Assert.assertEquals(cal1.get(Calendar.SECOND),cal2.get(Calendar.SECOND));
  Assert.assertEquals(cal1.get(Calendar.MILLISECOND),cal2.get(Calendar.MILLISECOND));
}

Fixed version (ground truth):
@Test public void testTimestamp(){
  final long now=System.currentTimeMillis();
  final Timestamp date1=new Timestamp(now);
  final Timestamp date2=DateHelper.parseTimeStamp(date1.toString());
  Calendar cal1=Calendar.getInstance(Locale.US);
  cal1.setTimeInMillis(date1.getTime());
  Calendar cal2=Calendar.getInstance(Locale.US);
  cal2.setTimeInMillis(date2.getTime());
  Assert.assertEquals(cal1.get(Calendar.YEAR),cal2.get(Calendar.YEAR));
  Assert.assertEquals(cal1.get(Calendar.MONTH),cal2.get(Calendar.MONTH));
  Assert.assertEquals(cal1.get(Calendar.DAY_OF_MONTH),cal2.get(Calendar.DAY_OF_MONTH));
  Assert.assertEquals(cal1.get(Calendar.HOUR_OF_DAY),cal2.get(Calendar.HOUR_OF_DAY));
  Assert.assertEquals(cal1.get(Calendar.MINUTE),cal2.get(Calendar.MINUTE));
  Assert.assertEquals(cal1.get(Calendar.SECOND),cal2.get(Calendar.SECOND));
}
Program: 49184
Project: 49184
Buggy source:
MockConnectionManager(Node node){
  this.node=node;
  thisConnection=new MockConnection(node.getThisAddress(),node.nodeEngine);
  register(node.getThisAddress(),node.nodeEngine);
}

Fixed version (ground truth):
MockConnectionManager(Node node){
  this.node=node;
  thisConnection=new MockConnection(node.getThisAddress(),node.nodeEngine);
synchronized (joinerLock) {
    nodes.put(node.getThisAddress(),node.nodeEngine);
  }
}
Program: 49185
Project: 49185
Buggy source:
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());
    }
  }
}

Fixed version (ground truth):
public void doJoin(AtomicBoolean joined){
  NodeEngineImpl nodeEngine=null;
synchronized (joinerLock) {
    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: 49187
Project: 49187
Buggy source:
@Override public boolean returnsResponse(){
  return true;
}

Fixed version (ground truth):
@Override public boolean returnsResponse(){
  return returnResponse;
}
Program: 49188
Project: 49188
Buggy source:
private void migrationTaskFailed(){
  systemLogService.logPartition("String_Node_Str" + migrationRequestOp);
  finalizeMigration(false);
  sendMigrationEvent(migrationInfo,MigrationStatus.FAILED);
}

Fixed version (ground truth):
private void migrationTaskFailed(){
  systemLogService.logPartition("String_Node_Str" + migrationInfo);
  finalizeMigration(false);
  sendMigrationEvent(migrationInfo,MigrationStatus.FAILED);
}
Program: 49190
Project: 49190
Buggy source:
private boolean shouldWaitMigrationOrBackups(Level level){
  if (initialized) {
    MemberGroupFactory mgf=memberGroupFactory;
    final Collection<MemberGroup> memberGroups=mgf.createMemberGroups(node.getClusterService().getMembers());
    if (memberGroups.size() < 2)     return false;
    int groups=0;
    for (    MemberGroup memberGroup : memberGroups) {
      if (memberGroup.size() > 0) {
        groups++;
      }
    }
    if (groups < 2)     return false;
    final int activeSize=activeMigrations.size();
    if (activeSize != 0) {
      logger.log(level,"String_Node_Str" + activeSize);
      return true;
    }
    final int queueSize=migrationQueue.size();
    if (queueSize == 0) {
      for (      PartitionImpl partition : partitions) {
        if (partition.getReplicaAddress(1) == null) {
          logger.log(level,"String_Node_Str" + partition.getPartitionId());
          return true;
        }
 else {
          final int replicaSyncProcesses=replicaSyncProcessCount.get();
          if (replicaSyncProcesses > 0) {
            logger.log(level,"String_Node_Str" + replicaSyncProcesses);
            return true;
          }
        }
      }
    }
 else {
      logger.log(level,"String_Node_Str" + queueSize);
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
private boolean shouldWaitMigrationOrBackups(Level level){
  if (initialized) {
    MemberGroupFactory mgf=memberGroupFactory;
    final Collection<MemberGroup> memberGroups=mgf.createMemberGroups(node.getClusterService().getMembers());
    if (memberGroups.size() < 2)     return false;
    int groups=0;
    for (    MemberGroup memberGroup : memberGroups) {
      if (memberGroup.size() > 0) {
        groups++;
      }
    }
    if (groups < 2)     return false;
    final int activeSize=activeMigrations.size();
    if (activeSize != 0) {
      if (logger.isLoggable(level)) {
        logger.log(level,"String_Node_Str" + activeSize);
      }
      return true;
    }
    final int queueSize=migrationQueue.size();
    if (queueSize == 0) {
      for (      PartitionImpl partition : partitions) {
        if (partition.getReplicaAddress(1) == null) {
          if (logger.isLoggable(level)) {
            logger.log(level,"String_Node_Str" + partition.getPartitionId());
          }
          return true;
        }
 else {
          final int replicaSyncProcesses=replicaSyncProcessCount.get();
          if (replicaSyncProcesses > 0) {
            if (logger.isLoggable(level)) {
              logger.log(level,"String_Node_Str" + replicaSyncProcesses);
            }
            return true;
          }
        }
      }
    }
 else {
      if (logger.isLoggable(level)) {
        logger.log(level,"String_Node_Str" + queueSize);
      }
      return true;
    }
  }
  return false;
}
Program: 49191
Project: 49191
Buggy source:
private void rollbackActiveMigrationsFromPreviousMaster(final String masterUuid){
  lock.lock();
  try {
    if (!activeMigrations.isEmpty()) {
      for (      MigrationInfo migrationInfo : activeMigrations.values()) {
        if (!masterUuid.equals(migrationInfo.getMasterUuid())) {
          logger.log(Level.INFO,"String_Node_Str" + migrationInfo);
          finalizeActiveMigration(migrationInfo);
        }
      }
    }
  }
  finally {
    lock.unlock();
  }
}

Fixed version (ground truth):
private void rollbackActiveMigrationsFromPreviousMaster(final String currentMasterUuid){
  lock.lock();
  try {
    if (!activeMigrations.isEmpty()) {
      for (      MigrationInfo migrationInfo : activeMigrations.values()) {
        if (!currentMasterUuid.equals(migrationInfo.getMasterUuid())) {
          logger.log(Level.INFO,"String_Node_Str" + migrationInfo);
          finalizeActiveMigration(migrationInfo);
        }
      }
    }
  }
  finally {
    lock.unlock();
  }
}
Program: 49192
Project: 49192
Buggy source:
public boolean backup(){
  final PartitionService partitionService=nodeEngine.getPartitionService();
  final PartitionView partition=partitionService.getPartitionView(partitionId);
  final Address target=partition.getReplicaAddress(replicaIndex);
  if (target != null) {
    send(backup,target);
    return true;
  }
  return ++retries >= 5;
}

Fixed version (ground truth):
public boolean backup(){
  final PartitionService partitionService=nodeEngine.getPartitionService();
  final PartitionView partition=partitionService.getPartitionView(partitionId);
  final Address target=partition.getReplicaAddress(replicaIndex);
  if (target != null && !target.equals(node.getThisAddress())) {
    send(backup,target);
    return true;
  }
  return ++retries >= 10;
}
Program: 49194
Project: 49194
Buggy source:
public void process(EntryTaskScheduler<Object,ScheduledBackup> scheduler,Collection<ScheduledEntry<Object,ScheduledBackup>> scheduledEntries){
  for (  ScheduledEntry<Object,ScheduledBackup> entry : scheduledEntries) {
    final ScheduledBackup backup=entry.getValue();
    if (!backup.backup()) {
      final int retries=backup.retries;
      if (logger.isLoggable(Level.INFO)) {
        logger.log(Level.INFO,"String_Node_Str" + retries + "String_Node_Str"+ backup);
      }
      scheduler.schedule(entry.getScheduledDelayMillis(),entry.getKey(),backup);
    }
  }
}

Fixed version (ground truth):
public void process(EntryTaskScheduler<Object,ScheduledBackup> scheduler,Collection<ScheduledEntry<Object,ScheduledBackup>> scheduledEntries){
  for (  ScheduledEntry<Object,ScheduledBackup> entry : scheduledEntries) {
    final ScheduledBackup backup=entry.getValue();
    if (!backup.backup()) {
      final int retries=backup.retries;
      if (logger.isLoggable(Level.INFO)) {
        logger.log(Level.INFO,"String_Node_Str" + retries + "String_Node_Str"+ backup);
      }
      scheduler.schedule(entry.getScheduledDelayMillis() * retries,entry.getKey(),backup);
    }
  }
}
Program: 49195
Project: 49195
Buggy source:
public static <T>Iterator<T> iterator(final Class<T> clazz,final String factoryId,final ClassLoader classLoader) throws Exception {
  final Set<ServiceDefinition> classDefinitions=parse(factoryId,classLoader);
  if (ServiceLoader.class.getClassLoader() != classLoader) {
    classDefinitions.addAll(parse(factoryId,ServiceLoader.class.getClassLoader()));
  }
  return new Iterator<T>(){
    final Iterator<ServiceDefinition> classIter=classDefinitions.iterator();
    public boolean hasNext(){
      return classIter.hasNext();
    }
    public T next(){
      final ServiceDefinition classDefinition=classIter.next();
      try {
        String className=classDefinition.className;
        ClassLoader classLoader=classDefinition.classLoader;
        return clazz.cast(ClassLoaderUtil.newInstance(classLoader,className));
      }
 catch (      Exception e) {
        throw new HazelcastException(e);
      }
    }
    public void remove(){
      throw new UnsupportedOperationException();
    }
  }
;
}

Fixed version (ground truth):
public static <T>Iterator<T> iterator(final Class<T> clazz,final String factoryId,final ClassLoader classLoader) throws Exception {
  final Set<ServiceDefinition> classDefinitions=parse(factoryId,classLoader);
  if (classLoader != null && ServiceLoader.class.getClassLoader() != classLoader) {
    classDefinitions.addAll(parse(factoryId,ServiceLoader.class.getClassLoader()));
  }
  return new Iterator<T>(){
    final Iterator<ServiceDefinition> classIter=classDefinitions.iterator();
    public boolean hasNext(){
      return classIter.hasNext();
    }
    public T next(){
      final ServiceDefinition classDefinition=classIter.next();
      try {
        String className=classDefinition.className;
        ClassLoader classLoader=classDefinition.classLoader;
        return clazz.cast(ClassLoaderUtil.newInstance(classLoader,className));
      }
 catch (      Exception e) {
        throw new HazelcastException(e);
      }
    }
    public void remove(){
      throw new UnsupportedOperationException();
    }
  }
;
}
Program: 49196
Project: 49196
Buggy source:
public T next(){
  final String className=classIter.next();
  try {
    return clazz.cast(ClassLoaderUtil.newInstance(classLoader,className));
  }
 catch (  Exception e) {
    throw new HazelcastException(e);
  }
}

Fixed version (ground truth):
public T next(){
  final ServiceDefinition classDefinition=classIter.next();
  try {
    String className=classDefinition.className;
    ClassLoader classLoader=classDefinition.classLoader;
    return clazz.cast(ClassLoaderUtil.newInstance(classLoader,className));
  }
 catch (  Exception e) {
    throw new HazelcastException(e);
  }
}
Program: 49197
Project: 49197
Buggy source:
public static <T>Iterator<T> iterator(final Class<T> clazz,final String factoryId,final ClassLoader classLoader) throws Exception {
  final Set<String> classNames=parse(factoryId,classLoader);
  return new Iterator<T>(){
    final Iterator<String> classIter=classNames.iterator();
    public boolean hasNext(){
      return classIter.hasNext();
    }
    public T next(){
      final String className=classIter.next();
      try {
        return clazz.cast(ClassLoaderUtil.newInstance(classLoader,className));
      }
 catch (      Exception e) {
        throw new HazelcastException(e);
      }
    }
    public void remove(){
      throw new UnsupportedOperationException();
    }
  }
;
}

Fixed version (ground truth):
public static <T>Iterator<T> iterator(final Class<T> clazz,final String factoryId,final ClassLoader classLoader) throws Exception {
  final Set<ServiceDefinition> classDefinitions=parse(factoryId,classLoader);
  if (ServiceLoader.class.getClassLoader() != classLoader) {
    classDefinitions.addAll(parse(factoryId,ServiceLoader.class.getClassLoader()));
  }
  return new Iterator<T>(){
    final Iterator<ServiceDefinition> classIter=classDefinitions.iterator();
    public boolean hasNext(){
      return classIter.hasNext();
    }
    public T next(){
      final ServiceDefinition classDefinition=classIter.next();
      try {
        String className=classDefinition.className;
        ClassLoader classLoader=classDefinition.classLoader;
        return clazz.cast(ClassLoaderUtil.newInstance(classLoader,className));
      }
 catch (      Exception e) {
        throw new HazelcastException(e);
      }
    }
    public void remove(){
      throw new UnsupportedOperationException();
    }
  }
;
}
Program: 49198
Project: 49198
Buggy source:
private static Set<String> parse(String factoryId,ClassLoader classLoader){
  final ClassLoader cl=(classLoader == null) ? Thread.currentThread().getContextClassLoader() : classLoader;
  final String resourceName="String_Node_Str" + factoryId;
  try {
    final Enumeration<URL> configs;
    if (cl != null) {
      configs=cl.getResources(resourceName);
    }
 else {
      configs=ClassLoader.getSystemResources(resourceName);
    }
    final Set<String> names=new HashSet<String>();
    while (configs.hasMoreElements()) {
      URL url=configs.nextElement();
      BufferedReader r=null;
      try {
        r=new BufferedReader(new InputStreamReader(url.openStream(),"String_Node_Str"));
        while (true) {
          String line=r.readLine();
          if (line == null) {
            break;
          }
          int comment=line.indexOf('#');
          if (comment >= 0) {
            line=line.substring(0,comment);
          }
          String name=line.trim();
          if (name.length() == 0) {
            continue;
          }
          names.add(name);
        }
      }
  finally {
        IOUtil.closeResource(r);
      }
    }
    return names;
  }
 catch (  Exception e) {
    logger.log(Level.SEVERE,e.getMessage(),e);
  }
  return Collections.emptySet();
}

Fixed version (ground truth):
private static Set<ServiceDefinition> parse(String factoryId,ClassLoader classLoader){
  final ClassLoader cl=(classLoader == null) ? Thread.currentThread().getContextClassLoader() : classLoader;
  final String resourceName="String_Node_Str" + factoryId;
  try {
    final Enumeration<URL> configs;
    if (cl != null) {
      configs=cl.getResources(resourceName);
    }
 else {
      configs=ClassLoader.getSystemResources(resourceName);
    }
    final Set<ServiceDefinition> names=new HashSet<ServiceDefinition>();
    while (configs.hasMoreElements()) {
      URL url=configs.nextElement();
      BufferedReader r=null;
      try {
        r=new BufferedReader(new InputStreamReader(url.openStream(),"String_Node_Str"));
        while (true) {
          String line=r.readLine();
          if (line == null) {
            break;
          }
          int comment=line.indexOf('#');
          if (comment >= 0) {
            line=line.substring(0,comment);
          }
          String name=line.trim();
          if (name.length() == 0) {
            continue;
          }
          names.add(new ServiceDefinition(name,classLoader));
        }
      }
  finally {
        IOUtil.closeResource(r);
      }
    }
    return names;
  }
 catch (  Exception e) {
    logger.log(Level.SEVERE,e.getMessage(),e);
  }
  return Collections.emptySet();
}
Program: 49199
Project: 49199
Buggy source:
public static void shutdownAll(){
  final List<HazelcastInstanceProxy> instances=new ArrayList<HazelcastInstanceProxy>(INSTANCE_MAP.values());
  INSTANCE_MAP.clear();
  Collections.sort(instances,new Comparator<HazelcastInstanceProxy>(){
    public int compare(    HazelcastInstanceProxy o1,    HazelcastInstanceProxy o2){
      return o1.getName().compareTo(o2.getName());
    }
  }
);
  for (  HazelcastInstanceProxy proxy : instances) {
    proxy.getLifecycleService().shutdown();
    proxy.original=null;
  }
  ManagementService.shutdownAll();
}

Fixed version (ground truth):
public static void shutdownAll(){
  final List<HazelcastInstanceProxy> instances=new ArrayList<HazelcastInstanceProxy>(INSTANCE_MAP.values());
  INSTANCE_MAP.clear();
  ManagementService.shutdownAll();
  Collections.sort(instances,new Comparator<HazelcastInstanceProxy>(){
    public int compare(    HazelcastInstanceProxy o1,    HazelcastInstanceProxy o2){
      return o1.getName().compareTo(o2.getName());
    }
  }
);
  for (  HazelcastInstanceProxy proxy : instances) {
    proxy.getLifecycleService().shutdown();
    proxy.original=null;
  }
}
Program: 49200
Project: 49200
Buggy source:
private HazelcastMBean createHazelcastBean(DistributedObject distributedObject){
  if (distributedObject instanceof IList) {
    return new ListMBean((IList)distributedObject,this);
  }
  if (distributedObject instanceof IAtomicLong) {
    return new AtomicLongMBean((IAtomicLong)distributedObject,this);
  }
  if (distributedObject instanceof ICountDownLatch) {
    return new CountDownLatchMBean((ICountDownLatch)distributedObject,this);
  }
  if (distributedObject instanceof ILock) {
    return new LockMBean((ILock)distributedObject,this);
  }
  if (distributedObject instanceof IMap) {
    return new MapMBean((IMap)distributedObject,this);
  }
  if (distributedObject instanceof MultiMap) {
    return new MultiMapMBean((MultiMap)distributedObject,this);
  }
  if (distributedObject instanceof IQueue) {
    return new QueueMBean((IQueue)distributedObject,this);
  }
  if (distributedObject instanceof ISemaphore) {
    return new SemaphoreMBean((ISemaphore)distributedObject,this);
  }
  if (distributedObject instanceof ISet) {
    return new SetMBean((ISet)distributedObject,this);
  }
  if (distributedObject instanceof ITopic) {
    return new TopicMBean((ITopic)distributedObject,this);
  }
  return null;
}

Fixed version (ground truth):
private HazelcastMBean createHazelcastBean(DistributedObject distributedObject){
  try {
    if (distributedObject instanceof IList) {
      return new ListMBean((IList)distributedObject,this);
    }
    if (distributedObject instanceof IAtomicLong) {
      return new AtomicLongMBean((IAtomicLong)distributedObject,this);
    }
    if (distributedObject instanceof ICountDownLatch) {
      return new CountDownLatchMBean((ICountDownLatch)distributedObject,this);
    }
    if (distributedObject instanceof ILock) {
      return new LockMBean((ILock)distributedObject,this);
    }
    if (distributedObject instanceof IMap) {
      return new MapMBean((IMap)distributedObject,this);
    }
    if (distributedObject instanceof MultiMap) {
      return new MultiMapMBean((MultiMap)distributedObject,this);
    }
    if (distributedObject instanceof IQueue) {
      return new QueueMBean((IQueue)distributedObject,this);
    }
    if (distributedObject instanceof ISemaphore) {
      return new SemaphoreMBean((ISemaphore)distributedObject,this);
    }
    if (distributedObject instanceof ISet) {
      return new SetMBean((ISet)distributedObject,this);
    }
    if (distributedObject instanceof ITopic) {
      return new TopicMBean((ITopic)distributedObject,this);
    }
  }
 catch (  HazelcastInstanceNotActiveException ignored) {
  }
  return null;
}
Program: 49201
Project: 49201
Buggy source:
void handleMaster(Address masterAddress){
  lock.lock();
  try {
    if (!node.joined() && !node.getThisAddress().equals(masterAddress)) {
      logger.log(Level.FINEST,"String_Node_Str" + this);
      final Address currentMaster=node.getMasterAddress();
      if (currentMaster != null && !currentMaster.equals(masterAddress)) {
        final Connection conn=node.connectionManager.getConnection(currentMaster);
        if (conn != null && conn.live()) {
          logger.log(Level.WARNING,"String_Node_Str" + this + "String_Node_Str"+ currentMaster);
          return;
        }
      }
      node.setMasterAddress(masterAddress);
      node.connectionManager.getOrConnect(masterAddress);
      if (!sendJoinRequest(masterAddress,true)) {
        logger.log(Level.WARNING,"String_Node_Str" + masterAddress);
      }
    }
  }
  finally {
    lock.unlock();
  }
}

Fixed version (ground truth):
void handleMaster(Address masterAddress){
  lock.lock();
  try {
    if (!node.joined() && !node.getThisAddress().equals(masterAddress)) {
      logger.log(Level.FINEST,"String_Node_Str" + this);
      final Address currentMaster=node.getMasterAddress();
      if (currentMaster != null && !currentMaster.equals(masterAddress)) {
        final Connection conn=node.connectionManager.getConnection(currentMaster);
        if (conn != null && conn.live()) {
          logger.log(Level.WARNING,"String_Node_Str" + masterAddress + "String_Node_Str"+ currentMaster);
          return;
        }
      }
      node.setMasterAddress(masterAddress);
      node.connectionManager.getOrConnect(masterAddress);
      if (!sendJoinRequest(masterAddress,true)) {
        logger.log(Level.WARNING,"String_Node_Str" + masterAddress);
      }
    }
  }
  finally {
    lock.unlock();
  }
}