nus-yam/ex-repair huggingface dataset:
Program: 50428
Project: 50428
Buggy source:
void quickBlockRearrangement(){
  if (!concurrentMapManager.isMaster())   return;
  createAllBlocks();
  Map<Address,List<Block>> addressBlocks=getCurrentMemberBlocks();
  if (addressBlocks.size() == 0) {
    return;
  }
  List<Block> lsEmptyBlocks=new ArrayList<Block>();
  for (  Block blockReal : blocks) {
    if (!blockReal.isMigrating() && thisAddress.equals(blockReal.getOwner())) {
      if (isBlockEmpty(blockReal.getBlockId())) {
        lsEmptyBlocks.add(blockReal);
      }
    }
  }
  int aveBlockOwnCount=PARTITION_COUNT / (addressBlocks.size());
  for (  Address address : addressBlocks.keySet()) {
    List<Block> blocks=addressBlocks.get(address);
    int diff=(aveBlockOwnCount - blocks.size());
    for (int i=0; i < diff && lsEmptyBlocks.size() > 0; i++) {
      Block block=lsEmptyBlocks.remove(0);
      block.setOwner(address);
    }
  }
  if (lsEmptyBlocks.size() > 0) {
    for (    Address address : addressBlocks.keySet()) {
      if (lsEmptyBlocks.size() == 0) {
        break;
      }
      Block ownableBlock=lsEmptyBlocks.remove(0);
      ownableBlock.setOwner(address);
    }
  }
  sendBlocks(null);
}

Fixed version (ground truth):
void quickBlockRearrangement(){
  if (!concurrentMapManager.isMaster())   return;
  createAllBlocks();
  Map<Address,List<Block>> addressBlocks=getCurrentMemberBlocks();
  if (addressBlocks.size() == 0) {
    return;
  }
  List<Block> lsEmptyBlocks=new ArrayList<Block>();
  for (  Block blockReal : blocks) {
    if (!blockReal.isMigrating() && thisAddress.equals(blockReal.getOwner())) {
      if (isBlockEmpty(blockReal.getBlockId())) {
        lsEmptyBlocks.add(blockReal);
      }
    }
  }
  int aveBlockOwnCount=PARTITION_COUNT / (addressBlocks.size());
  for (  Address address : addressBlocks.keySet()) {
    List<Block> blocks=addressBlocks.get(address);
    int diff=(aveBlockOwnCount - blocks.size());
    for (int i=0; i < diff && lsEmptyBlocks.size() > 0; i++) {
      Block block=lsEmptyBlocks.remove(0);
      block.setOwner(address);
    }
  }
  if (lsEmptyBlocks.size() > 0) {
    for (    Address address : addressBlocks.keySet()) {
      if (lsEmptyBlocks.size() == 0) {
        break;
      }
      Block ownableBlock=lsEmptyBlocks.remove(0);
      ownableBlock.setOwner(address);
    }
  }
  sendBlocks(null);
  partitionServiceImpl.reset();
}
Program: 50429
Project: 50429
Buggy source:
void fireScheduledActions(Record record){
  concurrentMapManager.checkServiceThread();
  if (record.getLockCount() == 0) {
    record.clearLock();
    if (record.getScheduledActions() != null) {
      while (record.getScheduledActions().size() > 0) {
        ScheduledAction sa=record.getScheduledActions().remove(0);
        node.clusterManager.deregisterScheduledAction(sa);
        if (!sa.expired()) {
          sa.consume();
          if (record.isLocked()) {
            return;
          }
        }
      }
    }
  }
}

Fixed version (ground truth):
void fireScheduledActions(Record record){
  concurrentMapManager.checkServiceThread();
  if (record.getLockCount() == 0) {
    record.clearLock();
    if (record.getScheduledActions() != null) {
      while (record.getScheduledActions().size() > 0) {
        ScheduledAction sa=record.getScheduledActions().remove(0);
        node.clusterManager.deregisterScheduledAction(sa);
        if (!sa.expired()) {
          sa.consume();
          if (record.isLocked()) {
            return;
          }
        }
 else {
          sa.onExpire();
        }
      }
    }
  }
}
Program: 50430
Project: 50430
Buggy source:
public Object invoke(Object proxy,Method method,Object[] args) throws Throwable {
  beforeCall();
  try {
    return method.invoke(mproxyReal,args);
  }
 catch (  Throwable e) {
    if (factory.restarted) {
      return invoke(proxy,method,args);
    }
 else {
      throw (RuntimeException)e;
    }
  }
 finally {
    afterCall();
  }
}

Fixed version (ground truth):
public Object invoke(Object proxy,Method method,Object[] args) throws Throwable {
  beforeCall();
  try {
    return method.invoke(mproxyReal,args);
  }
 catch (  Throwable e) {
    if (factory.restarted) {
      return invoke(proxy,method,args);
    }
 else     if (e instanceof RuntimeException) {
      throw (RuntimeException)e;
    }
 else {
      throw new RuntimeException(e);
    }
  }
 finally {
    afterCall();
  }
}
Program: 50432
Project: 50432
Buggy source:
public Record(CMap cmap,int blockId,Data key,Data value,long ttl,long maxIdleMillis,long id){
  super();
  this.id=id;
  this.cmap=cmap;
  this.blockId=blockId;
  this.key=key;
  this.value=value;
  this.setCreationTime(System.currentTimeMillis());
  this.setExpirationTime(ttl);
  this.maxIdleMillis=(maxIdleMillis == 0) ? Long.MAX_VALUE : maxIdleMillis;
  this.setVersion(0);
}

Fixed version (ground truth):
public Record(CMap cmap,int blockId,Data key,Data value,long ttl,long maxIdleMillis,long id){
  super();
  this.id=id;
  this.cmap=cmap;
  this.blockId=(short)blockId;
  this.key=key;
  this.value=value;
  this.setCreationTime(System.currentTimeMillis());
  this.setExpirationTime(ttl);
  this.maxIdleMillis=(maxIdleMillis == 0) ? Long.MAX_VALUE : maxIdleMillis;
  this.setVersion(0);
}
Program: 50434
Project: 50434
Buggy source:
public void run(){
  try {
    Object result=method.invoke(target,objects);
    resultQ.put((result == null) ? NULL_OBJECT : result);
  }
 catch (  Exception e) {
    try {
      resultQ.put(e);
    }
 catch (    InterruptedException ignored) {
    }
  }
}

Fixed version (ground truth):
public void run(){
  try {
    Object result=method.invoke(target,args);
    resultQ.put((result == null) ? NULL_OBJECT : result);
  }
 catch (  Exception e) {
    try {
      resultQ.put(e);
    }
 catch (    InterruptedException ignored) {
    }
  }
}
Program: 50435
Project: 50435
Buggy source:
@Test public void testTryLock(){
  Hazelcast.getMap("String_Node_Str").put("String_Node_Str","String_Node_Str");
  TransactionalMap txnMap=newTransactionalMapProxy("String_Node_Str");
  TransactionalMap txnMap2=newTransactionalMapProxy("String_Node_Str");
  txnMap.lock("String_Node_Str");
  long start=System.currentTimeMillis();
  assertFalse(txnMap2.tryLock("String_Node_Str",2,TimeUnit.SECONDS));
  long end=System.currentTimeMillis();
  long took=(end - start);
  assertTrue((took > 1000) ? (took < 4000) : false);
  assertFalse(txnMap2.tryLock("String_Node_Str"));
  txnMap.unlock("String_Node_Str");
  assertTrue(txnMap2.tryLock("String_Node_Str",2,TimeUnit.SECONDS));
}

Fixed version (ground truth):
@Test public void testTryLock(){
  Hazelcast.getMap("String_Node_Str").put("String_Node_Str","String_Node_Str");
  TransactionalMap txnMap=newTransactionalMapProxy("String_Node_Str");
  TransactionalMap txnMap2=newTransactionalMapProxy("String_Node_Str");
  txnMap.lock("String_Node_Str");
  long start=System.currentTimeMillis();
  assertFalse(txnMap2.tryLock("String_Node_Str",2,TimeUnit.SECONDS));
  long end=System.currentTimeMillis();
  long took=(end - start);
  System.out.println("String_Node_Str" + took);
  assertTrue((took > 1000) ? (took < 4000) : false);
  assertFalse(txnMap2.tryLock("String_Node_Str"));
  txnMap.unlock("String_Node_Str");
  assertTrue(txnMap2.tryLock("String_Node_Str",2,TimeUnit.SECONDS));
}
Program: 50438
Project: 50438
Buggy source:
public void returnScheduledAsSuccess(final Request request){
  if (request.local) {
    final TargetAwareOp targetAwareOp=(TargetAwareOp)request.attachment;
    targetAwareOp.setResult(request.response);
  }
 else {
    final Packet packet=obtainPacket();
    request.setPacket(packet);
    final Object result=request.response;
    if (result != null) {
      if (result instanceof Data) {
        final Data data=(Data)result;
        if (data.size() > 0) {
          packet.value=data;
        }
      }
    }
    sendResponse(packet,request.caller);
  }
}

Fixed version (ground truth):
public void returnScheduledAsSuccess(final Request request){
  if (request.local) {
    final TargetAwareOp targetAwareOp=(TargetAwareOp)request.attachment;
    targetAwareOp.setResult(request.response);
  }
 else {
    final Packet packet=obtainPacket();
    request.setPacket(packet);
    final Object result=request.response;
    if (result != null) {
      if (result instanceof Data) {
        final Data data=(Data)result;
        if (data.size() > 0) {
          packet.setValue(data);
        }
      }
    }
    sendResponse(packet,request.caller);
  }
}
Program: 50439
Project: 50439
Buggy source:
private void handleObjectNoneRedoResponse(final Packet packet){
  if (packet.responseType == Constants.ResponseTypes.RESPONSE_SUCCESS) {
    final Data oldValue=packet.value;
    if (oldValue == null || oldValue.size() == 0) {
      setResult(OBJECT_NULL);
    }
 else {
      setResult(oldValue);
    }
  }
 else {
    throw new RuntimeException(request.operation + "String_Node_Str" + packet.responseType);
  }
}

Fixed version (ground truth):
private void handleObjectNoneRedoResponse(final Packet packet){
  if (packet.responseType == Constants.ResponseTypes.RESPONSE_SUCCESS) {
    final Data oldValue=packet.getValueData();
    if (oldValue == null || oldValue.size() == 0) {
      setResult(OBJECT_NULL);
    }
 else {
      setResult(oldValue);
    }
  }
 else {
    throw new RuntimeException(request.operation + "String_Node_Str" + packet.responseType);
  }
}
Program: 50440
Project: 50440
Buggy source:
public boolean returnResponse(Request request,Connection conn){
  if (request.local) {
    final TargetAwareOp targetAwareOp=(TargetAwareOp)request.attachment;
    targetAwareOp.setResult(request.response);
  }
 else {
    Packet packet=obtainPacket();
    request.setPacket(packet);
    packet.operation=ClusterOperation.RESPONSE;
    packet.responseType=RESPONSE_SUCCESS;
    packet.longValue=request.longValue;
    if (request.value != null) {
      packet.value=request.value;
    }
    if (request.response == OBJECT_REDO) {
      packet.lockAddress=null;
      packet.responseType=RESPONSE_REDO;
    }
 else     if (request.response != null) {
      if (request.response instanceof Boolean) {
        if (request.response == Boolean.FALSE) {
          packet.responseType=RESPONSE_FAILURE;
        }
      }
 else       if (request.response instanceof Long) {
        packet.longValue=(Long)request.response;
      }
 else {
        Data data;
        if (request.response instanceof Data) {
          data=(Data)request.response;
        }
 else {
          data=toData(request.response);
        }
        if (data != null && data.size() > 0) {
          packet.value=data;
        }
      }
    }
    if (conn != null) {
      conn.getWriteHandler().enqueuePacket(packet);
    }
 else {
      return sendResponse(packet,request.caller);
    }
  }
  return true;
}

Fixed version (ground truth):
public boolean returnResponse(Request request,Connection conn){
  if (request.local) {
    final TargetAwareOp targetAwareOp=(TargetAwareOp)request.attachment;
    targetAwareOp.setResult(request.response);
  }
 else {
    Packet packet=obtainPacket();
    request.setPacket(packet);
    packet.operation=ClusterOperation.RESPONSE;
    packet.responseType=RESPONSE_SUCCESS;
    packet.longValue=request.longValue;
    if (request.value != null) {
      packet.setValue(request.value);
    }
    if (request.response == OBJECT_REDO) {
      packet.lockAddress=null;
      packet.responseType=RESPONSE_REDO;
    }
 else     if (request.response != null) {
      if (request.response instanceof Boolean) {
        if (request.response == Boolean.FALSE) {
          packet.responseType=RESPONSE_FAILURE;
        }
      }
 else       if (request.response instanceof Long) {
        packet.longValue=(Long)request.response;
      }
 else {
        Data data;
        if (request.response instanceof Data) {
          data=(Data)request.response;
        }
 else {
          data=toData(request.response);
        }
        if (data != null && data.size() > 0) {
          packet.setValue(data);
        }
      }
    }
    if (conn != null) {
      conn.getWriteHandler().enqueuePacket(packet);
    }
 else {
      return sendResponse(packet,request.caller);
    }
  }
  return true;
}
Program: 50441
Project: 50441
Buggy source:
public void sendEvents(final int eventType,final String name,final Data key,final Data value,final Map<Address,Boolean> mapListeners){
  if (mapListeners != null) {
    final Set<Map.Entry<Address,Boolean>> listeners=mapListeners.entrySet();
    for (    final Map.Entry<Address,Boolean> listener : listeners) {
      final Address address=listener.getKey();
      final boolean includeValue=listener.getValue();
      if (address.isThisAddress()) {
        try {
          enqueueEvent(eventType,name,key,(includeValue) ? value : null,address);
        }
 catch (        final Exception e) {
          e.printStackTrace();
        }
      }
 else {
        final Packet packet=obtainPacket();
        packet.set(name,ClusterOperation.EVENT,key,(includeValue) ? value : null);
        packet.longValue=eventType;
        final boolean sent=send(packet,address);
        if (!sent)         releasePacket(packet);
      }
    }
  }
}

Fixed version (ground truth):
public void sendEvents(final int eventType,final String name,final Data key,final Data value,final Map<Address,Boolean> mapListeners){
  if (mapListeners != null) {
    final Set<Map.Entry<Address,Boolean>> listeners=mapListeners.entrySet();
    for (    final Map.Entry<Address,Boolean> listener : listeners) {
      final Address address=listener.getKey();
      final boolean includeValue=listener.getValue();
      if (address.isThisAddress()) {
        enqueueEvent(eventType,name,key,(includeValue) ? value : null,address);
      }
 else {
        final Packet packet=obtainPacket();
        packet.set(name,ClusterOperation.EVENT,key,(includeValue) ? value : null);
        packet.longValue=eventType;
        final boolean sent=send(packet,address);
        if (!sent)         releasePacket(packet);
      }
    }
  }
}
Program: 50442
Project: 50442
Buggy source:
public synchronized void destroyConnection(Connection connection){
  if (currentConnection != null && currentConnection.getVersion() == connection.getVersion()) {
    logger.warning("String_Node_Str" + currentConnection + "String_Node_Str");
    currentConnection=null;
  }
}

Fixed version (ground truth):
public synchronized void destroyConnection(Connection connection,boolean gracefully){
  if (currentConnection != null && currentConnection.getVersion() == connection.getVersion()) {
    Level level=gracefully ? Level.INFO : Level.WARNING;
    logger.log(level,"String_Node_Str" + currentConnection + "String_Node_Str");
    currentConnection=null;
  }
}
Program: 50443
Project: 50443
Buggy source:
protected void customRun(){
  Packet packet;
  try {
    Connection oldConnection=connection;
    connection=client.connectionManager.getConnection();
    if (restoredConnection(oldConnection,connection)) {
      onDisconnect(oldConnection);
    }
    if (connection == null) {
      interruptWaitingCalls();
      Thread.sleep(50);
    }
 else {
      packet=reader.readPacket(connection);
      Call call=callMap.remove(packet.getCallId());
      if (call != null) {
        call.setResponse(packet);
      }
 else {
        if (packet.getOperation().equals(ClusterOperation.EVENT)) {
          client.getListenerManager().enqueue(packet);
        }
        if (packet.getCallId() == -1) {
        }
 else {
          throw new RuntimeException("String_Node_Str" + packet.getOperation() + "String_Node_Str"+ packet.getCallId());
        }
      }
    }
  }
 catch (  RuntimeException re) {
    throw re;
  }
catch (  Exception e) {
    logger.finest("String_Node_Str" + e.toString());
    client.connectionManager.destroyConnection(connection);
  }
}

Fixed version (ground truth):
protected void customRun(){
  Packet packet;
  try {
    Connection oldConnection=connection;
    connection=client.connectionManager.getConnection();
    if (restoredConnection(oldConnection,connection)) {
      onDisconnect(oldConnection);
    }
    if (connection == null) {
      interruptWaitingCalls();
      Thread.sleep(50);
    }
 else {
      packet=reader.readPacket(connection);
      Call call=callMap.remove(packet.getCallId());
      if (call != null) {
        call.setResponse(packet);
      }
 else {
        if (packet.getOperation().equals(ClusterOperation.EVENT)) {
          client.getListenerManager().enqueue(packet);
        }
        if (packet.getCallId() == -1) {
        }
 else {
          throw new RuntimeException("String_Node_Str" + packet.getOperation() + "String_Node_Str"+ packet.getCallId());
        }
      }
    }
  }
 catch (  RuntimeException re) {
    throw re;
  }
catch (  Exception e) {
    logger.finest("String_Node_Str" + e.toString());
    boolean gracefully=!running;
    client.connectionManager.destroyConnection(connection,gracefully);
  }
}
Program: 50444
Project: 50444
Buggy source:
protected void customRun() throws InterruptedException {
  Call call=null;
  try {
    call=queue.poll(100,TimeUnit.MILLISECONDS);
    if (call == null) {
      return;
    }
    callMap.put(call.getId(),call);
    Connection oldConnection=connection;
    connection=client.getConnectionManager().getConnection();
    if (restoredConnection(oldConnection,connection)) {
      redoUnfinishedCalls(call,oldConnection);
    }
 else     if (connection != null) {
      writer.write(connection,call.getRequest());
    }
 else {
      interruptWaitingCalls();
    }
  }
 catch (  InterruptedException e) {
    throw e;
  }
catch (  Throwable io) {
    logger.finest("String_Node_Str" + io.getMessage());
    enQueue(call);
    client.getConnectionManager().destroyConnection(connection);
  }
}

Fixed version (ground truth):
protected void customRun() throws InterruptedException {
  Call call=null;
  try {
    call=queue.poll(100,TimeUnit.MILLISECONDS);
    if (call == null) {
      return;
    }
    callMap.put(call.getId(),call);
    Connection oldConnection=connection;
    connection=client.getConnectionManager().getConnection();
    if (restoredConnection(oldConnection,connection)) {
      redoUnfinishedCalls(call,oldConnection);
    }
 else     if (connection != null) {
      writer.write(connection,call.getRequest());
    }
 else {
      interruptWaitingCalls();
    }
  }
 catch (  InterruptedException e) {
    throw e;
  }
catch (  Throwable io) {
    logger.finest("String_Node_Str" + io.getMessage());
    enQueue(call);
    boolean gracefully=!running;
    client.getConnectionManager().destroyConnection(connection,gracefully);
  }
}
Program: 50445
Project: 50445
Buggy source:
void doFireMigrationEvent(final boolean started,final MigrationEvent migrationEvent){
  if (migrationEvent == null)   throw new RuntimeException("String_Node_Str" + migrationEvent);
  Member owner=(started) ? migrationEvent.getOldOwner() : migrationEvent.getNewOwner();
  Member migrationMember=(started) ? migrationEvent.getNewOwner() : null;
  final PartitionReal partitionReal=new PartitionReal(migrationEvent.getPartitionId(),owner,migrationMember);
  mapRealPartitions.put(partitionReal.getPartitionId(),partitionReal);
  for (  final MigrationListener migrationListener : lsMigrationListeners) {
    concurrentMapManager.executeLocally(new Runnable(){
      public void run(){
        if (started) {
          migrationListener.migrationStarted(migrationEvent);
        }
 else {
          migrationListener.migrationCompleted(migrationEvent);
        }
      }
    }
);
  }
}

Fixed version (ground truth):
void doFireMigrationEvent(final boolean started,final MigrationEvent migrationEvent){
  partitionVersion.incrementAndGet();
  if (migrationEvent == null)   throw new RuntimeException("String_Node_Str" + migrationEvent);
  Member owner=(started) ? migrationEvent.getOldOwner() : migrationEvent.getNewOwner();
  Member migrationMember=(started) ? migrationEvent.getNewOwner() : null;
  final PartitionReal partitionReal=new PartitionReal(migrationEvent.getPartitionId(),owner,migrationMember);
  mapRealPartitions.put(partitionReal.getPartitionId(),partitionReal);
  for (  final MigrationListener migrationListener : lsMigrationListeners) {
    concurrentMapManager.executeLocally(new Runnable(){
      public void run(){
        if (started) {
          migrationListener.migrationStarted(migrationEvent);
        }
 else {
          migrationListener.migrationCompleted(migrationEvent);
        }
      }
    }
);
  }
}
Program: 50448
Project: 50448
Buggy source:
public void run(){
  while (true) {
    try {
      Thread.sleep(STATS_SECONDS * 1000);
      System.out.println("String_Node_Str" + Hazelcast.getCluster().getMembers().size());
      IMap<String,byte[]> map=Hazelcast.getMap("String_Node_Str");
      MapOperationStats mapOpStats=map.getLocalMapStats().getOperationStats();
      long period=((mapOpStats.getPeriodEnd() - mapOpStats.getPeriodStart()) / 1000);
      if (period == 0) {
        continue;
      }
      System.out.println(mapOpStats);
      System.out.println("String_Node_Str" + mapOpStats.total() / period);
    }
 catch (    Exception ignored) {
    }
  }
}

Fixed version (ground truth):
public void run(){
  while (true) {
    try {
      Thread.sleep(STATS_SECONDS * 1000);
      System.out.println("String_Node_Str" + Hazelcast.getCluster().getMembers().size());
      IMap<String,byte[]> map=Hazelcast.getMap("String_Node_Str");
      MapOperationStats mapOpStats=map.getLocalMapStats().getOperationStats();
      long period=((mapOpStats.getPeriodEnd() - mapOpStats.getPeriodStart()) / 1000);
      if (period == 0) {
        continue;
      }
      System.out.println(mapOpStats);
      System.out.println("String_Node_Str" + mapOpStats.total() / period);
    }
 catch (    InterruptedException ignored) {
      return;
    }
  }
}
Program: 50449
Project: 50449
Buggy source:
private String encodeURL(final String url,final String sessionURLPhrase){
  if (url != null || req == null || req.isRequestedSessionIdFromCookie()) {
    final int prefix=url.indexOf(sessionURLPhrase);
    if (prefix != -1) {
      int suffix=url.indexOf("String_Node_Str",prefix);
      if (suffix < 0)       suffix=url.indexOf("String_Node_Str",prefix);
      if (suffix <= prefix)       return url.substring(0,prefix);
      return url.substring(0,prefix) + url.substring(suffix);
    }
    return url;
  }
  final HazelSession session=req.getSession(false);
  if (session == null)   return url;
  if (!session.valid.get())   return url;
  final String id=session.getId();
  final int prefix=url.indexOf(sessionURLPhrase);
  if (prefix != -1) {
    int suffix=url.indexOf("String_Node_Str",prefix);
    if (suffix < 0)     suffix=url.indexOf("String_Node_Str",prefix);
    if (suffix <= prefix)     return url.substring(0,prefix + sessionURLPhrase.length()) + id;
    return url.substring(0,prefix + sessionURLPhrase.length()) + id + url.substring(suffix);
  }
  int suffix=url.indexOf('?');
  if (suffix < 0)   suffix=url.indexOf('#');
  if (suffix < 0)   return url + sessionURLPhrase + id;
  return url.substring(0,suffix) + sessionURLPhrase + id+ url.substring(suffix);
}

Fixed version (ground truth):
private String encodeURL(final String url,final String sessionURLPhrase){
  if (url == null) {
    throw new NullPointerException("String_Node_Str");
  }
  if (url != null || req == null || req.isRequestedSessionIdFromCookie()) {
    final int prefix=url.indexOf(sessionURLPhrase);
    if (prefix != -1) {
      int suffix=url.indexOf("String_Node_Str",prefix);
      if (suffix < 0)       suffix=url.indexOf("String_Node_Str",prefix);
      if (suffix <= prefix)       return url.substring(0,prefix);
      return url.substring(0,prefix) + url.substring(suffix);
    }
    return url;
  }
  final HazelSession session=req.getSession(false);
  if (session == null)   return url;
  if (!session.valid.get())   return url;
  final String id=session.getId();
  final int prefix=url.indexOf(sessionURLPhrase);
  if (prefix != -1) {
    int suffix=url.indexOf("String_Node_Str",prefix);
    if (suffix < 0)     suffix=url.indexOf("String_Node_Str",prefix);
    if (suffix <= prefix)     return url.substring(0,prefix + sessionURLPhrase.length()) + id;
    return url.substring(0,prefix + sessionURLPhrase.length()) + id + url.substring(suffix);
  }
  int suffix=url.indexOf('?');
  if (suffix < 0)   suffix=url.indexOf('#');
  if (suffix < 0)   return url + sessionURLPhrase + id;
  return url.substring(0,suffix) + sessionURLPhrase + id+ url.substring(suffix);
}
Program: 50450
Project: 50450
Buggy source:
public int getBlockId(Data key){
  int hash=key.hashCode();
  int result=Math.abs(hash) % PARTITION_COUNT;
  if (result < 0) {
    result=0;
  }
  return result;
}

Fixed version (ground truth):
public int getBlockId(Data key){
  int hash=key.hashCode();
  return (hash == Integer.MIN_VALUE) ? 0 : Math.abs(hash) % PARTITION_COUNT;
}
Program: 50451
Project: 50451
Buggy source:
int random(int from,int to){
  double diff=(to - from);
  return from+=(diff * Math.random());
}

Fixed version (ground truth):
int random(int from,int to){
  double diff=(to - from);
  return (int)(diff * Math.random() + from);
}
Program: 50452
Project: 50452
Buggy source:
final boolean evict(Request req){
  Record record=getRecord(req.key);
  if (record != null && record.isEvictable()) {
    if (ownerForSure(record)) {
      if (req.operation == CONCURRENT_MAP_EVICT_INTERNAL && record.isActive()) {
        return false;
      }
      concurrentMapManager.fireMapEvent(mapListeners,getName(),EntryEvent.TYPE_EVICTED,record.getKey(),record.getValue(),record.getMapListeners());
      record.setValue(null);
      markAsRemoved(record);
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
final boolean evict(Request req){
  Record record=getRecord(req.key);
  if (record != null && record.isEvictable()) {
    if (ownerForSure(record)) {
      concurrentMapManager.fireMapEvent(mapListeners,getName(),EntryEvent.TYPE_EVICTED,record.getKey(),record.getValue(),record.getMapListeners());
      record.setValue(null);
      markAsRemoved(record);
      return true;
    }
  }
  return false;
}
Program: 50453
Project: 50453
Buggy source:
void startEviction(boolean force){
  long now=System.currentTimeMillis();
  if (!force && ((now - lastEvictionTime) < evictionDelayMillis)) {
    return;
  }
  lastEvictionTime=now;
  List<Data> lsKeysToEvict=null;
  if (evictionPolicy == SortedHashMap.OrderingType.NONE) {
    if (ttl != 0 || maxIdle != 0 || ttlPerRecord) {
      Collection<Record> values=mapRecords.values();
      for (      Record record : values) {
        if (record.isActive() && !record.isValid(now)) {
          if (record.isEvictable()) {
            if (lsKeysToEvict == null) {
              lsKeysToEvict=new ArrayList<Data>(100);
            }
            markAsRemoved(record);
            lsKeysToEvict.add(record.getKey());
          }
        }
 else {
          break;
        }
      }
    }
  }
 else {
    Collection<Record> records=mapRecords.values();
    int numberOfRecordsToEvict=(int)(ownedRecords.size() * evictionRate);
    int evictedCount=0;
    loopRecords:     for (    Record record : records) {
      if (record.isActive() && record.isEvictable()) {
        if (lsKeysToEvict == null) {
          lsKeysToEvict=new ArrayList<Data>(numberOfRecordsToEvict);
        }
        markAsRemoved(record);
        lsKeysToEvict.add(record.getKey());
        if (++evictedCount >= numberOfRecordsToEvict) {
          break loopRecords;
        }
      }
    }
  }
  if (lsKeysToEvict != null && lsKeysToEvict.size() > 0) {
    for (    final Data key : lsKeysToEvict) {
      concurrentMapManager.evictAsync(getName(),key);
    }
  }
}

Fixed version (ground truth):
void startEviction(boolean force){
  long now=System.currentTimeMillis();
  if (!force && ((now - lastEvictionTime) < evictionDelayMillis)) {
    return;
  }
  lastEvictionTime=now;
  List<Record> lsRecordsToEvict=null;
  if (evictionPolicy == SortedHashMap.OrderingType.NONE) {
    if (ttl != 0 || maxIdle != 0 || ttlPerRecord) {
      Collection<Record> values=mapRecords.values();
      for (      Record record : values) {
        if (ownedRecords.contains(record) && record.isActive() && !record.isValid(now)) {
          if (record.isEvictable()) {
            if (lsRecordsToEvict == null) {
              lsRecordsToEvict=new ArrayList<Record>(100);
            }
            lsRecordsToEvict.add(record);
          }
        }
      }
    }
  }
 else {
    Collection<Record> records=mapRecords.values();
    int numberOfRecordsToEvict=(int)(ownedRecords.size() * evictionRate);
    int evictedCount=0;
    loopRecords:     for (    Record record : records) {
      if (ownedRecords.contains(record) && record.isActive() && record.isEvictable()) {
        if (lsRecordsToEvict == null) {
          lsRecordsToEvict=new ArrayList<Record>(numberOfRecordsToEvict);
        }
        lsRecordsToEvict.add(record);
        if (++evictedCount >= numberOfRecordsToEvict) {
          break loopRecords;
        }
      }
    }
  }
  if (lsRecordsToEvict != null && lsRecordsToEvict.size() > 0) {
    for (    final Record recordToEvict : lsRecordsToEvict) {
      markAsRemoved(recordToEvict);
      concurrentMapManager.evictAsync(recordToEvict.getName(),recordToEvict.getKey());
    }
  }
}
Program: 50454
Project: 50454
Buggy source:
@Test(timeout=60000) public void testMapMaxSize() throws Exception {
  Config c=new XmlConfigBuilder().build();
  MapConfig mapConfig=new MapConfig();
  mapConfig.setEvictionPolicy("String_Node_Str");
  mapConfig.setMaxSize(3);
  c.getMapMapConfigs().put("String_Node_Str",mapConfig);
  HazelcastInstance h=Hazelcast.newHazelcastInstance(c);
  IMap map=h.getMap("String_Node_Str");
  for (int i=0; i < 3; i++) {
    map.put(String.valueOf(i),String.valueOf(i));
  }
  assertEquals(3,map.size());
  for (int i=3; i < 10; i++) {
    map.put(String.valueOf(i),String.valueOf(i));
    assertEquals(3,map.size());
  }
}

Fixed version (ground truth):
@Test(timeout=60000) public void testMapMaxSize() throws Exception {
  Config c=new XmlConfigBuilder().build();
  MapConfig mapConfig=new MapConfig();
  mapConfig.setEvictionPolicy("String_Node_Str");
  mapConfig.setMaxSize(3);
  c.getMapMapConfigs().put("String_Node_Str",mapConfig);
  HazelcastInstance h=Hazelcast.newHazelcastInstance(c);
  IMap map=h.getMap("String_Node_Str");
  for (int i=0; i < 10; i++) {
    map.put(String.valueOf(i),String.valueOf(i));
    int expectedSize=(i < 3) ? i + 1 : 3;
    assertEquals(expectedSize,map.size());
  }
}
Program: 50455
Project: 50455
Buggy source:
public Record copy(){
  return new Record(factory,name,blockId,key.get(),value.get(),getRemainingTTL(),getRemainingIdle(),id);
}

Fixed version (ground truth):
public Record copy(){
  Record recordCopy=new Record(factory,name,blockId,key.get(),value.get(),getRemainingTTL(),getRemainingIdle(),id);
  recordCopy.setIndexes(indexes,indexTypes);
  recordCopy.setValueHash(valueHash);
  recordCopy.setLockCount(lockCount);
  recordCopy.setLockAddress(lockAddress);
  recordCopy.setLockThreadId(lockThreadId);
  recordCopy.setMultiValues(lsMultiValues);
  recordCopy.setCopyCount(copyCount);
  recordCopy.setVersion(getVersion());
  return recordCopy;
}
Program: 50456
Project: 50456
Buggy source:
public void start(){
  logger.log(Level.FINEST,"String_Node_Str" + String.valueOf(completelyShutdown));
  if (completelyShutdown)   return;
  Thread inThread=new Thread(threadGroup,inSelector,"String_Node_Str");
  inThread.setContextClassLoader(config.getClassLoader());
  inThread.setPriority(7);
  logger.log(Level.FINEST,"String_Node_Str" + inThread.getName());
  inThread.start();
  Thread outThread=new Thread(threadGroup,outSelector,"String_Node_Str");
  outThread.setContextClassLoader(config.getClassLoader());
  outThread.setPriority(7);
  logger.log(Level.FINEST,"String_Node_Str" + outThread.getName());
  outThread.start();
  serviceThread=new Thread(threadGroup,clusterService,"String_Node_Str");
  serviceThread.setContextClassLoader(config.getClassLoader());
  serviceThread.setPriority(8);
  logger.log(Level.FINEST,"String_Node_Str" + serviceThread.getName());
  serviceThread.start();
  queryThread=new Thread(threadGroup,queryService,"String_Node_Str");
  queryThread.setContextClassLoader(config.getClassLoader());
  queryThread.setPriority(6);
  logger.log(Level.FINEST,"String_Node_Str" + queryThread.getName());
  queryThread.start();
  if (config.getNetworkConfig().getJoin().getMulticastConfig().isEnabled()) {
    final Thread multicastServiceThread=new Thread(threadGroup,multicastService,"String_Node_Str");
    multicastServiceThread.start();
    multicastServiceThread.setContextClassLoader(config.getClassLoader());
    multicastServiceThread.setPriority(6);
  }
  setActive(true);
  if (!completelyShutdown) {
    logger.log(Level.FINEST,"String_Node_Str");
    Runtime.getRuntime().addShutdownHook(shutdownHookThread);
  }
  logger.log(Level.FINEST,"String_Node_Str");
  join();
}

Fixed version (ground truth):
public void start(){
  logger.log(Level.FINEST,"String_Node_Str" + String.valueOf(completelyShutdown));
  if (completelyShutdown)   return;
  Thread inThread=new Thread(threadGroup,inSelector,"String_Node_Str");
  inThread.setPriority(7);
  logger.log(Level.FINEST,"String_Node_Str" + inThread.getName());
  inThread.start();
  Thread outThread=new Thread(threadGroup,outSelector,"String_Node_Str");
  outThread.setPriority(7);
  logger.log(Level.FINEST,"String_Node_Str" + outThread.getName());
  outThread.start();
  serviceThread=new Thread(threadGroup,clusterService,"String_Node_Str");
  serviceThread.setPriority(8);
  logger.log(Level.FINEST,"String_Node_Str" + serviceThread.getName());
  serviceThread.start();
  queryThread=new Thread(threadGroup,queryService,"String_Node_Str");
  queryThread.setPriority(6);
  logger.log(Level.FINEST,"String_Node_Str" + queryThread.getName());
  queryThread.start();
  if (config.getNetworkConfig().getJoin().getMulticastConfig().isEnabled()) {
    final Thread multicastServiceThread=new Thread(threadGroup,multicastService,"String_Node_Str");
    multicastServiceThread.start();
    multicastServiceThread.setPriority(6);
  }
  setActive(true);
  if (!completelyShutdown) {
    logger.log(Level.FINEST,"String_Node_Str");
    Runtime.getRuntime().addShutdownHook(shutdownHookThread);
  }
  logger.log(Level.FINEST,"String_Node_Str");
  join();
}
Program: 50457
Project: 50457
Buggy source:
void completeMigration(int blockId){
  Block blockReal=blocks[blockId];
  if (blockReal.isMigrating()) {
    fireMigrationEvent(false,new Block(blockReal));
    blockReal.setOwner(blockReal.getMigrationAddress());
    blockReal.setMigrationAddress(null);
    logger.log(Level.FINEST,"String_Node_Str" + blockReal);
  }
}

Fixed version (ground truth):
void completeMigration(int blockId){
  Block blockReal=blocks[blockId];
  if (blockReal != null && blockReal.isMigrating()) {
    fireMigrationEvent(false,new Block(blockReal));
    blockReal.setOwner(blockReal.getMigrationAddress());
    blockReal.setMigrationAddress(null);
    logger.log(Level.FINEST,"String_Node_Str" + blockReal);
  }
}
Program: 50458
Project: 50458
Buggy source:
private PredicateBuilder addPredicate(Predicate predicate){
  qb.lsPredicates.add(predicate);
  qb.exp=null;
  return qb;
}

Fixed version (ground truth):
private PredicateBuilder addPredicate(Predicate predicate){
  qb.lsPredicates.add(predicate);
  return qb;
}
Program: 50459
Project: 50459
Buggy source:
Set<T> getSubRecords(QueryContext queryContext,boolean equal,boolean lessThan,long value){
  if (mapIndex instanceof HashSet)   return null;
  TreeMap<Long,Set<T>> treeMap=(TreeMap<Long,Set<T>>)mapIndex;
  Set<T> results=new HashSet<T>();
  Map<Long,Set<T>> sub=(lessThan) ? treeMap.headMap(value) : treeMap.tailMap(value);
  Set<Map.Entry<Long,Set<T>>> entries=sub.entrySet();
  for (  Map.Entry<Long,Set<T>> entry : entries) {
    if (equal || entry.getKey() != value) {
      Set<T> values=entry.getValue();
      if (queryContext.getIndexedPredicateCount() > 1 && values.size() > 100) {
        return null;
      }
      results.addAll(values);
    }
    if (queryContext.getIndexedPredicateCount() > 1 && results.size() > 100) {
      return null;
    }
  }
  return results;
}

Fixed version (ground truth):
Set<T> getSubRecords(QueryContext queryContext,boolean equal,boolean lessThan,long value){
  if (mapIndex instanceof HashSet)   return null;
  TreeMap<Long,Set<T>> treeMap=(TreeMap<Long,Set<T>>)mapIndex;
  Set<T> results=new HashSet<T>();
  Map<Long,Set<T>> sub=(lessThan) ? treeMap.headMap(value) : treeMap.tailMap(value);
  Set<Map.Entry<Long,Set<T>>> entries=sub.entrySet();
  for (  Map.Entry<Long,Set<T>> entry : entries) {
    if (equal || entry.getKey() != value) {
      Set<T> values=entry.getValue();
      if (queryContext.getIndexedPredicateCount() > 1 && values.size() > 100) {
        return null;
      }
      results.addAll(values);
    }
    if (queryContext.getIndexedPredicateCount() > 1 && results.size() > 100) {
      return null;
    }
  }
  if (lessThan && equal) {
    Set<T> recs=treeMap.get(value);
    if (recs != null) {
      results.addAll(recs);
    }
  }
  return results;
}
Program: 50460
Project: 50460
Buggy source:
/** 
 * from and to should be included
 * @param from from value (included)
 * @param to   to value (included
 * @return matching record set
 */
Set<T> getSubRecordsBetween(QueryContext queryContext,long from,long to){
  if (mapIndex instanceof HashSet)   return null;
  TreeMap<Long,Set<T>> treeMap=(TreeMap<Long,Set<T>>)mapIndex;
  Set<T> results=new HashSet<T>();
  Collection<Set<T>> sub=treeMap.subMap(from,to).values();
  for (  Set<T> records : sub) {
    if (queryContext.getIndexedPredicateCount() > 1 && sub.size() > 100) {
      return null;
    }
    results.addAll(records);
    if (queryContext.getIndexedPredicateCount() > 1 && results.size() > 100) {
      return null;
    }
  }
  Set<T> lastSet=treeMap.get(to);
  if (lastSet != null) {
    results.addAll(lastSet);
  }
  return results;
}

Fixed version (ground truth):
/** 
 * from and to should be included
 * @param queryContext query context
 * @param from from value (included)
 * @param to   to value (included
 * @return matching record set
 */
Set<T> getSubRecordsBetween(QueryContext queryContext,long from,long to){
  if (mapIndex instanceof HashSet)   return null;
  TreeMap<Long,Set<T>> treeMap=(TreeMap<Long,Set<T>>)mapIndex;
  Set<T> results=new HashSet<T>();
  Collection<Set<T>> sub=treeMap.subMap(from,to).values();
  for (  Set<T> records : sub) {
    if (queryContext.getIndexedPredicateCount() > 1 && sub.size() > 100) {
      return null;
    }
    results.addAll(records);
    if (queryContext.getIndexedPredicateCount() > 1 && results.size() > 100) {
      return null;
    }
  }
  Set<T> lastSet=treeMap.get(to);
  if (lastSet != null) {
    results.addAll(lastSet);
  }
  return results;
}
Program: 50461
Project: 50461
Buggy source:
@Test public void testPut(){
  Config config=new XmlConfigBuilder().build();
  FactoryImpl mockFactory=mock(FactoryImpl.class);
  Node node=new Node(mockFactory,config);
  node.serviceThread=Thread.currentThread();
  Object key="String_Node_Str";
  Object value="String_Node_Str";
  CMap cmap=new CMap(node.concurrentMapManager,"String_Node_Str");
  Request putRequest=new Request();
  putRequest.setLocal(ClusterOperation.CONCURRENT_MAP_PUT,null,toData(key),toData(value),-1,-1,-1,null);
  cmap.put(putRequest);
  assertTrue(cmap.mapRecords.containsKey(toData(key)));
  Request getRequest=new Request();
  getRequest.setLocal(ClusterOperation.CONCURRENT_MAP_GET,null,toData(key),null,-1,-1,-1,null);
  Data actualValue=cmap.get(getRequest);
  assertThat(toObject(actualValue),equalTo(value));
}

Fixed version (ground truth):
@Test public void testPut(){
  Config config=new XmlConfigBuilder().build();
  FactoryImpl mockFactory=mock(FactoryImpl.class);
  Node node=new Node(mockFactory,config);
  node.serviceThread=Thread.currentThread();
  CMap cmap=new CMap(node.concurrentMapManager,"String_Node_Str");
  Object key="String_Node_Str";
  Object value="String_Node_Str";
  Data dKey=toData(key);
  Data dValue=toData(value);
  cmap.put(newPutRequest(dKey,dValue));
  assertTrue(cmap.mapRecords.containsKey(toData(key)));
  Data actualValue=cmap.get(newGetRequest(dKey));
  assertThat(toObject(actualValue),equalTo(value));
  assertEquals(1,cmap.ownedRecords.size());
  Record record=cmap.getRecord(dKey);
  assertNotNull(record);
  assertTrue(record.isActive());
  assertTrue(record.isValid());
}
Program: 50463
Project: 50463
Buggy source:
public void doFunctionalQueryTest(IMap imap){
  imap.put("String_Node_Str",new Employee("String_Node_Str",33,false,14.56));
  imap.put("String_Node_Str",new Employee("String_Node_Str",23,true,15.00));
  for (int i=3; i < 103; i++) {
    imap.put(String.valueOf(i),new Employee("String_Node_Str" + i,i % 60,((i % 2) == 1),Double.valueOf(i)));
  }
  Set<Map.Entry> entries=imap.entrySet();
  assertEquals(102,entries.size());
  int itCount=0;
  for (  Map.Entry entry : entries) {
    Employee c=(Employee)entry.getValue();
    itCount++;
  }
  assertEquals(102,itCount);
  EntryObject e=new PredicateBuilder().getEntryObject();
  Predicate predicate=e.is("String_Node_Str").and(e.get("String_Node_Str").equal(23));
  entries=imap.entrySet(predicate);
  assertEquals(3,entries.size());
  for (  Map.Entry entry : entries) {
    Employee c=(Employee)entry.getValue();
    assertEquals(c.getAge(),23);
    assertTrue(c.isActive());
  }
  imap.remove("String_Node_Str");
  entries=imap.entrySet(predicate);
  assertEquals(2,entries.size());
  for (  Map.Entry entry : entries) {
    Employee c=(Employee)entry.getValue();
    assertEquals(c.getAge(),23);
    assertTrue(c.isActive());
  }
}

Fixed version (ground truth):
public void doFunctionalQueryTest(IMap imap){
  imap.put("String_Node_Str",new Employee("String_Node_Str",33,false,14.56));
  imap.put("String_Node_Str",new Employee("String_Node_Str",23,true,15.00));
  for (int i=3; i < 103; i++) {
    imap.put(String.valueOf(i),new Employee("String_Node_Str" + i,i % 60,((i % 2) == 1),Double.valueOf(i)));
  }
  Set<Map.Entry> entries=imap.entrySet();
  assertEquals(102,entries.size());
  int itCount=0;
  for (  Map.Entry entry : entries) {
    Employee c=(Employee)entry.getValue();
    itCount++;
  }
  assertEquals(102,itCount);
  EntryObject e=new PredicateBuilder().getEntryObject();
  Predicate predicate=e.is("String_Node_Str").and(e.get("String_Node_Str").equal(23));
  entries=imap.entrySet(predicate);
  assertEquals(3,entries.size());
  for (  Map.Entry entry : entries) {
    Employee c=(Employee)entry.getValue();
    assertEquals(c.getAge(),23);
    assertTrue(c.isActive());
  }
  imap.remove("String_Node_Str");
  entries=imap.entrySet(predicate);
  assertEquals(2,entries.size());
  for (  Map.Entry entry : entries) {
    Employee c=(Employee)entry.getValue();
    assertEquals(c.getAge(),23);
    assertTrue(c.isActive());
  }
  entries=imap.entrySet(new SqlPredicate("String_Node_Str" + 30 + "String_Node_Str"+ 40+ "String_Node_Str"));
  assertEquals(23,entries.size());
  for (  Map.Entry entry : entries) {
    Employee c=(Employee)entry.getValue();
    System.out.println(c);
    assertTrue(c.getAge() >= 30);
    assertTrue(c.getAge() <= 40);
  }
}
Program: 50464
Project: 50464
Buggy source:
public void memberAdded(MembershipEvent membershipEvent){
  this.clusterMembers.add(membershipEvent.getMember().getInetSocketAddress());
}

Fixed version (ground truth):
public synchronized void memberAdded(MembershipEvent membershipEvent){
  if (!this.clusterMembers.contains(membershipEvent.getMember().getInetSocketAddress())) {
    this.clusterMembers.add(membershipEvent.getMember().getInetSocketAddress());
  }
}
Program: 50465
Project: 50465
Buggy source:
public void memberRemoved(MembershipEvent membershipEvent){
  this.clusterMembers.remove(membershipEvent.getMember().getInetSocketAddress());
}

Fixed version (ground truth):
public synchronized void memberRemoved(MembershipEvent membershipEvent){
  this.clusterMembers.remove(membershipEvent.getMember().getInetSocketAddress());
}
Program: 50468
Project: 50468
Buggy source:
public void addMembershipListener(MembershipListener listener){
}

Fixed version (ground truth):
public void addMembershipListener(MembershipListener listener){
  check(listener);
  if (client.listenerManager.noInstanceListenerRegistered()) {
    Packet request=proxyHelper.createRequestPacket(ClusterOperation.CLIENT_ADD_INSTANCE_LISTENER,null,null);
    Call c=proxyHelper.createCall(request);
    client.listenerManager.addListenerCall(c);
    proxyHelper.doCall(c);
  }
  client.listenerManager.registerMembershipListener(listener);
}
Program: 50470
Project: 50470
Buggy source:
public void entryUpdated(EntryEvent<K,V> event){
  entryUpdatedLatch.countDown();
  assertEquals("String_Node_Str",event.getValue());
  assertEquals("String_Node_Str",event.getKey());
}

Fixed version (ground truth):
public void entryUpdated(EntryEvent<K,V> event){
  entryUpdatedLatch.countDown();
}
Program: 50471
Project: 50471
Buggy source:
public void entryAdded(EntryEvent<K,V> event){
  entryAddLatch.countDown();
  assertEquals("String_Node_Str",event.getKey());
}

Fixed version (ground truth):
public void entryAdded(EntryEvent<K,V> event){
  entryAddLatch.countDown();
}
Program: 50472
Project: 50472
Buggy source:
public void entryRemoved(EntryEvent<K,V> event){
  entryRemovedLatch.countDown();
  assertEquals("String_Node_Str",event.getKey());
  assertEquals("String_Node_Str",event.getValue());
}

Fixed version (ground truth):
public void entryRemoved(EntryEvent<K,V> event){
  entryRemovedLatch.countDown();
}
Program: 50473
Project: 50473
Buggy source:
@Test public void destroy(){
  HazelcastClient hClient=getHazelcastClient();
  IMap map=hClient.getMap("String_Node_Str");
  for (int i=0; i < 100; i++) {
    assertNull(map.put(i,i));
    assertEquals(i,map.get(i));
  }
  IMap<Integer,Integer> map2=hClient.getMap("String_Node_Str");
  assertTrue(map == map2);
  assertTrue(map.getId().equals(map2.getId()));
  map.destroy();
  map2=hClient.getMap("String_Node_Str");
  assertFalse(map == map2);
  for (int i=0; i < 100; i++) {
    assertNull(map2.get(i));
  }
}

Fixed version (ground truth):
@Test public void destroy() throws InterruptedException {
  HazelcastClient hClient=getHazelcastClient();
  IMap map=hClient.getMap("String_Node_Str");
  for (int i=0; i < 100; i++) {
    assertNull(map.put(i,i));
    assertEquals(i,map.get(i));
  }
  IMap<Integer,Integer> map2=hClient.getMap("String_Node_Str");
  assertTrue(map == map2);
  assertTrue(map.getId().equals(map2.getId()));
  map.destroy();
  for (int i=0; i < 100; i++) {
  }
}
Program: 50474
Project: 50474
Buggy source:
private Long getNewMillion(){
  try {
    DistributedTask<Long> task=new DistributedTask<Long>(new IncrementTask(name,factory));
    factory.executorServiceImpl.execute(task);
    return task.get();
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
  return null;
}

Fixed version (ground truth):
private Long getNewMillion(){
  try {
    DistributedTask<Long> task=new DistributedTask<Long>(new IncrementTask(name,factory),name);
    factory.executorServiceImpl.execute(task);
    return task.get();
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
  return null;
}
Program: 50475
Project: 50475
Buggy source:
public long newId(){
  long millionNow=million.get();
  long idAddition=currentId.incrementAndGet();
  if (idAddition >= MILLION) {
synchronized (this) {
      try {
        millionNow=million.get();
        idAddition=currentId.incrementAndGet();
        if (idAddition >= MILLION) {
          Long idMillion=getNewMillion();
          long newMillion=idMillion * MILLION;
          million.set(newMillion);
          currentId.set(0);
        }
        millionNow=million.get();
        idAddition=currentId.incrementAndGet();
      }
 catch (      Throwable t) {
        t.printStackTrace();
      }
    }
  }
  return millionNow + idAddition;
}

Fixed version (ground truth):
public long newId(){
  long idAddition=currentId.incrementAndGet();
  if (idAddition >= MILLION) {
synchronized (this) {
      try {
        idAddition=currentId.get();
        if (idAddition >= MILLION) {
          Long idMillion=getNewMillion();
          long newMillion=idMillion * MILLION;
          million.set(newMillion);
          currentId.set(0L);
        }
        return newId();
      }
 catch (      Throwable t) {
        t.printStackTrace();
      }
    }
  }
  long millionNow=million.get();
  return millionNow + idAddition;
}