nus-yam/ex-repair huggingface dataset:
Program: 48591
Project: 48591
Buggy source:
public void run(){
  final NodeEngine nodeEngine=mapService.getNodeEngine();
  try {
    Map values=mapContainer.getStore().loadAll(keys.values());
    if (values == null || values.isEmpty()) {
      if (checkIfMapLoaded.decrementAndGet() == 0) {
        loaded.set(true);
      }
      return;
    }
    MapEntrySet entrySet=new MapEntrySet();
    for (    Data dataKey : keys.keySet()) {
      Object key=keys.get(dataKey);
      Object value=values.get(key);
      if (value != null) {
        Data dataValue=mapService.toData(value);
        entrySet.add(dataKey,dataValue);
      }
    }
    PutAllOperation operation=new PutAllOperation(name,entrySet,true);
    operation.setNodeEngine(nodeEngine);
    operation.setResponseHandler(new ResponseHandler(){
      @Override public void sendResponse(      Object obj){
        if (checkIfMapLoaded.decrementAndGet() == 0) {
          loaded.set(true);
        }
      }
      public boolean isLocal(){
        return true;
      }
    }
);
    operation.setPartitionId(partitionId);
    OperationAccessor.setCallerAddress(operation,nodeEngine.getThisAddress());
    operation.setServiceName(MapService.SERVICE_NAME);
    nodeEngine.getOperationService().executeOperation(operation);
  }
 catch (  Exception e) {
    logger.warning("String_Node_Str" + e.toString());
  }
}

Fixed version (ground truth):
public void run(){
  final NodeEngine nodeEngine=mapService.getNodeEngine();
  try {
    Map values=mapContainer.getStore().loadAll(keys.values());
    if (values == null || values.isEmpty()) {
      if (checkIfMapLoaded.decrementAndGet() == 0) {
        loaded.set(true);
      }
      return;
    }
    MapEntrySet entrySet=new MapEntrySet();
    for (    Data dataKey : keys.keySet()) {
      Object key=keys.get(dataKey);
      Object value=values.get(key);
      if (value != null) {
        Data dataValue=mapService.toData(value);
        entrySet.add(dataKey,dataValue);
      }
    }
    PutAllOperation operation=new PutAllOperation(name,entrySet,true);
    operation.setNodeEngine(nodeEngine);
    operation.setResponseHandler(new ResponseHandler(){
      @Override public void sendResponse(      Object obj){
        if (checkIfMapLoaded.decrementAndGet() == 0) {
          loaded.set(true);
        }
      }
      public boolean isLocal(){
        return true;
      }
    }
);
    operation.setPartitionId(partitionId);
    OperationAccessor.setCallerAddress(operation,nodeEngine.getThisAddress());
    operation.setCallerUuid(nodeEngine.getLocalMember().getUuid());
    operation.setServiceName(MapService.SERVICE_NAME);
    nodeEngine.getOperationService().executeOperation(operation);
  }
 catch (  Exception e) {
    logger.warning("String_Node_Str" + e.toString());
  }
}
Program: 48592
Project: 48592
Buggy source:
private void scheduleBackup(Operation op,Backup backup,int partitionId,int replicaIndex){
  final RemoteCallKey key=new RemoteCallKey(op.getCallerAddress(),op.getCallerUuid(),op.getCallId());
  if (logger.isFinestEnabled()) {
    logger.finest("String_Node_Str" + backup);
  }
  backupScheduler.schedule(500,key,new ScheduledBackup(backup,partitionId,replicaIndex));
}

Fixed version (ground truth):
private void scheduleBackup(Operation op,Backup backup,int partitionId,int replicaIndex){
  final RemoteCallKey key=new RemoteCallKey(op);
  if (logger.isFinestEnabled()) {
    logger.finest("String_Node_Str" + backup);
  }
  backupScheduler.schedule(500,key,new ScheduledBackup(backup,partitionId,replicaIndex));
}
Program: 48593
Project: 48593
Buggy source:
private RemoteCallKey(Address callerAddress,String callerUuid,long callId){
  this.callerAddress=callerAddress;
  this.callerUuid=callerUuid;
  this.callId=callId;
}

Fixed version (ground truth):
private RemoteCallKey(final Operation op){
  callerUuid=op.getCallerUuid();
  if (callerUuid == null) {
    throw new IllegalArgumentException("String_Node_Str" + op);
  }
  callerAddress=op.getCallerAddress();
  if (callerAddress == null) {
    throw new IllegalArgumentException("String_Node_Str" + op);
  }
  callId=op.getCallId();
}
Program: 48594
Project: 48594
Buggy source:
private RemoteCallKey beforeCallExecution(Operation op){
  RemoteCallKey callKey=null;
  if (op.getCallId() != 0 && op.returnsResponse()) {
    callKey=new RemoteCallKey(op.getCallerAddress(),op.getCallerUuid(),op.getCallId());
    RemoteCallKey current;
    if ((current=executingCalls.put(callKey,callKey)) != null) {
      logger.warning("String_Node_Str" + callKey + "String_Node_Str"+ current+ "String_Node_Str"+ op.getClass().getName());
    }
  }
  return callKey;
}

Fixed version (ground truth):
private RemoteCallKey beforeCallExecution(Operation op){
  RemoteCallKey callKey=null;
  if (op.getCallId() != 0 && op.returnsResponse()) {
    callKey=new RemoteCallKey(op);
    RemoteCallKey current;
    if ((current=executingCalls.put(callKey,callKey)) != null) {
      logger.warning("String_Node_Str" + callKey + "String_Node_Str"+ current+ "String_Node_Str"+ op.getClass().getName());
    }
  }
  return callKey;
}
Program: 48595
Project: 48595
Buggy source:
public void initializeDistributedObject(String serviceName,String name){
  if (serviceName == null) {
    throw new NullPointerException("String_Node_Str");
  }
  if (name == null) {
    throw new NullPointerException("String_Node_Str");
  }
  ProxyRegistry registry=ConcurrencyUtil.getOrPutIfAbsent(registries,serviceName,registryConstructor);
  registry.getProxy(name,true,true);
}

Fixed version (ground truth):
public void initializeDistributedObject(String serviceName,String name){
  if (serviceName == null) {
    throw new NullPointerException("String_Node_Str");
  }
  if (name == null) {
    throw new NullPointerException("String_Node_Str");
  }
  ProxyRegistry registry=ConcurrencyUtil.getOrPutIfAbsent(registries,serviceName,registryConstructor);
  registry.createProxy(name,true,true);
}
Program: 48596
Project: 48596
Buggy source:
DistributedObject destroyProxy(String name,boolean publishEvent){
  final DistributedObject proxy;
  if ((proxy=proxies.remove(name)) != null) {
    nodeEngine.eventService.executeEvent(new ProxyEventProcessor(DESTROYED,serviceName,proxy));
    if (publishEvent) {
      publish(new DistributedObjectEventPacket(DESTROYED,serviceName,name));
    }
    return proxy;
  }
  return null;
}

Fixed version (ground truth):
void destroyProxy(String name,boolean publishEvent){
  final DistributedObject proxy=proxies.remove(name);
  if (proxy != null) {
    nodeEngine.eventService.executeEvent(new ProxyEventProcessor(DESTROYED,serviceName,proxy));
    if (publishEvent) {
      publish(new DistributedObjectEventPacket(DESTROYED,serviceName,name));
    }
  }
}
Program: 48597
Project: 48597
Buggy source:
public void dispatchEvent(final DistributedObjectEventPacket eventPacket,Object ignore){
  final String serviceName=eventPacket.getServiceName();
  if (eventPacket.getEventType() == CREATED) {
    try {
      final ProxyRegistry registry=ConcurrencyUtil.getOrPutIfAbsent(registries,serviceName,registryConstructor);
      if (!registry.contains(eventPacket.getName())) {
        registry.getProxy(eventPacket.getName(),false,true);
      }
    }
 catch (    HazelcastInstanceNotActiveException ignored) {
    }
  }
 else {
    final ProxyRegistry registry=registries.get(serviceName);
    if (registry != null) {
      registry.destroyProxy(eventPacket.getName(),false);
    }
  }
}

Fixed version (ground truth):
public void dispatchEvent(final DistributedObjectEventPacket eventPacket,Object ignore){
  final String serviceName=eventPacket.getServiceName();
  if (eventPacket.getEventType() == CREATED) {
    try {
      final ProxyRegistry registry=ConcurrencyUtil.getOrPutIfAbsent(registries,serviceName,registryConstructor);
      if (!registry.contains(eventPacket.getName())) {
        registry.createProxy(eventPacket.getName(),false,true);
      }
    }
 catch (    HazelcastInstanceNotActiveException ignored) {
    }
  }
 else {
    final ProxyRegistry registry=registries.get(serviceName);
    if (registry != null) {
      registry.destroyProxy(eventPacket.getName(),false);
    }
  }
}
Program: 48598
Project: 48598
Buggy source:
public DistributedObject getDistributedObject(String serviceName,String name){
  if (serviceName == null) {
    throw new NullPointerException("String_Node_Str");
  }
  if (name == null) {
    throw new NullPointerException("String_Node_Str");
  }
  ProxyRegistry registry=ConcurrencyUtil.getOrPutIfAbsent(registries,serviceName,registryConstructor);
  return registry.getProxy(name,true,true);
}

Fixed version (ground truth):
public DistributedObject getDistributedObject(String serviceName,String name){
  if (serviceName == null) {
    throw new NullPointerException("String_Node_Str");
  }
  if (name == null) {
    throw new NullPointerException("String_Node_Str");
  }
  ProxyRegistry registry=ConcurrencyUtil.getOrPutIfAbsent(registries,serviceName,registryConstructor);
  return registry.getOrCreateProxy(name,true,true);
}
Program: 48599
Project: 48599
Buggy source:
public void initializeDistributedObject(String serviceName,String name){
  if (serviceName == null) {
    throw new NullPointerException("String_Node_Str");
  }
  if (name == null) {
    throw new NullPointerException("String_Node_Str");
  }
  ProxyRegistry registry=ConcurrencyUtil.getOrPutIfAbsent(registries,serviceName,registryConstructor);
  registry.getProxy(name,true,true);
}

Fixed version (ground truth):
public void initializeDistributedObject(String serviceName,String name){
  if (serviceName == null) {
    throw new NullPointerException("String_Node_Str");
  }
  if (name == null) {
    throw new NullPointerException("String_Node_Str");
  }
  ProxyRegistry registry=ConcurrencyUtil.getOrPutIfAbsent(registries,serviceName,registryConstructor);
  registry.createProxy(name,true,true);
}
Program: 48600
Project: 48600
Buggy source:
DistributedObject destroyProxy(String name,boolean publishEvent){
  final DistributedObject proxy;
  if ((proxy=proxies.remove(name)) != null) {
    nodeEngine.eventService.executeEvent(new ProxyEventProcessor(DESTROYED,serviceName,proxy));
    if (publishEvent) {
      publish(new DistributedObjectEventPacket(DESTROYED,serviceName,name));
    }
    return proxy;
  }
  return null;
}

Fixed version (ground truth):
void destroyProxy(String name,boolean publishEvent){
  final DistributedObject proxy=proxies.remove(name);
  if (proxy != null) {
    nodeEngine.eventService.executeEvent(new ProxyEventProcessor(DESTROYED,serviceName,proxy));
    if (publishEvent) {
      publish(new DistributedObjectEventPacket(DESTROYED,serviceName,name));
    }
  }
}
Program: 48601
Project: 48601
Buggy source:
public void dispatchEvent(final DistributedObjectEventPacket eventPacket,Object ignore){
  final String serviceName=eventPacket.getServiceName();
  if (eventPacket.getEventType() == CREATED) {
    try {
      final ProxyRegistry registry=ConcurrencyUtil.getOrPutIfAbsent(registries,serviceName,registryConstructor);
      if (!registry.contains(eventPacket.getName())) {
        registry.getProxy(eventPacket.getName(),false,true);
      }
    }
 catch (    HazelcastInstanceNotActiveException ignored) {
    }
  }
 else {
    final ProxyRegistry registry=registries.get(serviceName);
    if (registry != null) {
      registry.destroyProxy(eventPacket.getName(),false);
    }
  }
}

Fixed version (ground truth):
public void dispatchEvent(final DistributedObjectEventPacket eventPacket,Object ignore){
  final String serviceName=eventPacket.getServiceName();
  if (eventPacket.getEventType() == CREATED) {
    try {
      final ProxyRegistry registry=ConcurrencyUtil.getOrPutIfAbsent(registries,serviceName,registryConstructor);
      if (!registry.contains(eventPacket.getName())) {
        registry.createProxy(eventPacket.getName(),false,true);
      }
    }
 catch (    HazelcastInstanceNotActiveException ignored) {
    }
  }
 else {
    final ProxyRegistry registry=registries.get(serviceName);
    if (registry != null) {
      registry.destroyProxy(eventPacket.getName(),false);
    }
  }
}
Program: 48602
Project: 48602
Buggy source:
public DistributedObject getDistributedObject(String serviceName,String name){
  if (serviceName == null) {
    throw new NullPointerException("String_Node_Str");
  }
  if (name == null) {
    throw new NullPointerException("String_Node_Str");
  }
  ProxyRegistry registry=ConcurrencyUtil.getOrPutIfAbsent(registries,serviceName,registryConstructor);
  return registry.getProxy(name,true,true);
}

Fixed version (ground truth):
public DistributedObject getDistributedObject(String serviceName,String name){
  if (serviceName == null) {
    throw new NullPointerException("String_Node_Str");
  }
  if (name == null) {
    throw new NullPointerException("String_Node_Str");
  }
  ProxyRegistry registry=ConcurrencyUtil.getOrPutIfAbsent(registries,serviceName,registryConstructor);
  return registry.getOrCreateProxy(name,true,true);
}
Program: 48603
Project: 48603
Buggy source:
public boolean replaceIfSameInternal(Data key,Object oldValue,Data newValue){
  VersionedValue versionedValue=lockAndGet(key,tx.getTimeoutMillis());
  if (versionedValue == null) {
    throw new TransactionException("String_Node_Str");
  }
  if (!getService().compare(name,oldValue,versionedValue.value))   return false;
  tx.addTransactionLog(new MapTransactionLog(name,key,new TxnSetOperation(name,key,newValue,-1,versionedValue.version),versionedValue.version));
  return true;
}

Fixed version (ground truth):
public boolean replaceIfSameInternal(Data key,Object oldValue,Data newValue){
  VersionedValue versionedValue=lockAndGet(key,tx.getTimeoutMillis());
  if (!getService().compare(name,oldValue,versionedValue.value))   return false;
  tx.addTransactionLog(new MapTransactionLog(name,key,new TxnSetOperation(name,key,newValue,-1,versionedValue.version),versionedValue.version));
  return true;
}
Program: 48604
Project: 48604
Buggy source:
public boolean removeIfSameInternal(Data key,Object value){
  VersionedValue versionedValue=lockAndGet(key,tx.getTimeoutMillis());
  if (versionedValue == null) {
    throw new TransactionException("String_Node_Str");
  }
  if (!getService().compare(name,versionedValue.value,value)) {
    return false;
  }
  tx.addTransactionLog(new MapTransactionLog(name,key,new TxnDeleteOperation(name,key,versionedValue.version),versionedValue.version));
  return true;
}

Fixed version (ground truth):
public boolean removeIfSameInternal(Data key,Object value){
  VersionedValue versionedValue=lockAndGet(key,tx.getTimeoutMillis());
  if (!getService().compare(name,versionedValue.value,value)) {
    return false;
  }
  tx.addTransactionLog(new MapTransactionLog(name,key,new TxnDeleteOperation(name,key,versionedValue.version),versionedValue.version));
  return true;
}
Program: 48605
Project: 48605
Buggy source:
public Data replaceInternal(Data key,Data value){
  VersionedValue versionedValue=lockAndGet(key,tx.getTimeoutMillis());
  if (versionedValue == null) {
    throw new TransactionException("String_Node_Str");
  }
  if (versionedValue.value == null)   return null;
  tx.addTransactionLog(new MapTransactionLog(name,key,new TxnSetOperation(name,key,value,-1,versionedValue.version),versionedValue.version));
  return versionedValue.value;
}

Fixed version (ground truth):
public Data replaceInternal(Data key,Data value){
  VersionedValue versionedValue=lockAndGet(key,tx.getTimeoutMillis());
  if (versionedValue.value == null)   return null;
  tx.addTransactionLog(new MapTransactionLog(name,key,new TxnSetOperation(name,key,value,-1,versionedValue.version),versionedValue.version));
  return versionedValue.value;
}
Program: 48606
Project: 48606
Buggy source:
private VersionedValue lockAndGet(Data key,long timeout){
  final NodeEngine nodeEngine=getNodeEngine();
  TxnLockAndGetOperation operation=new TxnLockAndGetOperation(name,key,timeout,timeout);
  operation.setThreadId(ThreadUtil.getThreadId());
  try {
    int partitionId=nodeEngine.getPartitionService().getPartitionId(key);
    Invocation invocation=nodeEngine.getOperationService().createInvocationBuilder(MapService.SERVICE_NAME,operation,partitionId).build();
    Future<VersionedValue> f=invocation.invoke();
    return f.get();
  }
 catch (  Throwable t) {
    throw ExceptionUtil.rethrow(t);
  }
}

Fixed version (ground truth):
private VersionedValue lockAndGet(Data key,long timeout){
  VersionedValue versionedValue=valueMap.get(key);
  if (versionedValue != null) {
    return versionedValue;
  }
  final NodeEngine nodeEngine=getNodeEngine();
  TxnLockAndGetOperation operation=new TxnLockAndGetOperation(name,key,timeout,timeout);
  operation.setThreadId(ThreadUtil.getThreadId());
  try {
    int partitionId=nodeEngine.getPartitionService().getPartitionId(key);
    Invocation invocation=nodeEngine.getOperationService().createInvocationBuilder(MapService.SERVICE_NAME,operation,partitionId).build();
    Future<VersionedValue> f=invocation.invoke();
    versionedValue=f.get();
    if (versionedValue == null) {
      throw new TransactionException("String_Node_Str");
    }
    valueMap.put(key,versionedValue);
    return versionedValue;
  }
 catch (  Throwable t) {
    throw ExceptionUtil.rethrow(t);
  }
}
Program: 48607
Project: 48607
Buggy source:
public Data putInternal(Data key,Data value){
  VersionedValue versionedValue=lockAndGet(key,tx.getTimeoutMillis());
  if (versionedValue == null) {
    throw new TransactionException("String_Node_Str");
  }
  tx.addTransactionLog(new MapTransactionLog(name,key,new TxnSetOperation(name,key,value,-1,versionedValue.version),versionedValue.version));
  return versionedValue.value;
}

Fixed version (ground truth):
public Data putInternal(Data key,Data value){
  VersionedValue versionedValue=lockAndGet(key,tx.getTimeoutMillis());
  tx.addTransactionLog(new MapTransactionLog(name,key,new TxnSetOperation(name,key,value,-1,versionedValue.version),versionedValue.version));
  return versionedValue.value;
}
Program: 48608
Project: 48608
Buggy source:
public Data removeInternal(Data key){
  VersionedValue versionedValue=lockAndGet(key,tx.getTimeoutMillis());
  if (versionedValue == null) {
    throw new TransactionException("String_Node_Str");
  }
  tx.addTransactionLog(new MapTransactionLog(name,key,new TxnDeleteOperation(name,key,versionedValue.version),versionedValue.version));
  return versionedValue.value;
}

Fixed version (ground truth):
public Data removeInternal(Data key){
  VersionedValue versionedValue=lockAndGet(key,tx.getTimeoutMillis());
  tx.addTransactionLog(new MapTransactionLog(name,key,new TxnDeleteOperation(name,key,versionedValue.version),versionedValue.version));
  return versionedValue.value;
}
Program: 48609
Project: 48609
Buggy source:
public Data putIfAbsentInternal(Data key,Data value){
  VersionedValue versionedValue=lockAndGet(key,tx.getTimeoutMillis());
  if (versionedValue == null) {
    throw new TransactionException("String_Node_Str");
  }
  if (versionedValue.value != null)   return versionedValue.value;
  tx.addTransactionLog(new MapTransactionLog(name,key,new TxnSetOperation(name,key,value,-1,versionedValue.version),versionedValue.version));
  return versionedValue.value;
}

Fixed version (ground truth):
public Data putIfAbsentInternal(Data key,Data value){
  VersionedValue versionedValue=lockAndGet(key,tx.getTimeoutMillis());
  if (versionedValue.value != null)   return versionedValue.value;
  tx.addTransactionLog(new MapTransactionLog(name,key,new TxnSetOperation(name,key,value,-1,versionedValue.version),versionedValue.version));
  return versionedValue.value;
}
Program: 48611
Project: 48611
Buggy source:
@Override protected <T>ICompletableFuture<T> invoke(final Collator collator){
  try {
    ClientContext context=getContext();
    ClientInvocationService cis=context.getInvocationService();
    ClientMapReduceRequest request=new ClientMapReduceRequest(name,jobId,keys,predicate,mapper,combinerFactory,reducerFactory,keyValueSource,chunkSize);
    final ClientCompletableFuture completableFuture=new ClientCompletableFuture(jobId);
    ClientCallFuture future=(ClientCallFuture)cis.invokeOnRandomTarget(request,new EventHandler(){
      @Override public void handle(      Object event){
        if (collator != null) {
          event=collator.collate(((Map)event).entrySet());
        }
        completableFuture.setResult(event);
        trackableJobs.remove(getJobId());
      }
    }
);
    Address runningMember=future.getConnection().getRemoteEndpoint();
    trackableJobs.putIfAbsent(jobId,new ClientTrackableJob<T>(jobId,runningMember,completableFuture));
    return completableFuture;
  }
 catch (  Exception e) {
    throw new RuntimeException(e);
  }
}

Fixed version (ground truth):
@Override protected <T>JobCompletableFuture<T> invoke(final Collator collator){
  try {
    final String jobId=UuidUtil.buildRandomUuidString();
    ClientContext context=getContext();
    ClientInvocationService cis=context.getInvocationService();
    ClientMapReduceRequest request=new ClientMapReduceRequest(name,jobId,keys,predicate,mapper,combinerFactory,reducerFactory,keyValueSource,chunkSize,topologyChangedStrategy);
    final ClientCompletableFuture completableFuture=new ClientCompletableFuture(jobId);
    ClientCallFuture future=(ClientCallFuture)cis.invokeOnRandomTarget(request,null);
    future.andThen(new ExecutionCallback(){
      @Override public void onResponse(      Object response){
        try {
          if (collator != null) {
            response=collator.collate(((Map)response).entrySet());
          }
        }
  finally {
          completableFuture.setResult(response);
          trackableJobs.remove(jobId);
        }
      }
      @Override public void onFailure(      Throwable t){
        try {
          if (t instanceof ExecutionException && t.getCause() instanceof CancellationException) {
            t=t.getCause();
          }
          completableFuture.setResult(t);
        }
  finally {
          trackableJobs.remove(jobId);
        }
      }
    }
);
    Address runningMember=future.getConnection().getRemoteEndpoint();
    trackableJobs.putIfAbsent(jobId,new ClientTrackableJob<T>(jobId,runningMember,completableFuture));
    return completableFuture;
  }
 catch (  Exception e) {
    throw new RuntimeException(e);
  }
}
Program: 48612
Project: 48612
Buggy source:
@Override public V get(long timeout,TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
  ValidationUtil.isNotNull(unit,"String_Node_Str");
  long deadline=timeout == 0L ? -1 : Clock.currentTimeMillis() + unit.toMillis(timeout);
  for (; ; ) {
    try {
      Thread.sleep(100);
    }
 catch (    Exception e) {
      if (e instanceof InterruptedException) {
        throw (InterruptedException)e;
      }
    }
    if (isDone()) {
      break;
    }
    long delta=deadline - Clock.currentTimeMillis();
    if (delta <= 0L) {
      throw new TimeoutException("String_Node_Str");
    }
  }
  return getResult();
}

Fixed version (ground truth):
@Override public V get(long timeout,TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
  ValidationUtil.isNotNull(unit,"String_Node_Str");
  long deadline=timeout == 0L ? -1 : Clock.currentTimeMillis() + unit.toMillis(timeout);
  for (; ; ) {
    try {
      Thread.sleep(100);
    }
 catch (    InterruptedException e) {
      throw e;
    }
    if (isDone()) {
      break;
    }
    long delta=deadline - Clock.currentTimeMillis();
    if (delta <= 0L) {
      throw new TimeoutException("String_Node_Str");
    }
  }
  return getResult();
}
Program: 48613
Project: 48613
Buggy source:
@Test(timeout=30000) public void testMapperCollator() throws Exception {
  Config config=buildConfig();
  HazelcastInstance h1=Hazelcast.newHazelcastInstance(config);
  HazelcastInstance h2=Hazelcast.newHazelcastInstance(config);
  HazelcastInstance h3=Hazelcast.newHazelcastInstance(config);
  HazelcastInstance client=HazelcastClient.newHazelcastClient(null);
  IMap<Integer,Integer> m1=client.getMap(MAP_NAME);
  for (int i=0; i < 100; i++) {
    m1.put(i,i);
  }
  JobTracker tracker=client.getJobTracker("String_Node_Str");
  Job<Integer,Integer> job=tracker.newJob(KeyValueSource.fromMap(m1));
  ICompletableFuture<Integer> future=job.mapper(new GroupingTestMapper()).submit(new GroupingTestCollator());
  int result=future.get();
  int expectedResult=0;
  for (int i=0; i < 100; i++) {
    expectedResult+=i;
  }
}

Fixed version (ground truth):
@Test(timeout=60000) public void testMapperCollator() throws Exception {
  Config config=buildConfig();
  HazelcastInstance h1=Hazelcast.newHazelcastInstance(config);
  HazelcastInstance h2=Hazelcast.newHazelcastInstance(config);
  HazelcastInstance h3=Hazelcast.newHazelcastInstance(config);
  HazelcastInstance client=HazelcastClient.newHazelcastClient(null);
  IMap<Integer,Integer> m1=client.getMap(MAP_NAME);
  for (int i=0; i < 100; i++) {
    m1.put(i,i);
  }
  JobTracker tracker=client.getJobTracker("String_Node_Str");
  Job<Integer,Integer> job=tracker.newJob(KeyValueSource.fromMap(m1));
  ICompletableFuture<Integer> future=job.mapper(new GroupingTestMapper()).submit(new GroupingTestCollator());
  int result=future.get();
  int expectedResult=0;
  for (int i=0; i < 100; i++) {
    expectedResult+=i;
  }
}
Program: 48614
Project: 48614
Buggy source:
@Test(timeout=30000) public void testKeyedMapperCollator() throws Exception {
  Config config=buildConfig();
  HazelcastInstance h1=Hazelcast.newHazelcastInstance(config);
  HazelcastInstance h2=Hazelcast.newHazelcastInstance(config);
  HazelcastInstance h3=Hazelcast.newHazelcastInstance(config);
  HazelcastInstance client=HazelcastClient.newHazelcastClient(null);
  IMap<Integer,Integer> m1=client.getMap(MAP_NAME);
  for (int i=0; i < 10000; i++) {
    m1.put(i,i);
  }
  JobTracker tracker=client.getJobTracker("String_Node_Str");
  Job<Integer,Integer> job=tracker.newJob(KeyValueSource.fromMap(m1));
  ICompletableFuture<Integer> future=job.onKeys(50).mapper(new TestMapper()).submit(new GroupingTestCollator());
  int result=future.get();
  assertEquals(50,result);
}

Fixed version (ground truth):
@Test(timeout=60000) public void testKeyedMapperCollator() throws Exception {
  Config config=buildConfig();
  HazelcastInstance h1=Hazelcast.newHazelcastInstance(config);
  HazelcastInstance h2=Hazelcast.newHazelcastInstance(config);
  HazelcastInstance h3=Hazelcast.newHazelcastInstance(config);
  HazelcastInstance client=HazelcastClient.newHazelcastClient(null);
  IMap<Integer,Integer> m1=client.getMap(MAP_NAME);
  for (int i=0; i < 10000; i++) {
    m1.put(i,i);
  }
  JobTracker tracker=client.getJobTracker("String_Node_Str");
  Job<Integer,Integer> job=tracker.newJob(KeyValueSource.fromMap(m1));
  ICompletableFuture<Integer> future=job.onKeys(50).mapper(new TestMapper()).submit(new GroupingTestCollator());
  int result=future.get();
  assertEquals(50,result);
}
Program: 48615
Project: 48615
Buggy source:
@Test(timeout=30000) public void testAsyncMapper() throws Exception {
  Config config=buildConfig();
  HazelcastInstance h1=Hazelcast.newHazelcastInstance(config);
  HazelcastInstance h2=Hazelcast.newHazelcastInstance(config);
  HazelcastInstance h3=Hazelcast.newHazelcastInstance(config);
  HazelcastInstance client=HazelcastClient.newHazelcastClient(null);
  IMap<Integer,Integer> m1=client.getMap(MAP_NAME);
  for (int i=0; i < 100; i++) {
    m1.put(i,i);
  }
  final Map<String,List<Integer>> listenerResults=new HashMap<String,List<Integer>>();
  final Semaphore semaphore=new Semaphore(1);
  semaphore.acquire();
  JobTracker tracker=client.getJobTracker("String_Node_Str");
  Job<Integer,Integer> job=tracker.newJob(KeyValueSource.fromMap(m1));
  ICompletableFuture<Map<String,List<Integer>>> future=job.mapper(new TestMapper()).submit();
  future.andThen(new ExecutionCallback<Map<String,List<Integer>>>(){
    @Override public void onResponse(    Map<String,List<Integer>> response){
      listenerResults.putAll(response);
      semaphore.release();
    }
    @Override public void onFailure(    Throwable t){
      semaphore.release();
    }
  }
);
  semaphore.acquire();
  assertEquals(100,listenerResults.size());
  for (  List<Integer> value : listenerResults.values()) {
    assertEquals(1,value.size());
  }
}

Fixed version (ground truth):
@Test(timeout=60000) public void testAsyncMapper() throws Exception {
  Config config=buildConfig();
  HazelcastInstance h1=Hazelcast.newHazelcastInstance(config);
  HazelcastInstance h2=Hazelcast.newHazelcastInstance(config);
  HazelcastInstance h3=Hazelcast.newHazelcastInstance(config);
  HazelcastInstance client=HazelcastClient.newHazelcastClient(null);
  IMap<Integer,Integer> m1=client.getMap(MAP_NAME);
  for (int i=0; i < 100; i++) {
    m1.put(i,i);
  }
  final Map<String,List<Integer>> listenerResults=new HashMap<String,List<Integer>>();
  final Semaphore semaphore=new Semaphore(1);
  semaphore.acquire();
  JobTracker tracker=client.getJobTracker("String_Node_Str");
  Job<Integer,Integer> job=tracker.newJob(KeyValueSource.fromMap(m1));
  ICompletableFuture<Map<String,List<Integer>>> future=job.mapper(new TestMapper()).submit();
  future.andThen(new ExecutionCallback<Map<String,List<Integer>>>(){
    @Override public void onResponse(    Map<String,List<Integer>> response){
      listenerResults.putAll(response);
      semaphore.release();
    }
    @Override public void onFailure(    Throwable t){
      semaphore.release();
    }
  }
);
  semaphore.acquire();
  assertEquals(100,listenerResults.size());
  for (  List<Integer> value : listenerResults.values()) {
    assertEquals(1,value.size());
  }
}
Program: 48616
Project: 48616
Buggy source:
@Test(timeout=30000) public void testMapper() throws Exception {
  Config config=buildConfig();
  HazelcastInstance h1=Hazelcast.newHazelcastInstance(config);
  HazelcastInstance h2=Hazelcast.newHazelcastInstance(config);
  HazelcastInstance h3=Hazelcast.newHazelcastInstance(config);
  HazelcastInstance client=HazelcastClient.newHazelcastClient(null);
  IMap<Integer,Integer> m1=client.getMap(MAP_NAME);
  for (int i=0; i < 100; i++) {
    m1.put(i,i);
  }
  JobTracker tracker=client.getJobTracker("String_Node_Str");
  Job<Integer,Integer> job=tracker.newJob(KeyValueSource.fromMap(m1));
  ICompletableFuture<Map<String,List<Integer>>> future=job.mapper(new TestMapper()).submit();
  Map<String,List<Integer>> result=future.get();
  assertEquals(100,result.size());
  for (  List<Integer> value : result.values()) {
    assertEquals(1,value.size());
  }
}

Fixed version (ground truth):
@Test(timeout=60000) public void testMapper() throws Exception {
  Config config=buildConfig();
  HazelcastInstance h1=Hazelcast.newHazelcastInstance(config);
  HazelcastInstance h2=Hazelcast.newHazelcastInstance(config);
  HazelcastInstance h3=Hazelcast.newHazelcastInstance(config);
  HazelcastInstance client=HazelcastClient.newHazelcastClient(null);
  IMap<Integer,Integer> m1=client.getMap(MAP_NAME);
  for (int i=0; i < 100; i++) {
    m1.put(i,i);
  }
  JobTracker tracker=client.getJobTracker("String_Node_Str");
  Job<Integer,Integer> job=tracker.newJob(KeyValueSource.fromMap(m1));
  ICompletableFuture<Map<String,List<Integer>>> future=job.mapper(new TestMapper()).submit();
  Map<String,List<Integer>> result=future.get();
  assertEquals(100,result.size());
  for (  List<Integer> value : result.values()) {
    assertEquals(1,value.size());
  }
}
Program: 48617
Project: 48617
Buggy source:
@Test(timeout=30000,expected=CancellationException.class) public void testInProcessCancellation() throws Exception {
  Config config=buildConfig();
  HazelcastInstance h1=Hazelcast.newHazelcastInstance(config);
  HazelcastInstance h2=Hazelcast.newHazelcastInstance(config);
  HazelcastInstance h3=Hazelcast.newHazelcastInstance(config);
  HazelcastInstance client=HazelcastClient.newHazelcastClient(null);
  IMap<Integer,Integer> m1=client.getMap(MAP_NAME);
  for (int i=0; i < 100; i++) {
    m1.put(i,i);
  }
  JobTracker tracker=h1.getJobTracker("String_Node_Str");
  Job<Integer,Integer> job=tracker.newJob(KeyValueSource.fromMap(m1));
  ICompletableFuture<Map<String,List<Integer>>> future=job.mapper(new TimeConsumingMapper()).submit();
  future.cancel(true);
  try {
    Map<String,List<Integer>> result=future.get();
  }
 catch (  Exception e) {
    e.printStackTrace();
    throw e;
  }
}

Fixed version (ground truth):
@Test(timeout=60000,expected=CancellationException.class) public void testInProcessCancellation() throws Exception {
  Config config=buildConfig();
  HazelcastInstance h1=Hazelcast.newHazelcastInstance(config);
  HazelcastInstance h2=Hazelcast.newHazelcastInstance(config);
  HazelcastInstance h3=Hazelcast.newHazelcastInstance(config);
  HazelcastInstance client=HazelcastClient.newHazelcastClient(null);
  IMap<Integer,Integer> m1=client.getMap(MAP_NAME);
  for (int i=0; i < 100; i++) {
    m1.put(i,i);
  }
  JobTracker tracker=client.getJobTracker("String_Node_Str");
  Job<Integer,Integer> job=tracker.newJob(KeyValueSource.fromMap(m1));
  ICompletableFuture<Map<String,List<Integer>>> future=job.mapper(new TimeConsumingMapper()).submit();
  future.cancel(true);
  try {
    Map<String,List<Integer>> result=future.get();
  }
 catch (  Exception e) {
    e.printStackTrace();
    throw e;
  }
}
Program: 48618
Project: 48618
Buggy source:
@Test(timeout=30000) public void testKeyPredicateMapperCollator() throws Exception {
  Config config=buildConfig();
  HazelcastInstance h1=Hazelcast.newHazelcastInstance(config);
  HazelcastInstance h2=Hazelcast.newHazelcastInstance(config);
  HazelcastInstance h3=Hazelcast.newHazelcastInstance(config);
  HazelcastInstance client=HazelcastClient.newHazelcastClient(null);
  IMap<Integer,Integer> m1=client.getMap(MAP_NAME);
  for (int i=0; i < 10000; i++) {
    m1.put(i,i);
  }
  JobTracker tracker=client.getJobTracker("String_Node_Str");
  Job<Integer,Integer> job=tracker.newJob(KeyValueSource.fromMap(m1));
  ICompletableFuture<Integer> future=job.keyPredicate(new TestKeyPredicate()).mapper(new TestMapper()).submit(new GroupingTestCollator());
  int result=future.get();
  assertEquals(50,result);
}

Fixed version (ground truth):
@Test(timeout=60000) public void testKeyPredicateMapperCollator() throws Exception {
  Config config=buildConfig();
  HazelcastInstance h1=Hazelcast.newHazelcastInstance(config);
  HazelcastInstance h2=Hazelcast.newHazelcastInstance(config);
  HazelcastInstance h3=Hazelcast.newHazelcastInstance(config);
  HazelcastInstance client=HazelcastClient.newHazelcastClient(null);
  IMap<Integer,Integer> m1=client.getMap(MAP_NAME);
  for (int i=0; i < 10000; i++) {
    m1.put(i,i);
  }
  JobTracker tracker=client.getJobTracker("String_Node_Str");
  Job<Integer,Integer> job=tracker.newJob(KeyValueSource.fromMap(m1));
  ICompletableFuture<Integer> future=job.keyPredicate(new TestKeyPredicate()).mapper(new TestMapper()).submit(new GroupingTestCollator());
  int result=future.get();
  assertEquals(50,result);
}
Program: 48619
Project: 48619
Buggy source:
@Test(timeout=30000) public void testMapperReducer() throws Exception {
  Config config=buildConfig();
  HazelcastInstance h1=Hazelcast.newHazelcastInstance(config);
  HazelcastInstance h2=Hazelcast.newHazelcastInstance(config);
  HazelcastInstance h3=Hazelcast.newHazelcastInstance(config);
  HazelcastInstance client=HazelcastClient.newHazelcastClient(null);
  IMap<Integer,Integer> m1=client.getMap(MAP_NAME);
  for (int i=0; i < 100; i++) {
    m1.put(i,i);
  }
  JobTracker tracker=client.getJobTracker("String_Node_Str");
  Job<Integer,Integer> job=tracker.newJob(KeyValueSource.fromMap(m1));
  ICompletableFuture<Map<String,Integer>> future=job.mapper(new GroupingTestMapper()).reducer(new TestReducerFactory()).submit();
  Map<String,Integer> result=future.get();
  int[] expectedResults=new int[4];
  for (int i=0; i < 100; i++) {
    int index=i % 4;
    expectedResults[index]+=i;
  }
  for (int i=0; i < 4; i++) {
    assertEquals(expectedResults[i],(int)result.get(String.valueOf(i)));
  }
}

Fixed version (ground truth):
@Test(timeout=60000) public void testMapperReducer() throws Exception {
  Config config=buildConfig();
  HazelcastInstance h1=Hazelcast.newHazelcastInstance(config);
  HazelcastInstance h2=Hazelcast.newHazelcastInstance(config);
  HazelcastInstance h3=Hazelcast.newHazelcastInstance(config);
  HazelcastInstance client=HazelcastClient.newHazelcastClient(null);
  IMap<Integer,Integer> m1=client.getMap(MAP_NAME);
  for (int i=0; i < 100; i++) {
    m1.put(i,i);
  }
  JobTracker tracker=client.getJobTracker("String_Node_Str");
  Job<Integer,Integer> job=tracker.newJob(KeyValueSource.fromMap(m1));
  ICompletableFuture<Map<String,Integer>> future=job.mapper(new GroupingTestMapper()).reducer(new TestReducerFactory()).submit();
  Map<String,Integer> result=future.get();
  int[] expectedResults=new int[4];
  for (int i=0; i < 100; i++) {
    int index=i % 4;
    expectedResults[index]+=i;
  }
  for (int i=0; i < 4; i++) {
    assertEquals(expectedResults[i],(int)result.get(String.valueOf(i)));
  }
}
Program: 48620
Project: 48620
Buggy source:
@Test(timeout=30000) public void testAsyncMapperCollator() throws Exception {
  Config config=buildConfig();
  HazelcastInstance h1=Hazelcast.newHazelcastInstance(config);
  HazelcastInstance h2=Hazelcast.newHazelcastInstance(config);
  HazelcastInstance h3=Hazelcast.newHazelcastInstance(config);
  HazelcastInstance client=HazelcastClient.newHazelcastClient(null);
  IMap<Integer,Integer> m1=client.getMap(MAP_NAME);
  for (int i=0; i < 100; i++) {
    m1.put(i,i);
  }
  final int[] result=new int[1];
  final Semaphore semaphore=new Semaphore(1);
  semaphore.acquire();
  JobTracker tracker=client.getJobTracker("String_Node_Str");
  Job<Integer,Integer> job=tracker.newJob(KeyValueSource.fromMap(m1));
  ICompletableFuture<Integer> future=job.mapper(new GroupingTestMapper()).submit(new GroupingTestCollator());
  future.andThen(new ExecutionCallback<Integer>(){
    @Override public void onResponse(    Integer response){
      result[0]=response.intValue();
      semaphore.release();
    }
    @Override public void onFailure(    Throwable t){
      semaphore.release();
    }
  }
);
  int expectedResult=0;
  for (int i=0; i < 100; i++) {
    expectedResult+=i;
  }
  semaphore.acquire();
  for (int i=0; i < 4; i++) {
    assertEquals(expectedResult,result[0]);
  }
}

Fixed version (ground truth):
@Test(timeout=60000) public void testAsyncMapperCollator() throws Exception {
  Config config=buildConfig();
  HazelcastInstance h1=Hazelcast.newHazelcastInstance(config);
  HazelcastInstance h2=Hazelcast.newHazelcastInstance(config);
  HazelcastInstance h3=Hazelcast.newHazelcastInstance(config);
  HazelcastInstance client=HazelcastClient.newHazelcastClient(null);
  IMap<Integer,Integer> m1=client.getMap(MAP_NAME);
  for (int i=0; i < 100; i++) {
    m1.put(i,i);
  }
  final int[] result=new int[1];
  final Semaphore semaphore=new Semaphore(1);
  semaphore.acquire();
  JobTracker tracker=client.getJobTracker("String_Node_Str");
  Job<Integer,Integer> job=tracker.newJob(KeyValueSource.fromMap(m1));
  ICompletableFuture<Integer> future=job.mapper(new GroupingTestMapper()).submit(new GroupingTestCollator());
  future.andThen(new ExecutionCallback<Integer>(){
    @Override public void onResponse(    Integer response){
      result[0]=response.intValue();
      semaphore.release();
    }
    @Override public void onFailure(    Throwable t){
      semaphore.release();
    }
  }
);
  int expectedResult=0;
  for (int i=0; i < 100; i++) {
    expectedResult+=i;
  }
  semaphore.acquire();
  for (int i=0; i < 4; i++) {
    assertEquals(expectedResult,result[0]);
  }
}
Program: 48621
Project: 48621
Buggy source:
@Test(timeout=30000) public void testAsyncMapperReducer() throws Exception {
  Config config=buildConfig();
  HazelcastInstance h1=Hazelcast.newHazelcastInstance(config);
  HazelcastInstance h2=Hazelcast.newHazelcastInstance(config);
  HazelcastInstance h3=Hazelcast.newHazelcastInstance(config);
  HazelcastInstance client=HazelcastClient.newHazelcastClient(null);
  IMap<Integer,Integer> m1=client.getMap(MAP_NAME);
  for (int i=0; i < 100; i++) {
    m1.put(i,i);
  }
  final Map<String,Integer> listenerResults=new HashMap<String,Integer>();
  final Semaphore semaphore=new Semaphore(1);
  semaphore.acquire();
  JobTracker tracker=client.getJobTracker("String_Node_Str");
  Job<Integer,Integer> job=tracker.newJob(KeyValueSource.fromMap(m1));
  ICompletableFuture<Map<String,Integer>> future=job.mapper(new GroupingTestMapper()).reducer(new TestReducerFactory()).submit();
  future.andThen(new ExecutionCallback<Map<String,Integer>>(){
    @Override public void onResponse(    Map<String,Integer> response){
      listenerResults.putAll(response);
      semaphore.release();
    }
    @Override public void onFailure(    Throwable t){
      semaphore.release();
    }
  }
);
  int[] expectedResults=new int[4];
  for (int i=0; i < 100; i++) {
    int index=i % 4;
    expectedResults[index]+=i;
  }
  semaphore.acquire();
  for (int i=0; i < 4; i++) {
    assertEquals(expectedResults[i],(int)listenerResults.get(String.valueOf(i)));
  }
}

Fixed version (ground truth):
@Test(timeout=60000) public void testAsyncMapperReducer() throws Exception {
  Config config=buildConfig();
  HazelcastInstance h1=Hazelcast.newHazelcastInstance(config);
  HazelcastInstance h2=Hazelcast.newHazelcastInstance(config);
  HazelcastInstance h3=Hazelcast.newHazelcastInstance(config);
  HazelcastInstance client=HazelcastClient.newHazelcastClient(null);
  IMap<Integer,Integer> m1=client.getMap(MAP_NAME);
  for (int i=0; i < 100; i++) {
    m1.put(i,i);
  }
  final Map<String,Integer> listenerResults=new HashMap<String,Integer>();
  final Semaphore semaphore=new Semaphore(1);
  semaphore.acquire();
  JobTracker tracker=client.getJobTracker("String_Node_Str");
  Job<Integer,Integer> job=tracker.newJob(KeyValueSource.fromMap(m1));
  ICompletableFuture<Map<String,Integer>> future=job.mapper(new GroupingTestMapper()).reducer(new TestReducerFactory()).submit();
  future.andThen(new ExecutionCallback<Map<String,Integer>>(){
    @Override public void onResponse(    Map<String,Integer> response){
      listenerResults.putAll(response);
      semaphore.release();
    }
    @Override public void onFailure(    Throwable t){
      semaphore.release();
    }
  }
);
  int[] expectedResults=new int[4];
  for (int i=0; i < 100; i++) {
    int index=i % 4;
    expectedResults[index]+=i;
  }
  semaphore.acquire();
  for (int i=0; i < 4; i++) {
    assertEquals(expectedResults[i],(int)listenerResults.get(String.valueOf(i)));
  }
}
Program: 48622
Project: 48622
Buggy source:
@Test(timeout=30000) public void testAsyncMapperReducerCollator() throws Exception {
  Config config=buildConfig();
  HazelcastInstance h1=Hazelcast.newHazelcastInstance(config);
  HazelcastInstance h2=Hazelcast.newHazelcastInstance(config);
  HazelcastInstance h3=Hazelcast.newHazelcastInstance(config);
  HazelcastInstance client=HazelcastClient.newHazelcastClient(null);
  IMap<Integer,Integer> m1=client.getMap(MAP_NAME);
  for (int i=0; i < 100; i++) {
    m1.put(i,i);
  }
  final int[] result=new int[1];
  final Semaphore semaphore=new Semaphore(1);
  semaphore.acquire();
  JobTracker tracker=client.getJobTracker("String_Node_Str");
  Job<Integer,Integer> job=tracker.newJob(KeyValueSource.fromMap(m1));
  ICompletableFuture<Integer> future=job.mapper(new GroupingTestMapper()).reducer(new TestReducerFactory()).submit(new TestCollator());
  future.andThen(new ExecutionCallback<Integer>(){
    @Override public void onResponse(    Integer response){
      result[0]=response.intValue();
      semaphore.release();
    }
    @Override public void onFailure(    Throwable t){
      semaphore.release();
    }
  }
);
  int expectedResult=0;
  for (int i=0; i < 100; i++) {
    expectedResult+=i;
  }
  semaphore.acquire();
  for (int i=0; i < 4; i++) {
    assertEquals(expectedResult,result[0]);
  }
}

Fixed version (ground truth):
@Test(timeout=60000) public void testAsyncMapperReducerCollator() throws Exception {
  Config config=buildConfig();
  HazelcastInstance h1=Hazelcast.newHazelcastInstance(config);
  HazelcastInstance h2=Hazelcast.newHazelcastInstance(config);
  HazelcastInstance h3=Hazelcast.newHazelcastInstance(config);
  HazelcastInstance client=HazelcastClient.newHazelcastClient(null);
  IMap<Integer,Integer> m1=client.getMap(MAP_NAME);
  for (int i=0; i < 100; i++) {
    m1.put(i,i);
  }
  final int[] result=new int[1];
  final Semaphore semaphore=new Semaphore(1);
  semaphore.acquire();
  JobTracker tracker=client.getJobTracker("String_Node_Str");
  Job<Integer,Integer> job=tracker.newJob(KeyValueSource.fromMap(m1));
  ICompletableFuture<Integer> future=job.mapper(new GroupingTestMapper()).reducer(new TestReducerFactory()).submit(new TestCollator());
  future.andThen(new ExecutionCallback<Integer>(){
    @Override public void onResponse(    Integer response){
      result[0]=response.intValue();
      semaphore.release();
    }
    @Override public void onFailure(    Throwable t){
      semaphore.release();
    }
  }
);
  int expectedResult=0;
  for (int i=0; i < 100; i++) {
    expectedResult+=i;
  }
  semaphore.acquire();
  for (int i=0; i < 4; i++) {
    assertEquals(expectedResult,result[0]);
  }
}
Program: 48623
Project: 48623
Buggy source:
@Test(timeout=30000) public void testKeyedAsyncMapper() throws Exception {
  Config config=buildConfig();
  HazelcastInstance h1=Hazelcast.newHazelcastInstance(config);
  HazelcastInstance h2=Hazelcast.newHazelcastInstance(config);
  HazelcastInstance h3=Hazelcast.newHazelcastInstance(config);
  HazelcastInstance client=HazelcastClient.newHazelcastClient(null);
  IMap<Integer,Integer> m1=client.getMap(MAP_NAME);
  for (int i=0; i < 100; i++) {
    m1.put(i,i);
  }
  final Map<String,List<Integer>> listenerResults=new HashMap<String,List<Integer>>();
  final Semaphore semaphore=new Semaphore(1);
  semaphore.acquire();
  JobTracker tracker=client.getJobTracker("String_Node_Str");
  Job<Integer,Integer> job=tracker.newJob(KeyValueSource.fromMap(m1));
  ICompletableFuture<Map<String,List<Integer>>> future=job.onKeys(50).mapper(new TestMapper()).submit();
  future.andThen(new ExecutionCallback<Map<String,List<Integer>>>(){
    @Override public void onResponse(    Map<String,List<Integer>> response){
      listenerResults.putAll(response);
      semaphore.release();
    }
    @Override public void onFailure(    Throwable t){
      semaphore.release();
    }
  }
);
  semaphore.acquire();
  assertEquals(1,listenerResults.size());
  for (  List<Integer> value : listenerResults.values()) {
    assertEquals(1,value.size());
  }
}

Fixed version (ground truth):
@Test(timeout=60000) public void testKeyedAsyncMapper() throws Exception {
  Config config=buildConfig();
  HazelcastInstance h1=Hazelcast.newHazelcastInstance(config);
  HazelcastInstance h2=Hazelcast.newHazelcastInstance(config);
  HazelcastInstance h3=Hazelcast.newHazelcastInstance(config);
  HazelcastInstance client=HazelcastClient.newHazelcastClient(null);
  IMap<Integer,Integer> m1=client.getMap(MAP_NAME);
  for (int i=0; i < 100; i++) {
    m1.put(i,i);
  }
  final Map<String,List<Integer>> listenerResults=new HashMap<String,List<Integer>>();
  final Semaphore semaphore=new Semaphore(1);
  semaphore.acquire();
  JobTracker tracker=client.getJobTracker("String_Node_Str");
  Job<Integer,Integer> job=tracker.newJob(KeyValueSource.fromMap(m1));
  ICompletableFuture<Map<String,List<Integer>>> future=job.onKeys(50).mapper(new TestMapper()).submit();
  future.andThen(new ExecutionCallback<Map<String,List<Integer>>>(){
    @Override public void onResponse(    Map<String,List<Integer>> response){
      listenerResults.putAll(response);
      semaphore.release();
    }
    @Override public void onFailure(    Throwable t){
      semaphore.release();
    }
  }
);
  semaphore.acquire();
  assertEquals(1,listenerResults.size());
  for (  List<Integer> value : listenerResults.values()) {
    assertEquals(1,value.size());
  }
}