nus-yam/ex-repair huggingface dataset:
Program: 47238
Project: 47238
Buggy source:
@Override public E getAndAlter(IFunction<E,E> function){
  isNotNull(function,"String_Node_Str");
  ClientMessage request=AtomicReferenceGetAndAlterCodec.encodeRequest(name,toData(function));
  AtomicReferenceGetAndAlterCodec.ResponseParameters resultParameters=AtomicReferenceGetAndAlterCodec.decodeResponse((ClientMessage)invoke(request));
  return toObject(resultParameters.response);
}

Fixed version (ground truth):
@Override public E getAndAlter(IFunction<E,E> function){
  isNotNull(function,"String_Node_Str");
  ClientMessage request=AtomicReferenceGetAndAlterCodec.encodeRequest(name,toData(function));
  ClientMessage response=invoke(request);
  return toObject(AtomicReferenceGetAndAlterCodec.decodeResponse(response).response);
}
Program: 47239
Project: 47239
Buggy source:
@Override public boolean contains(E expected){
  ClientMessage request=AtomicReferenceContainsCodec.encodeRequest(name,toData(expected));
  AtomicReferenceContainsCodec.ResponseParameters resultParameters=AtomicReferenceContainsCodec.decodeResponse((ClientMessage)invoke(request));
  return resultParameters.response;
}

Fixed version (ground truth):
@Override public boolean contains(E expected){
  ClientMessage request=AtomicReferenceContainsCodec.encodeRequest(name,toData(expected));
  ClientMessage response=invoke(request);
  return AtomicReferenceContainsCodec.decodeResponse(response).response;
}
Program: 47240
Project: 47240
Buggy source:
@Override public boolean compareAndSet(E expect,E update){
  ClientMessage request=AtomicReferenceCompareAndSetCodec.encodeRequest(name,toData(expect),toData(update));
  AtomicReferenceCompareAndSetCodec.ResponseParameters resultParameters=AtomicReferenceCompareAndSetCodec.decodeResponse((ClientMessage)invoke(request));
  return resultParameters.response;
}

Fixed version (ground truth):
@Override public boolean compareAndSet(E expect,E update){
  ClientMessage request=AtomicReferenceCompareAndSetCodec.encodeRequest(name,toData(expect),toData(update));
  ClientMessage response=invoke(request);
  return AtomicReferenceCompareAndSetCodec.decodeResponse(response).response;
}
Program: 47241
Project: 47241
Buggy source:
@Override public E get(){
  ClientMessage request=AtomicReferenceGetCodec.encodeRequest(name);
  AtomicReferenceGetCodec.ResponseParameters resultParameters=AtomicReferenceGetCodec.decodeResponse((ClientMessage)invoke(request));
  return toObject(resultParameters.response);
}

Fixed version (ground truth):
@Override public E get(){
  ClientMessage request=AtomicReferenceGetCodec.encodeRequest(name);
  ClientMessage response=invoke(request);
  return toObject(AtomicReferenceGetCodec.decodeResponse(response).response);
}
Program: 47242
Project: 47242
Buggy source:
@Override public boolean isNull(){
  ClientMessage request=AtomicReferenceIsNullCodec.encodeRequest(name);
  AtomicReferenceIsNullCodec.ResponseParameters resultParameters=AtomicReferenceIsNullCodec.decodeResponse((ClientMessage)invoke(request));
  return resultParameters.response;
}

Fixed version (ground truth):
@Override public boolean isNull(){
  ClientMessage request=AtomicReferenceIsNullCodec.encodeRequest(name);
  ClientMessage response=invoke(request);
  return AtomicReferenceIsNullCodec.decodeResponse(response).response;
}
Program: 47243
Project: 47243
Buggy source:
@Override public E getAndSet(E newValue){
  ClientMessage request=AtomicReferenceGetAndSetCodec.encodeRequest(name,toData(newValue));
  AtomicReferenceGetAndSetCodec.ResponseParameters resultParameters=AtomicReferenceGetAndSetCodec.decodeResponse((ClientMessage)invoke(request));
  return toObject(resultParameters.response);
}

Fixed version (ground truth):
@Override public E getAndSet(E newValue){
  ClientMessage request=AtomicReferenceGetAndSetCodec.encodeRequest(name,toData(newValue));
  ClientMessage response=invoke(request);
  return toObject(AtomicReferenceGetAndSetCodec.decodeResponse(response).response);
}
Program: 47244
Project: 47244
Buggy source:
@Override public E alterAndGet(IFunction<E,E> function){
  isNotNull(function,"String_Node_Str");
  ClientMessage request=AtomicReferenceAlterAndGetCodec.encodeRequest(name,toData(function));
  AtomicReferenceAlterAndGetCodec.ResponseParameters resultParameters=AtomicReferenceAlterAndGetCodec.decodeResponse((ClientMessage)invoke(request));
  return toObject(resultParameters.response);
}

Fixed version (ground truth):
@Override public E alterAndGet(IFunction<E,E> function){
  isNotNull(function,"String_Node_Str");
  ClientMessage request=AtomicReferenceAlterAndGetCodec.encodeRequest(name,toData(function));
  ClientMessage response=invoke(request);
  return toObject(AtomicReferenceAlterAndGetCodec.decodeResponse(response).response);
}
Program: 47245
Project: 47245
Buggy source:
private boolean doAwait(long time,TimeUnit unit,long threadId) throws InterruptedException {
  final long timeoutInMillis=unit.toMillis(time);
  ClientMessage request=ConditionAwaitCodec.encodeRequest(conditionId,threadId,timeoutInMillis,lockProxy.getName());
  ConditionAwaitCodec.ResponseParameters resultParameters=ConditionAwaitCodec.decodeResponse((ClientMessage)invoke(request));
  return resultParameters.response;
}

Fixed version (ground truth):
private boolean doAwait(long time,TimeUnit unit,long threadId) throws InterruptedException {
  final long timeoutInMillis=unit.toMillis(time);
  ClientMessage request=ConditionAwaitCodec.encodeRequest(conditionId,threadId,timeoutInMillis,lockProxy.getName());
  ClientMessage response=invoke(request);
  return ConditionAwaitCodec.decodeResponse(response).response;
}
Program: 47246
Project: 47246
Buggy source:
@Override public void handle(String name,String serviceName,int eventType){
  final ObjectNamespace ns=new DefaultObjectNamespace(serviceName,name);
  ClientProxyFuture future=proxies.get(ns);
  ClientProxy proxy=future == null ? null : future.get();
  if (proxy == null) {
    proxy=getOrCreateProxy(serviceName,name);
  }
  if (DistributedObjectEvent.EventType.CREATED.equals(eventType)) {
    DistributedObjectEvent event=new DistributedObjectEvent(DistributedObjectEvent.EventType.CREATED,serviceName,proxy);
    listener.distributedObjectCreated(event);
  }
 else   if (DistributedObjectEvent.EventType.DESTROYED.equals(eventType)) {
    DistributedObjectEvent event=new DistributedObjectEvent(DistributedObjectEvent.EventType.DESTROYED,serviceName,proxy);
    listener.distributedObjectDestroyed(event);
  }
}

Fixed version (ground truth):
@Override public void handle(String name,String serviceName,String eventTypeName){
  final ObjectNamespace ns=new DefaultObjectNamespace(serviceName,name);
  ClientProxyFuture future=proxies.get(ns);
  ClientProxy proxy=future == null ? null : future.get();
  if (proxy == null) {
    proxy=getOrCreateProxy(serviceName,name);
  }
  DistributedObjectEvent.EventType eventType=DistributedObjectEvent.EventType.valueOf(eventTypeName);
  DistributedObjectEvent event=new DistributedObjectEvent(eventType,serviceName,proxy);
  if (DistributedObjectEvent.EventType.CREATED.equals(eventType)) {
    listener.distributedObjectCreated(event);
  }
 else   if (DistributedObjectEvent.EventType.DESTROYED.equals(eventType)) {
    listener.distributedObjectDestroyed(event);
  }
}
Program: 47247
Project: 47247
Buggy source:
public static void encode(com.hazelcast.instance.AbstractMember member,ClientMessage clientMessage){
  AddressCodec.encode(member.getAddress(),clientMessage);
  clientMessage.set(member.getUuid());
  Map<String,Object> attributes=new HashMap<String,Object>(member.getAttributes());
  clientMessage.set(attributes.size());
  for (  Map.Entry<String,Object> entry : attributes.entrySet()) {
    clientMessage.set(entry.getKey());
    Object value=entry.getValue();
    clientMessage.set(value.toString());
  }
}

Fixed version (ground truth):
public static void encode(Member member,ClientMessage clientMessage){
  AddressCodec.encode(((AbstractMember)member).getAddress(),clientMessage);
  clientMessage.set(member.getUuid());
  Map<String,Object> attributes=new HashMap<String,Object>(member.getAttributes());
  clientMessage.set(attributes.size());
  for (  Map.Entry<String,Object> entry : attributes.entrySet()) {
    clientMessage.set(entry.getKey());
    Object value=entry.getValue();
    clientMessage.set(value.toString());
  }
}
Program: 47248
Project: 47248
Buggy source:
public static int calculateDataSize(com.hazelcast.instance.AbstractMember member){
  int dataSize=AddressCodec.calculateDataSize(member.getAddress());
  dataSize+=ParameterUtil.calculateStringDataSize(member.getUuid());
  dataSize+=Bits.INT_SIZE_IN_BYTES;
  Map<String,Object> attributes=member.getAttributes();
  for (  Map.Entry<String,Object> entry : attributes.entrySet()) {
    dataSize+=ParameterUtil.calculateStringDataSize(entry.getKey());
    Object value=entry.getValue();
    dataSize+=ParameterUtil.calculateStringDataSize(value.toString());
  }
  return dataSize;
}

Fixed version (ground truth):
public static int calculateDataSize(Member member){
  int dataSize=AddressCodec.calculateDataSize(((AbstractMember)member).getAddress());
  dataSize+=ParameterUtil.calculateStringDataSize(member.getUuid());
  dataSize+=Bits.INT_SIZE_IN_BYTES;
  Map<String,Object> attributes=member.getAttributes();
  for (  Map.Entry<String,Object> entry : attributes.entrySet()) {
    dataSize+=ParameterUtil.calculateStringDataSize(entry.getKey());
    Object value=entry.getValue();
    dataSize+=ParameterUtil.calculateStringDataSize(value.toString());
  }
  return dataSize;
}
Program: 47249
Project: 47249
Buggy source:
public static com.hazelcast.instance.AbstractMember decode(ClientMessage clientMessage){
  final Address address=AddressCodec.decode(clientMessage);
  String uuid=clientMessage.getStringUtf8();
  int attributeSize=clientMessage.getInt();
  Map<String,Object> attributes=new HashMap<String,Object>();
  for (int i=0; i < attributeSize; i++) {
    String key=clientMessage.getStringUtf8();
    String value=clientMessage.getStringUtf8();
    attributes.put(key,value);
  }
  return new com.hazelcast.client.impl.MemberImpl(address,uuid,attributes);
}

Fixed version (ground truth):
public static Member decode(ClientMessage clientMessage){
  final Address address=AddressCodec.decode(clientMessage);
  String uuid=clientMessage.getStringUtf8();
  int attributeSize=clientMessage.getInt();
  Map<String,Object> attributes=new HashMap<String,Object>();
  for (int i=0; i < attributeSize; i++) {
    String key=clientMessage.getStringUtf8();
    String value=clientMessage.getStringUtf8();
    attributes.put(key,value);
  }
  return new com.hazelcast.client.impl.MemberImpl(address,uuid,attributes);
}
Program: 47250
Project: 47250
Buggy source:
private void send(DistributedObjectEvent event){
  if (endpoint.isAlive()) {
    String name=event.getDistributedObject().getName();
    String serviceName=event.getServiceName();
    ClientMessage eventMessage=ClientAddDistributedObjectListenerCodec.encodeDistributedObjectEvent(name,serviceName,event.getEventType().ordinal());
    sendClientMessage(null,eventMessage);
  }
}

Fixed version (ground truth):
private void send(DistributedObjectEvent event){
  if (endpoint.isAlive()) {
    String name=event.getDistributedObject().getName();
    String serviceName=event.getServiceName();
    ClientMessage eventMessage=ClientAddDistributedObjectListenerCodec.encodeDistributedObjectEvent(name,serviceName,event.getEventType().name());
    sendClientMessage(null,eventMessage);
  }
}
Program: 47251
Project: 47251
Buggy source:
@Override protected ClientMessage encodeResponse(Object response){
  Object[] responses=((TaskMultipleResponse)response).responses;
  return ClientAuthenticationCustomCodec.encodeResponse((Address)responses[0],(String)responses[1],(String)responses[2]);
}

Fixed version (ground truth):
@Override protected ClientMessage encodeResponse(Object response){
  Object[] responses=((TaskMultipleResponse)response).getResponses();
  return ClientAuthenticationCustomCodec.encodeResponse((Address)responses[0],(String)responses[1],(String)responses[2]);
}
Program: 47252
Project: 47252
Buggy source:
@Override protected ClientMessage encodeResponse(Object response){
  Object[] responses=((TaskMultipleResponse)response).responses;
  return ClientAuthenticationCodec.encodeResponse((Address)responses[0],(String)responses[1],(String)responses[2]);
}

Fixed version (ground truth):
@Override protected ClientMessage encodeResponse(Object response){
  Object[] responses=((TaskMultipleResponse)response).getResponses();
  return ClientAuthenticationCodec.encodeResponse((Address)responses[0],(String)responses[1],(String)responses[2]);
}
Program: 47253
Project: 47253
Buggy source:
@Override protected ClientMessage encodeResponse(Object response){
  Object[] responses=((TaskMultipleResponse)response).responses;
  return ClientGetPartitionsCodec.encodeResponse((Address[])responses[0],(int[])responses[1]);
}

Fixed version (ground truth):
@Override protected ClientMessage encodeResponse(Object response){
  Object[] responses=((TaskMultipleResponse)response).getResponses();
  return ClientGetPartitionsCodec.encodeResponse((Address[])responses[0],(int[])responses[1]);
}
Program: 47254
Project: 47254
Buggy source:
@Override protected Object call(){
  final ClientEndpoint endpoint=getEndpoint();
  CacheService cacheService=getService(CacheService.SERVICE_NAME);
  String registrationId=cacheService.addInvalidationListener(parameters.name,new CacheEventListener(){
    @Override public void handleEvent(    Object eventObject){
      if (eventObject instanceof CacheInvalidationMessage) {
        CacheInvalidationMessage message=(CacheInvalidationMessage)eventObject;
        if (endpoint.isAlive()) {
          ClientMessage eventMessage=CacheAddInvalidationListenerCodec.encodeCacheInvalidationEvent(message.getName(),message.getKey(),message.getSourceUuid());
          sendClientMessage(message.getKey(),eventMessage);
        }
      }
    }
  }
);
  endpoint.setListenerRegistration(CacheService.SERVICE_NAME,parameters.name,registrationId);
  return registrationId;
}

Fixed version (ground truth):
@Override protected Object call(){
  final ClientEndpoint endpoint=getEndpoint();
  CacheService cacheService=getService(CacheService.SERVICE_NAME);
  String registrationId=cacheService.addInvalidationListener(parameters.name,new CacheEventListener(){
    @Override public void handleEvent(    Object eventObject){
      if (!endpoint.isAlive()) {
        return;
      }
      if (eventObject instanceof CacheInvalidationMessage) {
        CacheInvalidationMessage message=(CacheInvalidationMessage)eventObject;
        ClientMessage eventMessage=CacheAddInvalidationListenerCodec.encodeCacheInvalidationEvent(message.getName(),message.getKey(),message.getSourceUuid());
        sendClientMessage(message.getKey(),eventMessage);
      }
    }
  }
);
  endpoint.setListenerRegistration(CacheService.SERVICE_NAME,parameters.name,registrationId);
  return registrationId;
}
Program: 47255
Project: 47255
Buggy source:
@Override public void handleEvent(Object eventObject){
  if (eventObject instanceof CacheInvalidationMessage) {
    CacheInvalidationMessage message=(CacheInvalidationMessage)eventObject;
    if (endpoint.isAlive()) {
      ClientMessage eventMessage=CacheAddInvalidationListenerCodec.encodeCacheInvalidationEvent(message.getName(),message.getKey(),message.getSourceUuid());
      sendClientMessage(message.getKey(),eventMessage);
    }
  }
}

Fixed version (ground truth):
@Override public void handleEvent(Object eventObject){
  if (!endpoint.isAlive()) {
    return;
  }
  if (eventObject instanceof CacheInvalidationMessage) {
    CacheInvalidationMessage message=(CacheInvalidationMessage)eventObject;
    ClientMessage eventMessage=CacheAddInvalidationListenerCodec.encodeCacheInvalidationEvent(message.getName(),message.getKey(),message.getSourceUuid());
    sendClientMessage(message.getKey(),eventMessage);
  }
}
Program: 47256
Project: 47256
Buggy source:
@Override protected ClientMessage encodeResponse(Object response){
  Object[] responses=((TaskMultipleResponse)response).responses;
  return MapReduceJobProcessInformationCodec.encodeResponse((JobPartitionState[])responses[0],(Integer)responses[1]);
}

Fixed version (ground truth):
@Override protected ClientMessage encodeResponse(Object response){
  Object[] responses=((TaskMultipleResponse)response).getResponses();
  return MapReduceJobProcessInformationCodec.encodeResponse((JobPartitionState[])responses[0],(Integer)responses[1]);
}
Program: 47257
Project: 47257
Buggy source:
/** 
 * Here we are cleaning staging area upon a store operation.
 */
@Override public void afterStore(StoreEvent<DelayedEntry> storeEvent){
  final DelayedEntry delayedEntry=storeEvent.getSource();
  int partitionId=delayedEntry.getPartitionId();
  WriteBehindStore writeBehindStore=getWriteBehindStoreOrNull(partitionId);
  if (writeBehindStore == null) {
    return;
  }
  Data key=(Data)delayedEntry.getKey();
  Object value=delayedEntry.getValue();
  writeBehindStore.removeFromStagingArea(key,value);
  if (value == null) {
    writeBehindStore.removeFromWaitingDeletions(key);
  }
}

Fixed version (ground truth):
/** 
 * Here we are cleaning staging area upon a store operation.
 */
@Override public void afterStore(StoreEvent<DelayedEntry> storeEvent){
  DelayedEntry delayedEntry=storeEvent.getSource();
  int partitionId=delayedEntry.getPartitionId();
  WriteBehindStore writeBehindStore=getWriteBehindStoreOrNull(partitionId);
  if (writeBehindStore == null) {
    return;
  }
  writeBehindStore.removeFromStagingArea(delayedEntry);
}
Program: 47258
Project: 47258
Buggy source:
public static <T>WriteBehindQueue<T> createDefaultWriteBehindQueue(){
  final WriteBehindQueue queue=createCoalescedWriteBehindQueue();
  return createSyncronizedWriteBehindQueue(queue);
}

Fixed version (ground truth):
public static <T>WriteBehindQueue<T> createDefaultWriteBehindQueue(){
  final WriteBehindQueue queue=createCoalescedWriteBehindQueue();
  return createSynchronizedWriteBehindQueue(queue);
}
Program: 47259
Project: 47259
Buggy source:
@Override public boolean equals(Object o){
  if (this == o) {
    return true;
  }
  if (o == null || getClass() != o.getClass()) {
    return false;
  }
  AbstractDelayedEntry that=(AbstractDelayedEntry)o;
  if (key != null ? !key.equals(that.key) : that.key != null) {
    return false;
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean equals(Object o){
  return this == o;
}
Program: 47260
Project: 47260
Buggy source:
/** 
 * Here we are cleaning staging area upon a store operation.
 */
@Override public void afterStore(StoreEvent<DelayedEntry> storeEvent){
  final DelayedEntry delayedEntry=storeEvent.getSource();
  int partitionId=delayedEntry.getPartitionId();
  WriteBehindStore writeBehindStore=getWriteBehindStoreOrNull(partitionId);
  if (writeBehindStore == null) {
    return;
  }
  Data key=(Data)delayedEntry.getKey();
  Object value=delayedEntry.getValue();
  writeBehindStore.removeFromStagingArea(key,value);
  if (value == null) {
    writeBehindStore.removeFromWaitingDeletions(key);
  }
}

Fixed version (ground truth):
/** 
 * Here we are cleaning staging area upon a store operation.
 */
@Override public void afterStore(StoreEvent<DelayedEntry> storeEvent){
  final DelayedEntry delayedEntry=storeEvent.getSource();
  int partitionId=delayedEntry.getPartitionId();
  WriteBehindStore writeBehindStore=getWriteBehindStoreOrNull(partitionId);
  if (writeBehindStore == null) {
    return;
  }
  writeBehindStore.removeProcessed(delayedEntry);
}
Program: 47261
Project: 47261
Buggy source:
@Override public Object add(Data key,Object value,long now){
  final long writeDelay=this.writeDelayTime;
  final long storeTime=now + writeDelay;
  final DelayedEntry<Data,Object> delayedEntry=DelayedEntry.create(key,value,storeTime,partitionId);
  writeBehindQueue.offer(delayedEntry);
  removeFromWaitingDeletions(key);
  transients.remove(key);
  return value;
}

Fixed version (ground truth):
public void add(DelayedEntry<Data,Object> delayedEntry){
  writeBehindQueue.offer(delayedEntry);
  stagingArea.put(delayedEntry.getKey(),delayedEntry);
}
Program: 47262
Project: 47262
Buggy source:
/** 
 * * Used in   {@link com.hazelcast.core.IMap#loadAll} calls.If write-behind map-store feature enabled, some things may lead possible data inconsistencies. These are: - calling evict/evictAll. - calling remove. - not yet stored write behind queue operation. <p/> With this method we can be sure that a key can be loadable from map-store or not.
 * @param key            to query whether loadable or not.
 * @param lastUpdateTime last update time.
 * @param now            in mills
 * @return <code>true</code> if loadable, otherwise false.
 */
@Override public boolean loadable(Data key,long lastUpdateTime,long now){
  if (hasWaitingWriteBehindDeleteOperation(key) || isInStagingArea(key,now) || hasAnyWaitingOperationInWriteBehindQueue(lastUpdateTime,now)) {
    return false;
  }
  return true;
}

Fixed version (ground truth):
/** 
 * * Used in   {@link com.hazelcast.core.IMap#loadAll} calls.If write-behind map-store feature enabled, some things may lead possible data inconsistencies. These are: - calling evict/evictAll. - calling remove. - not yet stored write behind queue operation. <p/> With this method we can be sure that a key can be loadable from map-store or not.
 * @param key            to query whether loadable or not.
 * @param lastUpdateTime last update time.
 * @param now            in mills
 * @return <code>true</code> if loadable, otherwise false.
 */
@Override public boolean loadable(Data key,long lastUpdateTime,long now){
  if (isInStagingArea(key,now) || hasAnyWaitingOperationInWriteBehindQueue(lastUpdateTime,now)) {
    return false;
  }
  return true;
}
Program: 47263
Project: 47263
Buggy source:
@Override public void clear(){
  writeBehindQueue.clear();
  writeBehindWaitingDeletions.clear();
  transients.clear();
  stagingArea.clear();
  flushCounter.set(0);
}

Fixed version (ground truth):
@Override public void clear(){
  writeBehindQueue.clear();
  stagingArea.clear();
  flushCounter.set(0);
}
Program: 47264
Project: 47264
Buggy source:
@Override public Map loadAll(Collection keys){
  if (keys == null || keys.isEmpty()) {
    return Collections.emptyMap();
  }
  final Map<Object,Object> map=new HashMap<Object,Object>();
  final Iterator iterator=keys.iterator();
  while (iterator.hasNext()) {
    final Object key=iterator.next();
    final Data dataKey=toData(key);
    if (hasWaitingWriteBehindDeleteOperation(dataKey)) {
      iterator.remove();
      continue;
    }
    final Object valueFromStagingArea=getFromStagingArea(dataKey);
    if (valueFromStagingArea != null) {
      map.put(dataKey,valueFromStagingArea);
      iterator.remove();
    }
  }
  map.putAll(super.loadAll(keys));
  return map;
}

Fixed version (ground truth):
@Override public Map loadAll(Collection keys){
  if (keys == null || keys.isEmpty()) {
    return Collections.emptyMap();
  }
  final Map<Object,Object> map=new HashMap<Object,Object>();
  final Iterator iterator=keys.iterator();
  while (iterator.hasNext()) {
    final Object key=iterator.next();
    final Data dataKey=toData(key);
    DelayedEntry delayedEntry=getFromStagingArea(dataKey);
    if (delayedEntry != null) {
      Object value=delayedEntry.getValue();
      if (value != null) {
        map.put(dataKey,toObject(value));
      }
      iterator.remove();
    }
  }
  map.putAll(super.loadAll(keys));
  return map;
}
Program: 47265
Project: 47265
Buggy source:
public WriteBehindStore(MapStoreWrapper store,SerializationService serializationService,long writeDelayTime,int partitionId){
  super(store,serializationService);
  this.writeDelayTime=writeDelayTime;
  this.partitionId=partitionId;
  this.stagingArea=createStagingArea();
  this.flushCounter=new AtomicInteger(0);
  this.writeBehindWaitingDeletions=new HashSet<Data>();
  this.transients=new HashSet<Data>();
}

Fixed version (ground truth):
public WriteBehindStore(MapStoreWrapper store,SerializationService serializationService,long writeDelayTime,int partitionId){
  super(store,serializationService);
  this.writeDelayTime=writeDelayTime;
  this.partitionId=partitionId;
  this.stagingArea=createStagingArea();
  this.flushCounter=new AtomicInteger(0);
}
Program: 47266
Project: 47266
Buggy source:
@Override public void addTransient(Data key,long now){
  removeFromWaitingDeletions(key);
  transients.add(key);
}

Fixed version (ground truth):
@Override public void addTransient(Data key,long now){
  stagingArea.put(key,TRANSIENT);
}
Program: 47267
Project: 47267
Buggy source:
@Override public void remove(Data key,long now){
  final long writeDelay=this.writeDelayTime;
  final long storeTime=now + writeDelay;
  final DelayedEntry<Data,Object> delayedEntry=DelayedEntry.createWithNullValue(key,storeTime,partitionId);
  addToWaitingDeletions(key);
  removeFromStagingArea(key);
  transients.remove(key);
  writeBehindQueue.offer(delayedEntry);
}

Fixed version (ground truth):
@Override public void remove(Data key,long now){
  final long writeDelay=this.writeDelayTime;
  final long storeTime=now + writeDelay;
  final DelayedEntry<Data,Object> delayedEntry=DelayedEntry.createWithNullValue(key,storeTime,partitionId);
  add(delayedEntry);
}
Program: 47268
Project: 47268
Buggy source:
private Object getFromStagingArea(Data key){
  final DelayedEntry entry=stagingArea.get(key);
  if (entry == null) {
    return null;
  }
  final long storeTime=entry.getStoreTime();
  final long now=Clock.currentTimeMillis();
  if (now >= storeTime) {
    return null;
  }
  return toObject(entry.getValue());
}

Fixed version (ground truth):
private DelayedEntry getFromStagingArea(Data key){
  DelayedEntry entry=stagingArea.get(key);
  if (entry == null || entry == TRANSIENT) {
    return null;
  }
  return entry;
}
Program: 47269
Project: 47269
Buggy source:
@Override public Object load(Data key){
  if (hasWaitingWriteBehindDeleteOperation(key)) {
    return null;
  }
  final Object valueFromStagingArea=getFromStagingArea(key);
  return valueFromStagingArea == null ? getStore().load(toObject(key)) : valueFromStagingArea;
}

Fixed version (ground truth):
@Override public Object load(Data key){
  DelayedEntry delayedEntry=getFromStagingArea(key);
  return delayedEntry == null ? getStore().load(toObject(key)) : toObject(delayedEntry.getValue());
}
Program: 47270
Project: 47270
Buggy source:
@Test public void testMapTryPut() throws InterruptedException {
  final IMap<Object,Object> map=getInstance().getMap("String_Node_Str");
  final String key1="String_Node_Str";
  final String key2="String_Node_Str";
  map.lock(key1);
  final AtomicInteger counter=new AtomicInteger(6);
  final CountDownLatch latch=new CountDownLatch(1);
  Thread thread=new Thread(new Runnable(){
    public void run(){
      try {
        if (map.tryPut(key1,"String_Node_Str",100,TimeUnit.MILLISECONDS) == false)         counter.decrementAndGet();
        if (map.get(key1) == null)         counter.decrementAndGet();
        if (map.tryPut(key2,"String_Node_Str",100,TimeUnit.MILLISECONDS))         counter.decrementAndGet();
        if (map.get(key2).equals("String_Node_Str"))         counter.decrementAndGet();
        if (map.tryPut(key1,"String_Node_Str",5,TimeUnit.SECONDS))         counter.decrementAndGet();
        if (map.get(key1).equals("String_Node_Str"))         counter.decrementAndGet();
        latch.countDown();
      }
 catch (      Exception e) {
        e.printStackTrace();
        fail(e.getMessage());
      }
    }
  }
);
  thread.start();
  Thread.sleep(1000);
  map.unlock("String_Node_Str");
  latch.await(10,TimeUnit.SECONDS);
  assertEquals(0,counter.get());
  thread.join(10000);
}

Fixed version (ground truth):
@Test public void testMapTryPut() throws InterruptedException {
  final IMap<Object,Object> map=getInstance().getMap("String_Node_Str");
  final String key1="String_Node_Str";
  final String key2="String_Node_Str";
  map.lock(key1);
  final AtomicInteger counter=new AtomicInteger(6);
  final CountDownLatch latch=new CountDownLatch(1);
  final CountDownLatch waitTryPutFailure=new CountDownLatch(1);
  Thread thread=new Thread(new Runnable(){
    public void run(){
      try {
        if (map.tryPut(key1,"String_Node_Str",100,TimeUnit.MILLISECONDS) == false) {
          counter.decrementAndGet();
          waitTryPutFailure.countDown();
        }
        if (map.get(key1) == null) {
          counter.decrementAndGet();
        }
        if (map.tryPut(key2,"String_Node_Str",100,TimeUnit.MILLISECONDS)) {
          counter.decrementAndGet();
        }
        if (map.get(key2).equals("String_Node_Str")) {
          counter.decrementAndGet();
        }
        if (map.tryPut(key1,"String_Node_Str",5,TimeUnit.SECONDS)) {
          counter.decrementAndGet();
        }
        if (map.get(key1).equals("String_Node_Str")) {
          counter.decrementAndGet();
        }
        latch.countDown();
      }
 catch (      Exception e) {
        e.printStackTrace();
        fail(e.getMessage());
      }
    }
  }
);
  thread.start();
  assertOpenEventually(waitTryPutFailure);
  map.unlock("String_Node_Str");
  assertOpenEventually(latch);
  assertEquals(0,counter.get());
  assertJoinable(thread);
}
Program: 47271
Project: 47271
Buggy source:
protected void waitCompletionLatch(Integer countDownLatchId,int offset){
  final CountDownLatch countDownLatch=syncLocks.get(countDownLatchId);
  if (countDownLatch != null) {
    for (int i=0; i < offset; i++) {
      countDownLatch.countDown();
    }
    awaitLatch(countDownLatch);
  }
}

Fixed version (ground truth):
protected void waitCompletionLatch(Integer countDownLatchId,int offset,ICompletableFuture future) throws ExecutionException {
  final CountDownLatch countDownLatch=syncLocks.get(countDownLatchId);
  if (countDownLatch != null) {
    for (int i=0; i < offset; i++) {
      countDownLatch.countDown();
    }
    awaitLatch(countDownLatch,future);
  }
}
Program: 47272
Project: 47272
Buggy source:
protected <T>ICompletableFuture<T> invoke(ClientMessage req,Data keyData,boolean completionOperation){
  Integer completionId=null;
  if (completionOperation) {
    completionId=registerCompletionLatch(1);
  }
  try {
    int partitionId=clientContext.getPartitionService().getPartitionId(keyData);
    HazelcastClientInstanceImpl client=(HazelcastClientInstanceImpl)clientContext.getHazelcastInstance();
    final ClientInvocation clientInvocation=new ClientInvocation(client,req,partitionId);
    ClientInvocationFuture f=clientInvocation.invoke();
    if (completionOperation) {
      waitCompletionLatch(completionId);
    }
    return new ClientDelegatingFuture<T>(f,clientContext.getSerializationService());
  }
 catch (  Throwable e) {
    if (e instanceof IllegalStateException) {
      close();
    }
    if (completionOperation) {
      deregisterCompletionLatch(completionId);
    }
    throw ExceptionUtil.rethrowAllowedTypeFirst(e,CacheException.class);
  }
}

Fixed version (ground truth):
protected <T>ICompletableFuture<T> invoke(ClientMessage req,Data keyData,boolean completionOperation){
  Integer completionId=null;
  if (completionOperation) {
    completionId=registerCompletionLatch(1);
  }
  try {
    int partitionId=clientContext.getPartitionService().getPartitionId(keyData);
    HazelcastClientInstanceImpl client=(HazelcastClientInstanceImpl)clientContext.getHazelcastInstance();
    final ClientInvocation clientInvocation=new ClientInvocation(client,req,partitionId);
    ClientInvocationFuture f=clientInvocation.invoke();
    if (completionOperation) {
      waitCompletionLatch(completionId,f);
    }
    return new ClientDelegatingFuture<T>(f,clientContext.getSerializationService());
  }
 catch (  Throwable e) {
    if (e instanceof IllegalStateException) {
      close();
    }
    if (completionOperation) {
      deregisterCompletionLatch(completionId);
    }
    throw ExceptionUtil.rethrowAllowedTypeFirst(e,CacheException.class);
  }
}
Program: 47273
Project: 47273
Buggy source:
protected void removeAllInternal(Set<? extends K> keys){
  final Set<Data> keysData;
  if (keys != null) {
    keysData=new HashSet<Data>();
    for (    K key : keys) {
      keysData.add(toData(key));
    }
  }
 else {
    keysData=null;
  }
  final int partitionCount=clientContext.getPartitionService().getPartitionCount();
  int completionId=registerCompletionLatch(partitionCount);
  ClientMessage request=CacheRemoveAllParameters.encode(nameWithPrefix,keysData,completionId);
  try {
    invoke(request);
    waitCompletionLatch(completionId);
  }
 catch (  Throwable t) {
    deregisterCompletionLatch(completionId);
    throw ExceptionUtil.rethrowAllowedTypeFirst(t,CacheException.class);
  }
}

Fixed version (ground truth):
protected void removeAllInternal(Set<? extends K> keys){
  final Set<Data> keysData;
  if (keys != null) {
    keysData=new HashSet<Data>();
    for (    K key : keys) {
      keysData.add(toData(key));
    }
  }
 else {
    keysData=null;
  }
  final int partitionCount=clientContext.getPartitionService().getPartitionCount();
  int completionId=registerCompletionLatch(partitionCount);
  ClientMessage request=CacheRemoveAllParameters.encode(nameWithPrefix,keysData,completionId);
  try {
    invoke(request);
    waitCompletionLatch(completionId,null);
  }
 catch (  Throwable t) {
    deregisterCompletionLatch(completionId);
    throw ExceptionUtil.rethrowAllowedTypeFirst(t,CacheException.class);
  }
}
Program: 47274
Project: 47274
Buggy source:
private void awaitLatch(CountDownLatch countDownLatch){
  try {
    long currentTimeoutMs=MAX_COMPLETION_LATCH_WAIT_TIME;
    while (currentTimeoutMs > 0 && !countDownLatch.await(COMPLETION_LATCH_WAIT_TIME_STEP,TimeUnit.MILLISECONDS)) {
      currentTimeoutMs-=COMPLETION_LATCH_WAIT_TIME_STEP;
      if (!clientContext.isActive()) {
        throw new HazelcastInstanceNotActiveException();
      }
 else       if (isClosed()) {
        throw new IllegalStateException("String_Node_Str" + nameWithPrefix + "String_Node_Str");
      }
 else       if (isDestroyed()) {
        throw new IllegalStateException("String_Node_Str" + nameWithPrefix + "String_Node_Str");
      }
    }
  }
 catch (  InterruptedException e) {
    ExceptionUtil.sneakyThrow(e);
  }
}

Fixed version (ground truth):
private void awaitLatch(CountDownLatch countDownLatch,ICompletableFuture future) throws ExecutionException {
  try {
    long currentTimeoutMs=MAX_COMPLETION_LATCH_WAIT_TIME;
    while (currentTimeoutMs > 0 && !countDownLatch.await(COMPLETION_LATCH_WAIT_TIME_STEP,TimeUnit.MILLISECONDS)) {
      if (future != null && future.isDone()) {
        Object response=future.get();
        if (response instanceof Throwable) {
          return;
        }
      }
      currentTimeoutMs-=COMPLETION_LATCH_WAIT_TIME_STEP;
      if (!clientContext.isActive()) {
        throw new HazelcastInstanceNotActiveException();
      }
 else       if (isClosed()) {
        throw new IllegalStateException("String_Node_Str" + nameWithPrefix + "String_Node_Str");
      }
 else       if (isDestroyed()) {
        throw new IllegalStateException("String_Node_Str" + nameWithPrefix + "String_Node_Str");
      }
    }
    if (countDownLatch.getCount() > 0) {
      logger.finest("String_Node_Str" + MAX_COMPLETION_LATCH_WAIT_TIME + "String_Node_Str");
    }
  }
 catch (  InterruptedException e) {
    ExceptionUtil.sneakyThrow(e);
  }
}
Program: 47275
Project: 47275
Buggy source:
protected void waitCompletionLatch(Integer countDownLatchId,int offset){
  final CountDownLatch countDownLatch=syncLocks.get(countDownLatchId);
  if (countDownLatch != null) {
    for (int i=0; i < offset; i++) {
      countDownLatch.countDown();
    }
    awaitLatch(countDownLatch);
  }
}

Fixed version (ground truth):
protected void waitCompletionLatch(Integer countDownLatchId,int offset,ICompletableFuture future) throws ExecutionException {
  final CountDownLatch countDownLatch=syncLocks.get(countDownLatchId);
  if (countDownLatch != null) {
    for (int i=0; i < offset; i++) {
      countDownLatch.countDown();
    }
    awaitLatch(countDownLatch,future);
  }
}
Program: 47276
Project: 47276
Buggy source:
protected <T>ICompletableFuture<T> invoke(ClientRequest req,Data keyData,boolean completionOperation){
  Integer completionId=null;
  if (completionOperation) {
    completionId=registerCompletionLatch(1);
    if (req instanceof AbstractCacheRequest) {
      ((AbstractCacheRequest)req).setCompletionId(completionId);
    }
  }
  try {
    int partitionId=clientContext.getPartitionService().getPartitionId(keyData);
    HazelcastClientInstanceImpl client=(HazelcastClientInstanceImpl)clientContext.getHazelcastInstance();
    final ClientInvocation clientInvocation=new ClientInvocation(client,req,partitionId);
    final ICompletableFuture<T> f=clientInvocation.invoke();
    if (completionOperation) {
      waitCompletionLatch(completionId);
    }
    return f;
  }
 catch (  Throwable e) {
    if (e instanceof IllegalStateException) {
      close();
    }
    if (completionOperation) {
      deregisterCompletionLatch(completionId);
    }
    throw ExceptionUtil.rethrowAllowedTypeFirst(e,CacheException.class);
  }
}

Fixed version (ground truth):
protected <T>ICompletableFuture<T> invoke(ClientRequest req,Data keyData,boolean completionOperation){
  Integer completionId=null;
  if (completionOperation) {
    completionId=registerCompletionLatch(1);
    if (req instanceof AbstractCacheRequest) {
      ((AbstractCacheRequest)req).setCompletionId(completionId);
    }
  }
  try {
    int partitionId=clientContext.getPartitionService().getPartitionId(keyData);
    HazelcastClientInstanceImpl client=(HazelcastClientInstanceImpl)clientContext.getHazelcastInstance();
    final ClientInvocation clientInvocation=new ClientInvocation(client,req,partitionId);
    final ICompletableFuture<T> f=clientInvocation.invoke();
    if (completionOperation) {
      waitCompletionLatch(completionId,f);
    }
    return f;
  }
 catch (  Throwable e) {
    if (e instanceof IllegalStateException) {
      close();
    }
    if (completionOperation) {
      deregisterCompletionLatch(completionId);
    }
    throw ExceptionUtil.rethrowAllowedTypeFirst(e,CacheException.class);
  }
}
Program: 47277
Project: 47277
Buggy source:
protected void removeAllInternal(Set<? extends K> keys,boolean isRemoveAll){
  final Set<Data> keysData;
  if (keys != null) {
    keysData=new HashSet<Data>();
    for (    K key : keys) {
      keysData.add(toData(key));
    }
  }
 else {
    keysData=null;
  }
  final int partitionCount=clientContext.getPartitionService().getPartitionCount();
  int completionId=registerCompletionLatch(partitionCount);
  CacheClearRequest request=new CacheClearRequest(nameWithPrefix,keysData,isRemoveAll,completionId);
  try {
    final Map<Integer,Object> results=invoke(request);
    int completionCount=0;
    for (    Object result : results.values()) {
      if (result != null && result instanceof CacheClearResponse) {
        final Object response=((CacheClearResponse)result).getResponse();
        if (response instanceof Boolean) {
          completionCount++;
        }
        if (response instanceof Throwable) {
          throw (Throwable)response;
        }
      }
    }
    waitCompletionLatch(completionId,partitionCount - completionCount);
  }
 catch (  Throwable t) {
    deregisterCompletionLatch(completionId);
    throw ExceptionUtil.rethrowAllowedTypeFirst(t,CacheException.class);
  }
}

Fixed version (ground truth):
protected void removeAllInternal(Set<? extends K> keys,boolean isRemoveAll){
  final Set<Data> keysData;
  if (keys != null) {
    keysData=new HashSet<Data>();
    for (    K key : keys) {
      keysData.add(toData(key));
    }
  }
 else {
    keysData=null;
  }
  final int partitionCount=clientContext.getPartitionService().getPartitionCount();
  int completionId=registerCompletionLatch(partitionCount);
  CacheClearRequest request=new CacheClearRequest(nameWithPrefix,keysData,isRemoveAll,completionId);
  try {
    final Map<Integer,Object> results=invoke(request);
    int completionCount=0;
    for (    Object result : results.values()) {
      if (result != null && result instanceof CacheClearResponse) {
        final Object response=((CacheClearResponse)result).getResponse();
        if (response instanceof Boolean) {
          completionCount++;
        }
        if (response instanceof Throwable) {
          throw (Throwable)response;
        }
      }
    }
    waitCompletionLatch(completionId,partitionCount - completionCount,null);
  }
 catch (  Throwable t) {
    deregisterCompletionLatch(completionId);
    throw ExceptionUtil.rethrowAllowedTypeFirst(t,CacheException.class);
  }
}
Program: 47278
Project: 47278
Buggy source:
private void awaitLatch(CountDownLatch countDownLatch){
  try {
    long currentTimeoutMs=MAX_COMPLETION_LATCH_WAIT_TIME;
    while (currentTimeoutMs > 0 && !countDownLatch.await(COMPLETION_LATCH_WAIT_TIME_STEP,TimeUnit.MILLISECONDS)) {
      currentTimeoutMs-=COMPLETION_LATCH_WAIT_TIME_STEP;
      if (!clientContext.isActive()) {
        throw new HazelcastInstanceNotActiveException();
      }
 else       if (isClosed()) {
        throw new IllegalStateException("String_Node_Str" + nameWithPrefix + "String_Node_Str");
      }
 else       if (isDestroyed()) {
        throw new IllegalStateException("String_Node_Str" + nameWithPrefix + "String_Node_Str");
      }
    }
  }
 catch (  InterruptedException e) {
    ExceptionUtil.sneakyThrow(e);
  }
}

Fixed version (ground truth):
private void awaitLatch(CountDownLatch countDownLatch,ICompletableFuture future) throws ExecutionException {
  try {
    long currentTimeoutMs=MAX_COMPLETION_LATCH_WAIT_TIME;
    while (currentTimeoutMs > 0 && !countDownLatch.await(COMPLETION_LATCH_WAIT_TIME_STEP,TimeUnit.MILLISECONDS)) {
      if (future != null && future.isDone()) {
        Object response=future.get();
        if (response instanceof Throwable) {
          return;
        }
      }
      currentTimeoutMs-=COMPLETION_LATCH_WAIT_TIME_STEP;
      if (!clientContext.isActive()) {
        throw new HazelcastInstanceNotActiveException();
      }
 else       if (isClosed()) {
        throw new IllegalStateException("String_Node_Str" + nameWithPrefix + "String_Node_Str");
      }
 else       if (isDestroyed()) {
        throw new IllegalStateException("String_Node_Str" + nameWithPrefix + "String_Node_Str");
      }
    }
    if (countDownLatch.getCount() > 0) {
      logger.finest("String_Node_Str" + MAX_COMPLETION_LATCH_WAIT_TIME + "String_Node_Str");
    }
  }
 catch (  InterruptedException e) {
    ExceptionUtil.sneakyThrow(e);
  }
}
Program: 47279
Project: 47279
Buggy source:
@Test public void testMapTryPut() throws InterruptedException {
  final IMap<Object,Object> map=getInstance().getMap("String_Node_Str");
  final String key1="String_Node_Str";
  final String key2="String_Node_Str";
  map.lock(key1);
  final AtomicInteger counter=new AtomicInteger(6);
  final CountDownLatch latch=new CountDownLatch(1);
  Thread thread=new Thread(new Runnable(){
    public void run(){
      try {
        if (map.tryPut(key1,"String_Node_Str",100,TimeUnit.MILLISECONDS) == false)         counter.decrementAndGet();
        if (map.get(key1) == null)         counter.decrementAndGet();
        if (map.tryPut(key2,"String_Node_Str",100,TimeUnit.MILLISECONDS))         counter.decrementAndGet();
        if (map.get(key2).equals("String_Node_Str"))         counter.decrementAndGet();
        if (map.tryPut(key1,"String_Node_Str",5,TimeUnit.SECONDS))         counter.decrementAndGet();
        if (map.get(key1).equals("String_Node_Str"))         counter.decrementAndGet();
        latch.countDown();
      }
 catch (      Exception e) {
        e.printStackTrace();
        fail(e.getMessage());
      }
    }
  }
);
  thread.start();
  Thread.sleep(1000);
  map.unlock("String_Node_Str");
  latch.await(10,TimeUnit.SECONDS);
  assertEquals(0,counter.get());
  thread.join(10000);
}

Fixed version (ground truth):
@Test public void testMapTryPut() throws InterruptedException {
  final IMap<Object,Object> map=getInstance().getMap("String_Node_Str");
  final String key1="String_Node_Str";
  final String key2="String_Node_Str";
  map.lock(key1);
  final AtomicInteger counter=new AtomicInteger(6);
  final CountDownLatch latch=new CountDownLatch(1);
  final CountDownLatch waitTryPutFailure=new CountDownLatch(1);
  Thread thread=new Thread(new Runnable(){
    public void run(){
      try {
        if (map.tryPut(key1,"String_Node_Str",100,TimeUnit.MILLISECONDS) == false) {
          counter.decrementAndGet();
          waitTryPutFailure.countDown();
        }
        if (map.get(key1) == null) {
          counter.decrementAndGet();
        }
        if (map.tryPut(key2,"String_Node_Str",100,TimeUnit.MILLISECONDS)) {
          counter.decrementAndGet();
        }
        if (map.get(key2).equals("String_Node_Str")) {
          counter.decrementAndGet();
        }
        if (map.tryPut(key1,"String_Node_Str",5,TimeUnit.SECONDS)) {
          counter.decrementAndGet();
        }
        if (map.get(key1).equals("String_Node_Str")) {
          counter.decrementAndGet();
        }
        latch.countDown();
      }
 catch (      Exception e) {
        e.printStackTrace();
        fail(e.getMessage());
      }
    }
  }
);
  thread.start();
  assertOpenEventually(waitTryPutFailure);
  map.unlock("String_Node_Str");
  assertOpenEventually(latch);
  assertEquals(0,counter.get());
  assertJoinable(thread);
}
Program: 47280
Project: 47280
Buggy source:
public void register(){
  ioSelector.addTask(this);
  ioSelector.wakeup();
}

Fixed version (ground truth):
public void register(){
  ioSelector.addTaskAndWakeup(this);
}
Program: 47281
Project: 47281
Buggy source:
public void register(){
  ioSelector.addTask(this);
  ioSelector.wakeup();
}

Fixed version (ground truth):
public void register(){
  ioSelector.addTaskAndWakeup(this);
}
Program: 47282
Project: 47282
Buggy source:
/** 
 * Migrates this handler to a new IOSelector thread. The migration logic is rather simple: <p><ul> <li>Submit a de-registration task to a current IOSelector thread</li> <li>The de-registration task submits a registration task to the new IOSelector thread</li> </ul></p>
 * @param newOwner target IOSelector this handler migrates to
 */
public void migrate(final IOSelector newOwner){
  if (ioSelector == newOwner || !socketChannel.isOpen()) {
    return;
  }
  ioSelector.addTask(new MigrationTask(newOwner));
  ioSelector.wakeup();
}

Fixed version (ground truth):
/** 
 * Migrates this handler to a new IOSelector thread. The migration logic is rather simple: <p><ul> <li>Submit a de-registration task to a current IOSelector thread</li> <li>The de-registration task submits a registration task to the new IOSelector thread</li> </ul></p>
 * @param newOwner target IOSelector this handler migrates to
 */
public void migrate(final IOSelector newOwner){
  if (ioSelector == newOwner || !socketChannel.isOpen()) {
    return;
  }
  ioSelector.addTaskAndWakeup(new MigrationTask(newOwner));
}
Program: 47283
Project: 47283
Buggy source:
public void start(){
  ioSelector.addTask(new Runnable(){
    @Override public void run(){
      getSelectionKey();
    }
  }
);
  ioSelector.wakeup();
}

Fixed version (ground truth):
public void start(){
  ioSelector.addTaskAndWakeup(new Runnable(){
    @Override public void run(){
      getSelectionKey();
    }
  }
);
}
Program: 47284
Project: 47284
Buggy source:
void shutdown(){
  ioSelector.addTask(new Runnable(){
    @Override public void run(){
      try {
        socketChannel.closeInbound();
      }
 catch (      IOException e) {
        logger.finest("String_Node_Str",e);
      }
    }
  }
);
  ioSelector.wakeup();
}

Fixed version (ground truth):
void shutdown(){
  ioSelector.addTaskAndWakeup(new Runnable(){
    @Override public void run(){
      try {
        socketChannel.closeInbound();
      }
 catch (      IOException e) {
        logger.finest("String_Node_Str",e);
      }
    }
  }
);
}