nus-yam/ex-repair huggingface dataset:
Program: 50656
Project: 50656
Buggy source:
public Data put(Request req){
  if (req.operation == ClusterOperation.CONCURRENT_MAP_PUT_IF_ABSENT) {
    Record record=recordExist(req);
    if (record != null && record.getValue() != null) {
      return doHardCopy(record.getValue());
    }
  }
 else   if (req.operation == ClusterOperation.CONCURRENT_MAP_REPLACE_IF_NOT_NULL) {
    Record record=recordExist(req);
    if (record == null || record.getValue() == null) {
      return null;
    }
  }
  Record record=getRecord(req.key);
  Data oldValue=null;
  if (record == null) {
    record=createNewRecord(req.key,req.value);
    req.key=null;
  }
 else {
    if (!record.isValid()) {
      record.setExpirationTime(ttl);
    }
    oldValue=record.getValue();
    record.setValue(req.value);
    record.version++;
    touch(record);
    record.setLastUpdated();
  }
  req.version=record.version;
  req.longValue=record.copyCount;
  req.value=null;
  if (oldValue == null) {
    fireMapEvent(mapListeners,name,EntryEvent.TYPE_ADDED,record);
  }
 else {
    fireMapEvent(mapListeners,name,EntryEvent.TYPE_UPDATED,record);
  }
  markRecordDirty(record);
  return oldValue;
}

Fixed version (ground truth):
public Data put(Request req){
  if (req.value == null) {
    req.value=new Data();
  }
  if (req.operation == ClusterOperation.CONCURRENT_MAP_PUT_IF_ABSENT) {
    Record record=recordExist(req);
    if (record != null && record.getValue() != null) {
      return doHardCopy(record.getValue());
    }
  }
 else   if (req.operation == ClusterOperation.CONCURRENT_MAP_REPLACE_IF_NOT_NULL) {
    Record record=recordExist(req);
    if (record == null || record.getValue() == null) {
      return null;
    }
  }
  Record record=getRecord(req.key);
  Data oldValue=null;
  if (record == null) {
    record=createNewRecord(req.key,req.value);
    req.key=null;
  }
 else {
    if (!record.isValid()) {
      record.setExpirationTime(ttl);
    }
    oldValue=record.getValue();
    record.setValue(req.value);
    record.version++;
    touch(record);
    record.setLastUpdated();
  }
  req.version=record.version;
  req.longValue=record.copyCount;
  req.value=null;
  if (oldValue == null) {
    fireMapEvent(mapListeners,name,EntryEvent.TYPE_ADDED,record);
  }
 else {
    fireMapEvent(mapListeners,name,EntryEvent.TYPE_UPDATED,record);
  }
  markRecordDirty(record);
  return oldValue;
}
Program: 50657
Project: 50657
Buggy source:
public void own(Request req){
  Record record=toRecord(req);
  record.owner=thisAddress;
}

Fixed version (ground truth):
public void own(Request req){
  if (req.value == null) {
    req.value=new Data();
  }
  Record record=toRecord(req);
  record.owner=thisAddress;
}
Program: 50658
Project: 50658
Buggy source:
public Object getValue(){
  if (value == null) {
    value=((FactoryImpl.MProxy)FactoryImpl.getProxy(name)).get(key);
  }
  return value;
}

Fixed version (ground truth):
public Object getValue(){
  if (value == null) {
    value=((FactoryImpl.MProxy)FactoryImpl.getProxyByName(name)).get(key);
  }
  return value;
}
Program: 50659
Project: 50659
Buggy source:
public Object setValue(Object value){
  Object oldValue=this.value;
  ((FactoryImpl.MProxy)FactoryImpl.getProxy(name)).put(key,value);
  return oldValue;
}

Fixed version (ground truth):
public Object setValue(Object value){
  Object oldValue=this.value;
  ((FactoryImpl.MProxy)FactoryImpl.getProxyByName(name)).put(key,value);
  return oldValue;
}
Program: 50660
Project: 50660
Buggy source:
public void stop(){
  setJoins.clear();
  timeToStartJoin=0;
  lsMembers.clear();
}

Fixed version (ground truth):
public void stop(){
  if (setJoins != null) {
    setJoins.clear();
  }
  timeToStartJoin=0;
  if (lsMembers != null) {
    lsMembers.clear();
  }
}
Program: 50661
Project: 50661
Buggy source:
public void stop(){
  if (!started)   return;
  executionIds.clear();
  executor.shutdownNow();
  started=false;
}

Fixed version (ground truth):
public void stop(){
  if (!started)   return;
  executionIds.clear();
  if (executor != null) {
    executor.shutdownNow();
  }
  started=false;
}
Program: 50662
Project: 50662
Buggy source:
public void shutdown(){
  try {
    joined=false;
    ConcurrentMapManager.get().reset();
    ClusterService.get().stop();
    MulticastService.get().stop();
    ConnectionManager.get().shutdown();
    ExecutorManager.get().stop();
    InSelector.get().shutdown();
    OutSelector.get().shutdown();
    address=null;
    masterAddress=null;
    FactoryImpl.inited=false;
    ClusterManager.get().stop();
  }
 catch (  Throwable e) {
    logger.log(Level.FINEST,"String_Node_Str",e);
  }
}

Fixed version (ground truth):
public void shutdown(){
  try {
    joined=false;
    ConcurrentMapManager.get().reset();
    ClusterService.get().stop();
    MulticastService.get().stop();
    ConnectionManager.get().shutdown();
    ExecutorManager.get().stop();
    InSelector.get().shutdown();
    OutSelector.get().shutdown();
    address=null;
    masterAddress=null;
    FactoryImpl.inited=false;
    ClusterManager.get().stop();
  }
 catch (  Throwable e) {
    if (logger != null)     logger.log(Level.FINEST,"String_Node_Str",e);
  }
}
Program: 50663
Project: 50663
Buggy source:
@Override public void shutdown(){
  try {
    super.shutdown();
    serverSocketChannel.close();
  }
 catch (  IOException ignored) {
  }
}

Fixed version (ground truth):
@Override public void shutdown(){
  try {
    super.shutdown();
    if (serverSocketChannel != null) {
      serverSocketChannel.close();
    }
  }
 catch (  IOException ignored) {
  }
}
Program: 50664
Project: 50664
Buggy source:
public void shutdown(){
  live=false;
  selectorQueue.clear();
}

Fixed version (ground truth):
public void shutdown(){
  live=false;
  if (selectorQueue != null) {
    selectorQueue.clear();
  }
}
Program: 50665
Project: 50665
Buggy source:
public void removeMembershipListener(MembershipListener listener){
  Set<MembershipListener> oldListeners=listeners.get();
  if (oldListeners == null || oldListeners.size() == 0)   return;
  int size=oldListeners.size() - 1;
  Set<MembershipListener> newListeners=new LinkedHashSet<MembershipListener>(size);
  for (  MembershipListener existingListener : oldListeners) {
    if (existingListener.equals(listener))     newListeners.add(existingListener);
  }
  listeners.set(newListeners);
}

Fixed version (ground truth):
public void removeMembershipListener(MembershipListener listener){
  Set<MembershipListener> oldListeners=listeners.get();
  if (oldListeners == null || oldListeners.size() == 0)   return;
  int size=oldListeners.size() - 1;
  Set<MembershipListener> newListeners=new LinkedHashSet<MembershipListener>(size);
  for (  MembershipListener existingListener : oldListeners) {
    if (!existingListener.equals(listener)) {
      newListeners.add(existingListener);
    }
  }
  listeners.set(newListeners);
}
Program: 50666
Project: 50666
Buggy source:
void doRemoveAddress(Address deadAddress){
  if (DEBUG) {
    log("String_Node_Str" + deadAddress);
  }
  if (!Node.get().joined()) {
    return;
  }
  if (deadAddress.equals(thisAddress))   return;
  if (deadAddress.equals(getMasterAddress())) {
    if (Node.get().joined()) {
      MemberImpl newMaster=getNextMemberAfter(deadAddress,false,1);
      if (newMaster != null)       Node.get().setMasterAddress(newMaster.getAddress());
 else       Node.get().setMasterAddress(null);
    }
 else {
      Node.get().setMasterAddress(null);
    }
    if (DEBUG) {
      log("String_Node_Str" + Node.get().getMasterAddress());
    }
  }
  if (isMaster()) {
    setJoins.remove(new MemberInfo(deadAddress));
  }
  lsMembersBefore.clear();
  for (  MemberImpl member : lsMembers) {
    lsMembersBefore.add(member);
  }
  Connection conn=ConnectionManager.get().getConnection(deadAddress);
  if (conn != null) {
    ConnectionManager.get().remove(conn);
  }
  MemberImpl member=getMember(deadAddress);
  if (member != null) {
    removeMember(deadAddress);
  }
  BlockingQueueManager.get().syncForDead(deadAddress);
  ConcurrentMapManager.get().syncForDead(deadAddress);
  ListenerManager.get().syncForDead(deadAddress);
  TopicManager.get().syncForDead(deadAddress);
  Node.get().getClusterImpl().setMembers(lsMembers);
  Object[] calls=mapCalls.values().toArray();
  for (  Object call : calls) {
    ((Call)call).onDisconnect(deadAddress);
  }
  System.out.println(this);
}

Fixed version (ground truth):
void doRemoveAddress(Address deadAddress){
  if (DEBUG) {
    log("String_Node_Str" + deadAddress);
  }
  if (!Node.get().joined()) {
    return;
  }
  if (deadAddress.equals(thisAddress))   return;
  if (deadAddress.equals(getMasterAddress())) {
    if (Node.get().joined()) {
      MemberImpl newMaster=getNextMemberAfter(deadAddress,false,1);
      if (newMaster != null)       Node.get().setMasterAddress(newMaster.getAddress());
 else       Node.get().setMasterAddress(null);
    }
 else {
      Node.get().setMasterAddress(null);
    }
    if (DEBUG) {
      log("String_Node_Str" + Node.get().getMasterAddress());
    }
  }
  if (isMaster()) {
    setJoins.remove(new MemberInfo(deadAddress));
  }
  lsMembersBefore.clear();
  for (  MemberImpl member : lsMembers) {
    lsMembersBefore.add(member);
  }
  Connection conn=ConnectionManager.get().getConnection(deadAddress);
  if (conn != null) {
    ConnectionManager.get().remove(conn);
  }
  MemberImpl member=getMember(deadAddress);
  if (member != null) {
    removeMember(deadAddress);
  }
  BlockingQueueManager.get().syncForDead(deadAddress);
  ConcurrentMapManager.get().syncForDead(deadAddress);
  ListenerManager.get().syncForDead(deadAddress);
  TopicManager.get().syncForDead(deadAddress);
  Node.get().getClusterImpl().setMembers(lsMembers);
  Object[] calls=mapCalls.values().toArray();
  for (  Object call : calls) {
    ((Call)call).onDisconnect(deadAddress);
  }
  logger.log(Level.INFO,this.toString());
}
Program: 50668
Project: 50668
Buggy source:
public CMap(String name){
  super();
  this.name=name;
  mapRecords=new SortedHashMap<Data,Record>(10000);
  MapConfig mapConfig=Config.get().getMapConfig(name.substring(2));
  this.backupCount=mapConfig.getBackupCount();
  ttl=mapConfig.getTimeToLiveSeconds() * 1000L;
  if ("String_Node_Str".equalsIgnoreCase(mapConfig.getEvictionPolicy())) {
    evictionPolicy=OrderingType.LFU;
  }
 else   if ("String_Node_Str".equalsIgnoreCase(mapConfig.getEvictionPolicy())) {
    evictionPolicy=OrderingType.LRU;
  }
 else {
    evictionPolicy=OrderingType.NONE;
  }
  evictionRate=mapConfig.getEvictionPercentage() / 100;
  if (evictionPolicy == OrderingType.NONE) {
    maxSize=Integer.MAX_VALUE;
  }
 else {
    maxSize=(mapConfig.getMaxSize() == 0) ? MapConfig.DEFAULT_MAX_SIZE : mapConfig.getMaxSize();
  }
  instanceType=getInstanceType(name);
  loader=null;
  store=null;
}

Fixed version (ground truth):
public CMap(String name){
  super();
  this.name=name;
  mapRecords=new SortedHashMap<Data,Record>(10000);
  MapConfig mapConfig=Config.get().getMapConfig(name.substring(2));
  this.backupCount=mapConfig.getBackupCount();
  ttl=mapConfig.getTimeToLiveSeconds() * 1000L;
  if ("String_Node_Str".equalsIgnoreCase(mapConfig.getEvictionPolicy())) {
    evictionPolicy=OrderingType.LFU;
  }
 else   if ("String_Node_Str".equalsIgnoreCase(mapConfig.getEvictionPolicy())) {
    evictionPolicy=OrderingType.LRU;
  }
 else {
    evictionPolicy=OrderingType.NONE;
  }
  evictionRate=mapConfig.getEvictionPercentage() / 100f;
  if (evictionPolicy == OrderingType.NONE) {
    maxSize=Integer.MAX_VALUE;
  }
 else {
    maxSize=(mapConfig.getMaxSize() == 0) ? MapConfig.DEFAULT_MAX_SIZE : mapConfig.getMaxSize();
  }
  instanceType=getInstanceType(name);
  loader=null;
  store=null;
}
Program: 50669
Project: 50669
Buggy source:
public void run(){
  while (live) {
    if (size.get() > 0) {
      processSelectionQueue();
    }
    int selectedKeys;
    try {
      selectedKeys=selector.select(waitTime);
      if (Thread.interrupted()) {
        Node.get().handleInterruptedException(Thread.currentThread(),new RuntimeException());
      }
    }
 catch (    final Throwable exp) {
      continue;
    }
    if (selectedKeys == 0) {
      continue;
    }
    final Set<SelectionKey> setSelectedKeys=selector.selectedKeys();
    final Iterator<SelectionKey> it=setSelectedKeys.iterator();
    while (it.hasNext()) {
      final SelectionKey sk=it.next();
      it.remove();
      try {
        sk.interestOps(sk.interestOps() & ~sk.readyOps());
        final SelectionHandler selectionHandler=(SelectionHandler)sk.attachment();
        selectionHandler.handle();
      }
 catch (      final Exception e) {
        handleSelectorException(e);
      }
    }
  }
}

Fixed version (ground truth):
public void run(){
  while (live) {
    if (size.get() > 0) {
      processSelectionQueue();
    }
    int selectedKeys;
    try {
      selectedKeys=selector.select(waitTime);
      if (Thread.interrupted()) {
        Node.get().handleInterruptedException(Thread.currentThread(),new RuntimeException());
      }
    }
 catch (    final Throwable exp) {
      continue;
    }
    if (selectedKeys == 0) {
      continue;
    }
    final Set<SelectionKey> setSelectedKeys=selector.selectedKeys();
    final Iterator<SelectionKey> it=setSelectedKeys.iterator();
    while (it.hasNext()) {
      final SelectionKey sk=it.next();
      it.remove();
      try {
        sk.interestOps(sk.interestOps() & ~sk.readyOps());
        final SelectionHandler selectionHandler=(SelectionHandler)sk.attachment();
        selectionHandler.handle();
      }
 catch (      final Exception e) {
        handleSelectorException(e);
      }
    }
  }
  try {
    selector.close();
  }
 catch (  final Exception e) {
    e.printStackTrace();
  }
}
Program: 50670
Project: 50670
Buggy source:
public void shutdown(){
  live=false;
  selectorQueue.clear();
  try {
    selector.close();
  }
 catch (  final Exception e) {
    e.printStackTrace();
  }
}

Fixed version (ground truth):
public void shutdown(){
  live=false;
  selectorQueue.clear();
}
Program: 50671
Project: 50671
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 || 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: 50672
Project: 50672
Buggy source:
public void getEntries(Request request){
  Collection<Record> colRecords=mapRecords.values();
  Pairs pairs=new Pairs();
  long now=System.currentTimeMillis();
  for (  Record record : colRecords) {
    if (record.isValid(now)) {
      Block block=blocks[record.blockId];
      if (thisAddress.equals(block.owner)) {
        if (record.value != null) {
          pairs.addKeyValue(new KeyValue(record.key,null));
        }
 else         if (record.copyCount > 0) {
          for (int i=0; i < record.copyCount; i++) {
            pairs.addKeyValue(new KeyValue(record.key,null));
          }
        }
 else         if (record.lsValues != null) {
          int size=record.lsValues.size();
          if (size > 0) {
            if (request.operation == OP_CMAP_ITERATE_VALUES) {
              for (int i=0; i < size; i++) {
                Data value=record.lsValues.get(i);
                pairs.addKeyValue(new KeyValue(record.key,value));
              }
            }
 else {
              pairs.addKeyValue(new KeyValue(record.key,null));
            }
          }
        }
      }
    }
 else {
      if (!record.isEvictable()) {
        scheduleForEviction(record);
      }
    }
  }
  Data dataEntries=toData(pairs);
  request.longValue=pairs.size();
  request.response=dataEntries;
}

Fixed version (ground truth):
public void getEntries(Request request){
  Collection<Record> colRecords=mapRecords.values();
  Pairs pairs=new Pairs();
  long now=System.currentTimeMillis();
  for (  Record record : colRecords) {
    if (record.isValid(now)) {
      Block block=blocks[record.blockId];
      if (thisAddress.equals(block.owner)) {
        if (record.value != null) {
          pairs.addKeyValue(new KeyValue(record.key,null));
        }
 else         if (record.copyCount > 0) {
          for (int i=0; i < record.copyCount; i++) {
            pairs.addKeyValue(new KeyValue(record.key,null));
          }
        }
 else         if (record.lsValues != null) {
          int size=record.lsValues.size();
          if (size > 0) {
            if (request.operation == OP_CMAP_ITERATE_KEYS) {
              pairs.addKeyValue(new KeyValue(record.key,null));
            }
 else {
              for (int i=0; i < size; i++) {
                Data value=record.lsValues.get(i);
                pairs.addKeyValue(new KeyValue(record.key,value));
              }
            }
          }
        }
      }
    }
 else {
      if (!record.isEvictable()) {
        scheduleForEviction(record);
      }
    }
  }
  Data dataEntries=toData(pairs);
  request.longValue=pairs.size();
  request.response=dataEntries;
}
Program: 50673
Project: 50673
Buggy source:
static Object createProxy(String name){
  ICommon proxy=proxies.get(name);
  if (proxy == null) {
    if (name.startsWith("String_Node_Str")) {
      proxy=proxies.get(name);
      if (proxy == null) {
        proxy=new QProxyImpl(name);
        proxies.put(name,proxy);
      }
    }
 else     if (name.startsWith("String_Node_Str")) {
      proxy=proxies.get(name);
      if (proxy == null) {
        proxy=new TopicProxyImpl(name);
        proxies.put(name,proxy);
      }
    }
 else     if (name.startsWith("String_Node_Str")) {
      proxy=proxies.get(name);
      if (proxy == null) {
        proxy=new MProxyImpl(name);
        proxies.put(name,proxy);
      }
    }
 else     if (name.startsWith("String_Node_Str")) {
      proxy=proxies.get(name);
      if (proxy == null) {
        if (BaseManager.getMapType(name) == MAP_TYPE_MULTI_MAP) {
          proxy=new MultiMapProxy(name);
        }
 else {
          proxy=new CollectionProxyImpl(name);
        }
        proxies.put(name,proxy);
      }
    }
  }
  return proxy;
}

Fixed version (ground truth):
static Object createProxy(String name){
  ICommon proxy=proxies.get(name);
  if (proxy == null) {
    if (name.startsWith("String_Node_Str")) {
      proxy=proxies.get(name);
      if (proxy == null) {
        proxy=new QProxyImpl(name);
        proxies.put(name,proxy);
      }
    }
 else     if (name.startsWith("String_Node_Str")) {
      proxy=proxies.get(name);
      if (proxy == null) {
        proxy=new TopicProxyImpl(name);
        proxies.put(name,proxy);
      }
    }
 else     if (name.startsWith("String_Node_Str")) {
      proxy=proxies.get(name);
      if (proxy == null) {
        proxy=new MProxyImpl(name);
        proxies.put(name,proxy);
      }
    }
 else     if (name.startsWith("String_Node_Str")) {
      proxy=proxies.get(name);
      if (proxy == null) {
        if (BaseManager.getInstanceType(name) == ICommon.InstanceType.MULTIMAP) {
          proxy=new MultiMapProxy(name);
        }
 else {
          proxy=new CollectionProxyImpl(name);
        }
        proxies.put(name,proxy);
      }
    }
  }
  return proxy;
}
Program: 50674
Project: 50674
Buggy source:
public Object getValue(){
  if (objValue == null) {
    if (value != null) {
      objValue=toObject(value);
    }
 else {
      objValue=((FactoryImpl.MProxy)FactoryImpl.getProxy(name)).get((key == null) ? getKey() : key);
    }
  }
  return objValue;
}

Fixed version (ground truth):
public Object getValue(){
  if (objValue == null) {
    if (value != null) {
      objValue=toObject(value);
    }
 else {
      objValue=((FactoryImpl.IGetAwareProxy)FactoryImpl.getProxy(name)).get((key == null) ? getKey() : key);
    }
  }
  return objValue;
}
Program: 50675
Project: 50675
Buggy source:
public MGetEntries(Address target){
  this.target=target;
  request.reset();
  request.name=name;
  request.operation=(iteratorType == MIterate.TYPE_KEYS) ? OP_CMAP_ITERATE_KEYS : OP_CMAP_ITERATE;
}

Fixed version (ground truth):
public MGetEntries(Address target){
  this.target=target;
  request.reset();
  request.name=name;
  if (iteratorType == MIterate.TYPE_ENTRIES) {
    request.operation=OP_CMAP_ITERATE_ENTRIES;
  }
 else   if (iteratorType == MIterate.TYPE_KEYS) {
    request.operation=OP_CMAP_ITERATE_KEYS;
  }
 else   if (iteratorType == MIterate.TYPE_VALUES) {
    request.operation=OP_CMAP_ITERATE_VALUES;
  }
}
Program: 50677
Project: 50677
Buggy source:
public void getEntries(Request request){
  Collection<Record> colRecords=mapRecords.values();
  Pairs pairs=new Pairs();
  long now=System.currentTimeMillis();
  for (  Record record : colRecords) {
    if (record.isValid(now)) {
      Block block=blocks[record.blockId];
      if (thisAddress.equals(block.owner)) {
        if (record.value != null) {
          pairs.addKeyValue(new KeyValue(record.key,null));
        }
 else         if (record.copyCount > 0) {
          for (int i=0; i < record.copyCount; i++) {
            pairs.addKeyValue(new KeyValue(record.key,null));
          }
        }
 else         if (record.lsValues != null) {
          int size=record.lsValues.size();
          if (size > 0) {
            if (request.operation == OP_CMAP_ITERATE_KEYS) {
              pairs.addKeyValue(new KeyValue(record.key,null));
            }
 else {
              for (int i=0; i < size; i++) {
                Data value=record.lsValues.get(i);
                pairs.addKeyValue(new KeyValue(record.key,null));
              }
            }
          }
        }
      }
    }
 else {
      if (!record.isEvictable()) {
        scheduleForEviction(record);
      }
    }
  }
  Data dataEntries=toData(pairs);
  request.longValue=pairs.size();
  request.response=dataEntries;
}

Fixed version (ground truth):
public void getEntries(Request request){
  Collection<Record> colRecords=mapRecords.values();
  Pairs pairs=new Pairs();
  long now=System.currentTimeMillis();
  for (  Record record : colRecords) {
    if (record.isValid(now)) {
      Block block=blocks[record.blockId];
      if (thisAddress.equals(block.owner)) {
        if (record.value != null) {
          pairs.addKeyValue(new KeyValue(record.key,null));
        }
 else         if (record.copyCount > 0) {
          for (int i=0; i < record.copyCount; i++) {
            pairs.addKeyValue(new KeyValue(record.key,null));
          }
        }
 else         if (record.lsValues != null) {
          int size=record.lsValues.size();
          if (size > 0) {
            if (request.operation == OP_CMAP_ITERATE_VALUES) {
              for (int i=0; i < size; i++) {
                Data value=record.lsValues.get(i);
                pairs.addKeyValue(new KeyValue(record.key,value));
              }
            }
 else {
              pairs.addKeyValue(new KeyValue(record.key,null));
            }
          }
        }
      }
    }
 else {
      if (!record.isEvictable()) {
        scheduleForEviction(record);
      }
    }
  }
  Data dataEntries=toData(pairs);
  request.longValue=pairs.size();
  request.response=dataEntries;
}
Program: 50678
Project: 50678
Buggy source:
public boolean removeItem(Request req){
  Record record=mapRecords.get(req.key);
  req.key.setNoData();
  req.key=null;
  if (record == null) {
    return false;
  }
  boolean removed=false;
  if (record.getCopyCount() > 0) {
    record.decrementCopyCount();
    removed=true;
  }
 else   if (record.value != null) {
    removed=true;
  }
  if (removed) {
    fireMapEvent(mapListeners,name,EntryEvent.TYPE_REMOVED,record);
    record.version++;
    if (record.value != null) {
      record.value.setNoData();
      record.value=null;
    }
  }
  req.version=record.version;
  req.longValue=record.copyCount;
  if (record.isRemovable()) {
    removeRecord(record.key);
    record.key.setNoData();
    record.key=null;
  }
  return true;
}

Fixed version (ground truth):
public boolean removeItem(Request req){
  Record record=mapRecords.get(req.key);
  req.key.setNoData();
  req.key=null;
  if (record == null) {
    return false;
  }
  boolean removed=false;
  if (record.getCopyCount() > 0) {
    record.decrementCopyCount();
    removed=true;
  }
 else   if (record.value != null) {
    removed=true;
  }
 else   if (record.lsValues != null) {
    removed=true;
  }
  if (removed) {
    fireMapEvent(mapListeners,name,EntryEvent.TYPE_REMOVED,record);
    record.version++;
    if (record.value != null) {
      record.value.setNoData();
      record.value=null;
    }
 else     if (record.lsValues != null) {
      for (      Data v : record.lsValues) {
        v.setNoData();
      }
      record.lsValues=null;
    }
  }
  req.version=record.version;
  req.longValue=record.copyCount;
  if (record.isRemovable()) {
    removeRecord(record.key);
    record.key.setNoData();
    record.key=null;
  }
  return true;
}
Program: 50679
Project: 50679
Buggy source:
public static int copy(ByteBuffer src,ByteBuffer dest){
  int n=Math.min(src.remaining(),dest.remaining());
  int srcPosition=src.position();
  int destPosition=dest.position();
  int ixSrc=srcPosition + src.arrayOffset();
  int ixDest=destPosition + dest.arrayOffset();
  System.arraycopy(src.array(),ixSrc,dest.array(),ixDest,n);
  src.position(srcPosition + n);
  dest.position(destPosition + n);
  return n;
}

Fixed version (ground truth):
public static int copy(ByteBuffer src,ByteBuffer dest){
  int n=Math.min(src.remaining(),dest.remaining());
  if (n > 0) {
    int srcPosition=src.position();
    int destPosition=dest.position();
    int ixSrc=srcPosition + src.arrayOffset();
    int ixDest=destPosition + dest.arrayOffset();
    System.arraycopy(src.array(),ixSrc,dest.array(),ixDest,n);
    src.position(srcPosition + n);
    dest.position(destPosition + n);
  }
  return n;
}
Program: 50680
Project: 50680
Buggy source:
public void reset(){
  name=null;
  operation=-1;
  threadId=-1;
  lockCount=0;
  lockAddress=null;
  timeout=-1;
  txnId=-1;
  responseType=Constants.ResponseTypes.RESPONSE_NONE;
  local=true;
  currentCallCount=0;
  blockId=-1;
  longValue=Long.MIN_VALUE;
  recordId=-1;
  version=-1;
  callId=-1;
  bbSizes.clear();
  bbHeader.clear();
  key.setNoData();
  value.setNoData();
  conn=null;
  totalSize=0;
}

Fixed version (ground truth):
public void reset(){
  name=null;
  operation=-1;
  threadId=-1;
  lockCount=0;
  lockAddress=null;
  timeout=-1;
  txnId=-1;
  responseType=Constants.ResponseTypes.RESPONSE_NONE;
  local=true;
  currentCallCount=0;
  blockId=-1;
  longValue=Long.MIN_VALUE;
  recordId=-1;
  version=-1;
  callId=-1;
  bbSizes.clear();
  bbHeader.clear();
  key.setNoData();
  value.setNoData();
  conn=null;
  totalSize=0;
  totalWritten=0;
}
Program: 50681
Project: 50681
Buggy source:
public ReadHandler(final Connection connection){
  super(connection);
  inBuffer=ByteBuffer.allocate(32 * 1024);
}

Fixed version (ground truth):
public ReadHandler(final Connection connection){
  super(connection);
}
Program: 50683
Project: 50683
Buggy source:
public void handle(){
  if (writeCount++ % 10000 == 0) {
    logger.log(Level.FINEST,"String_Node_Str" + writeCount);
    writeCount=1;
  }
  if (writeQueue.size() == 0) {
    ready=true;
    return;
  }
  if (!connection.live())   return;
  try {
    bbOut.clear();
    copyLoop:     while (bbOut.position() < (32 * 1024)) {
      final PacketQueue.Packet packet=(PacketQueue.Packet)writeQueue.poll();
      if (packet == null)       break copyLoop;
      packet.write(bbOut);
      packet.returnToContainer();
    }
    if (bbOut.position() == 0)     return;
    bbOut.flip();
    int remaining=bbOut.remaining();
    int loopCount=0;
    while (remaining > 0) {
      try {
        final int written=socketChannel.write(bbOut);
        remaining-=written;
        loopCount++;
        if (DEBUG) {
          if (loopCount > 1) {
            logger.log(Level.FINEST,"String_Node_Str" + loopCount);
          }
        }
      }
 catch (      final Exception e) {
        handleSocketException(e);
        return;
      }
    }
  }
 catch (  final Throwable t) {
    logger.log(Level.SEVERE,"String_Node_Str" + connection.getEndPoint(),t);
  }
 finally {
    ready=false;
    registerWrite();
  }
}

Fixed version (ground truth):
public void handle(){
  if (lastPacket == null && writeQueue.size() == 0) {
    ready=true;
    return;
  }
  if (!connection.live())   return;
  try {
    loop:     while (socketBB.hasRemaining()) {
      if (lastPacket == null) {
        lastPacket=(Packet)writeQueue.poll();
      }
      if (lastPacket != null) {
        boolean packetDone=lastPacket.doWrite(socketBB);
        if (packetDone) {
          lastPacket.returnToContainer();
          lastPacket=null;
        }
      }
 else       break loop;
    }
    socketBB.flip();
    try {
      socketChannel.write(socketBB);
    }
 catch (    final Exception e) {
      if (lastPacket != null) {
        lastPacket.returnToContainer();
        lastPacket=null;
      }
      handleSocketException(e);
      return;
    }
    if (socketBB.hasRemaining()) {
      socketBB.compact();
    }
 else {
      socketBB.clear();
    }
  }
 catch (  final Throwable t) {
    logger.log(Level.SEVERE,"String_Node_Str" + connection.getEndPoint(),t);
  }
 finally {
    ready=false;
    registerWrite();
  }
}
Program: 50685
Project: 50685
Buggy source:
int offer(Request req){
  int addIndex=blCurrentPut.add(req.value);
  try {
    long recordId=getRecordId(blCurrentPut.blockId,addIndex);
    req.recordId=recordId;
    doFireEntryEvent(true,req.value,recordId);
    size++;
    while (lsScheduledPollActions.size() > 0) {
      ScheduledAction pollAction=lsScheduledPollActions.remove(0);
      ClusterManager.get().deregisterScheduledAction(pollAction);
      if (pollAction.expired()) {
        pollAction.onExpire();
      }
 else {
        boolean consumed=pollAction.consume();
        if (consumed)         return -1;
      }
    }
    sendBackup(true,req.caller,req.value,blCurrentPut.blockId,addIndex);
  }
  finally {
    req.longValue=addIndex;
    if (blCurrentPut.isFull()) {
      fireBlockFullEvent(blCurrentPut);
      blCurrentPut=null;
      setCurrentPut();
    }
  }
  return addIndex;
}

Fixed version (ground truth):
int offer(Request req){
  try {
    int addIndex=blCurrentPut.add(req.value);
    long recordId=getRecordId(blCurrentPut.blockId,addIndex);
    req.recordId=recordId;
    doFireEntryEvent(true,req.value,recordId);
    size++;
    sendBackup(true,req.caller,req.value,blCurrentPut.blockId,addIndex);
    req.longValue=addIndex;
    if (blCurrentPut.isFull()) {
      fireBlockFullEvent(blCurrentPut);
      blCurrentPut=null;
      setCurrentPut();
    }
    return addIndex;
  }
  finally {
    boolean consumed=false;
    while (!consumed && lsScheduledPollActions.size() > 0) {
      ScheduledAction pollAction=lsScheduledPollActions.remove(0);
      ClusterManager.get().deregisterScheduledAction(pollAction);
      if (pollAction.expired()) {
        pollAction.onExpire();
      }
 else {
        consumed=pollAction.consume();
      }
    }
  }
}
Program: 50686
Project: 50686
Buggy source:
public void sendAddBlockMessageToOthers(Block block,int fullBlockId,Address except,boolean add){
  int operation=OP_B_ADD_BLOCK;
  if (!add) {
    operation=OP_B_REMOVE_BLOCK;
  }
  if (lsMembers.size() > 1) {
    int addBlockId=-1;
    int removeBlockId=-1;
    Address addAddress=null;
    if (add) {
      addBlockId=block.blockId;
      addAddress=block.address;
      except=null;
    }
 else {
      removeBlockId=block.blockId;
    }
    BlockUpdate addRemove=new BlockUpdate(addAddress,addBlockId,fullBlockId,removeBlockId);
    for (    MemberImpl member : lsMembers) {
      if (!member.localMember()) {
        Address dest=member.getAddress();
        if (!dest.equals(except)) {
          send(block.name,operation,addRemove,dest);
        }
      }
    }
  }
}

Fixed version (ground truth):
public void sendAddBlockMessageToOthers(String name,Address addAddress,int blockId,int fullBlockId,Address except,boolean add){
  int operation=OP_B_ADD_BLOCK;
  if (!add) {
    operation=OP_B_REMOVE_BLOCK;
  }
  if (lsMembers.size() > 1) {
    int addBlockId=-1;
    int removeBlockId=-1;
    if (add) {
      addBlockId=blockId;
      except=null;
    }
 else {
      removeBlockId=blockId;
    }
    BlockUpdate addRemove=new BlockUpdate(addAddress,addBlockId,fullBlockId,removeBlockId);
    for (    MemberImpl member : lsMembers) {
      if (!member.localMember()) {
        Address dest=member.getAddress();
        if (!dest.equals(except)) {
          send(name,operation,addRemove,dest);
        }
      }
    }
  }
}
Program: 50687
Project: 50687
Buggy source:
public void doRemoveBlock(Q q,Address originalRemover,int blockId){
  Block blockRemoved=q.removeBlock(blockId);
  if (blockRemoved != null) {
    if (isMaster()) {
      sendAddBlockMessageToOthers(blockRemoved,-1,originalRemover,false);
    }
  }
}

Fixed version (ground truth):
public void doRemoveBlock(Q q,Address originalRemover,int blockId){
  Block blockRemoved=q.removeBlock(blockId);
  if (isMaster()) {
    sendAddBlockMessageToOthers(q.name,null,blockId,-1,originalRemover,false);
  }
}
Program: 50688
Project: 50688
Buggy source:
public Data poll(Request request){
  setCurrentTake();
  Data value=blCurrentTake.remove();
  if (request.txnId != -1) {
    MemberImpl backup=null;
    if (request.caller.equals(thisAddress)) {
      backup=getNextMemberAfter(thisAddress,true,1);
    }
 else {
      backup=getNextMemberAfter(request.caller,true,1);
    }
    if (backup != null) {
      if (backup.getAddress().equals(thisAddress)) {
        doTxnBackupPoll(request.txnId,value);
      }
 else {
        sendTxnBackup(backup.getAddress(),value,request.txnId);
      }
    }
  }
  size--;
  long recordId=getRecordId(blCurrentTake.blockId,blCurrentTake.removeIndex);
  request.recordId=recordId;
  doFireEntryEvent(false,value,recordId);
  runScheduledOffer:   while (lsScheduledOfferActions.size() > 0) {
    ScheduledOfferAction offerAction=lsScheduledOfferActions.remove(0);
    ClusterManager.get().deregisterScheduledAction(offerAction);
    if (offerAction.expired()) {
      offerAction.onExpire();
    }
 else {
      boolean consumed=offerAction.consume();
      if (consumed) {
        break runScheduledOffer;
      }
    }
  }
  sendBackup(false,request.caller,null,blCurrentTake.blockId,0);
  if (blCurrentTake.size() == 0 && blCurrentTake.isFull()) {
    fireBlockRemoveEvent(blCurrentTake);
    blCurrentTake=null;
  }
  return value;
}

Fixed version (ground truth):
public Data poll(Request request){
  try {
    setCurrentTake();
    Data value=blCurrentTake.remove();
    if (request.txnId != -1) {
      MemberImpl backup=null;
      if (request.caller.equals(thisAddress)) {
        backup=getNextMemberAfter(thisAddress,true,1);
      }
 else {
        backup=getNextMemberAfter(request.caller,true,1);
      }
      if (backup != null) {
        if (backup.getAddress().equals(thisAddress)) {
          doTxnBackupPoll(request.txnId,value);
        }
 else {
          sendTxnBackup(backup.getAddress(),value,request.txnId);
        }
      }
    }
    size--;
    long recordId=getRecordId(blCurrentTake.blockId,blCurrentTake.removeIndex);
    request.recordId=recordId;
    doFireEntryEvent(false,value,recordId);
    sendBackup(false,request.caller,null,blCurrentTake.blockId,0);
    if (blCurrentTake.size() == 0 && blCurrentTake.isFull()) {
      fireBlockRemoveEvent(blCurrentTake);
      blCurrentTake=null;
    }
    return value;
  }
  finally {
    boolean consumed=false;
    while (!consumed && lsScheduledOfferActions.size() > 0) {
      ScheduledOfferAction offerAction=lsScheduledOfferActions.remove(0);
      ClusterManager.get().deregisterScheduledAction(offerAction);
      if (offerAction.expired()) {
        offerAction.onExpire();
      }
 else {
        consumed=offerAction.consume();
      }
    }
  }
}
Program: 50689
Project: 50689
Buggy source:
public Block removeBlock(int blockId){
  int size=lsBlocks.size();
  for (int i=0; i < size; i++) {
    Block b=lsBlocks.get(i);
    if (b.blockId == blockId) {
      blCurrentTake=null;
      return lsBlocks.remove(i);
    }
  }
  return null;
}

Fixed version (ground truth):
public Block removeBlock(int blockId){
  try {
    if (blCurrentPut != null && blCurrentPut.blockId == blockId) {
      blCurrentPut=null;
    }
    if (blCurrentTake != null && blCurrentTake.blockId == blockId) {
      blCurrentTake=null;
    }
    int size=lsBlocks.size();
    for (int i=0; i < size; i++) {
      Block b=lsBlocks.get(i);
      if (b.blockId == blockId) {
        blCurrentTake=null;
        return lsBlocks.remove(i);
      }
    }
    return null;
  }
  finally {
    if (blCurrentPut == null) {
      setCurrentPut();
    }
  }
}
Program: 50690
Project: 50690
Buggy source:
public void setBlockFull(int fullBlockId){
  int size=lsBlocks.size();
  for (int i=0; i < size; i++) {
    Block block=lsBlocks.get(i);
    if (block.blockId == fullBlockId) {
      block.setFull(true);
      blCurrentPut=null;
      return;
    }
  }
}

Fixed version (ground truth):
public void setBlockFull(int fullBlockId){
  if (blCurrentPut != null && blCurrentPut.blockId == fullBlockId) {
    blCurrentPut.setFull(true);
    blCurrentPut=null;
  }
  if (blCurrentTake != null && blCurrentTake.blockId == fullBlockId) {
    blCurrentTake.setFull(true);
  }
  int size=lsBlocks.size();
  for (int i=0; i < size; i++) {
    Block block=lsBlocks.get(i);
    if (block.blockId == fullBlockId) {
      block.setFull(true);
      blCurrentPut=null;
      return;
    }
  }
}
Program: 50691
Project: 50691
Buggy source:
public EventTask(final int eventType,final String name,final Data dataKey,final Data dataValue){
  super(name);
  this.eventType=eventType;
  this.dataValue=dataValue;
  this.dataKey=dataKey;
}

Fixed version (ground truth):
public EventTask(final int eventType,final String name,final Data dataKey,final Data dataValue){
  super(name);
  this.eventType=eventType;
  this.dataKey=dataKey;
  this.dataValue=dataValue;
}
Program: 50692
Project: 50692
Buggy source:
public void run(){
  try {
    if (!collection) {
      key=ThreadContext.get().toObject(dataKey);
    }
    if (dataValue != null) {
      value=ThreadContext.get().toObject(dataValue);
    }
    ListenerManager.get().callListeners(this);
  }
 catch (  final Exception e) {
    e.printStackTrace();
  }
}

Fixed version (ground truth):
public void run(){
  try {
    if (dataKey != null) {
      key=toObject(dataKey);
    }
    if (dataValue != null) {
      value=toObject(dataValue);
    }
 else     if (collection) {
      value=key;
    }
    ListenerManager.get().callListeners(this);
  }
 catch (  final Exception e) {
    e.printStackTrace();
  }
}
Program: 50693
Project: 50693
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 PacketQueue sq=PacketQueue.get();
    final Set<Map.Entry<Address,Boolean>> entries=mapListeners.entrySet();
    for (    final Map.Entry<Address,Boolean> entry : entries) {
      final Address address=entry.getKey();
      final boolean includeValue=entry.getValue();
      if (address.isThisAddress()) {
        try {
          final Data eventKey=(key != null) ? ThreadContext.get().hardCopy(key) : null;
          Data eventValue=null;
          if (includeValue)           eventValue=ThreadContext.get().hardCopy(value);
          enqueueEvent(eventType,name,eventKey,eventValue,address);
        }
 catch (        final Exception e) {
          e.printStackTrace();
        }
      }
 else {
        final PacketQueue.Packet packet=sq.obtainPacket();
        packet.reset();
        try {
          final Data eventKey=key;
          Data eventValue=null;
          if (includeValue)           eventValue=value;
          packet.set(name,OP_EVENT,eventKey,eventValue);
          packet.longValue=eventType;
        }
 catch (        final Exception e) {
          e.printStackTrace();
        }
        final boolean sent=send(packet,address);
        if (!sent)         packet.returnToContainer();
      }
    }
  }
}

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 PacketQueue sq=PacketQueue.get();
    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,doHardCopy(key),(includeValue) ? doHardCopy(value) : null,address);
        }
 catch (        final Exception e) {
          e.printStackTrace();
        }
      }
 else {
        final PacketQueue.Packet packet=sq.obtainPacket();
        packet.reset();
        try {
          packet.set(name,OP_EVENT,key,(includeValue) ? value : null);
          packet.longValue=eventType;
        }
 catch (        final Exception e) {
          e.printStackTrace();
        }
        final boolean sent=send(packet,address);
        if (!sent)         packet.returnToContainer();
      }
    }
  }
}
Program: 50694
Project: 50694
Buggy source:
int offer(Request req){
  try {
    int addIndex=blCurrentPut.add(req.value);
    long recordId=getRecordId(blCurrentPut.blockId,addIndex);
    req.recordId=recordId;
    doFireEntryEvent(true,req.value,recordId);
    sendBackup(true,req.caller,req.value,blCurrentPut.blockId,addIndex);
    req.longValue=addIndex;
    if (blCurrentPut.isFull()) {
      fireBlockFullEvent(blCurrentPut);
      blCurrentPut=null;
      setCurrentPut();
    }
    return addIndex;
  }
  finally {
    boolean consumed=false;
    while (!consumed && lsScheduledPollActions.size() > 0) {
      ScheduledAction pollAction=lsScheduledPollActions.remove(0);
      ClusterManager.get().deregisterScheduledAction(pollAction);
      if (pollAction.expired()) {
        pollAction.onExpire();
      }
 else {
        consumed=pollAction.consume();
      }
    }
  }
}

Fixed version (ground truth):
int offer(Request req){
  try {
    int addIndex=blCurrentPut.add(req.value);
    long recordId=getRecordId(blCurrentPut.blockId,addIndex);
    req.recordId=recordId;
    doFireEntryEvent(true,req.value);
    sendBackup(true,req.caller,req.value,blCurrentPut.blockId,addIndex);
    req.longValue=addIndex;
    if (blCurrentPut.isFull()) {
      fireBlockFullEvent(blCurrentPut);
      blCurrentPut=null;
      setCurrentPut();
    }
    return addIndex;
  }
  finally {
    boolean consumed=false;
    while (!consumed && lsScheduledPollActions.size() > 0) {
      ScheduledAction pollAction=lsScheduledPollActions.remove(0);
      ClusterManager.get().deregisterScheduledAction(pollAction);
      if (pollAction.expired()) {
        pollAction.onExpire();
      }
 else {
        consumed=pollAction.consume();
      }
    }
  }
}
Program: 50695
Project: 50695
Buggy source:
public Data poll(Request request){
  try {
    setCurrentTake();
    Data value=blCurrentTake.remove();
    if (request.txnId != -1) {
      MemberImpl backup=null;
      if (request.caller.equals(thisAddress)) {
        backup=getNextMemberAfter(thisAddress,true,1);
      }
 else {
        backup=getNextMemberAfter(request.caller,true,1);
      }
      if (backup != null) {
        if (backup.getAddress().equals(thisAddress)) {
          doTxnBackupPoll(request.txnId,value);
        }
 else {
          sendTxnBackup(backup.getAddress(),value,request.txnId);
        }
      }
    }
    long recordId=getRecordId(blCurrentTake.blockId,blCurrentTake.removeIndex);
    request.recordId=recordId;
    doFireEntryEvent(false,value,recordId);
    sendBackup(false,request.caller,null,blCurrentTake.blockId,0);
    if (!blCurrentTake.containsValidItem() && blCurrentTake.isFull()) {
      fireBlockRemoveEvent(blCurrentTake);
      blCurrentTake=null;
    }
    return value;
  }
  finally {
    boolean consumed=false;
    while (!consumed && lsScheduledOfferActions.size() > 0) {
      ScheduledOfferAction offerAction=lsScheduledOfferActions.remove(0);
      ClusterManager.get().deregisterScheduledAction(offerAction);
      if (offerAction.expired()) {
        offerAction.onExpire();
      }
 else {
        consumed=offerAction.consume();
      }
    }
  }
}

Fixed version (ground truth):
public Data poll(Request request){
  try {
    setCurrentTake();
    Data value=blCurrentTake.remove();
    if (request.txnId != -1) {
      MemberImpl backup=null;
      if (request.caller.equals(thisAddress)) {
        backup=getNextMemberAfter(thisAddress,true,1);
      }
 else {
        backup=getNextMemberAfter(request.caller,true,1);
      }
      if (backup != null) {
        if (backup.getAddress().equals(thisAddress)) {
          doTxnBackupPoll(request.txnId,value);
        }
 else {
          sendTxnBackup(backup.getAddress(),value,request.txnId);
        }
      }
    }
    request.recordId=getRecordId(blCurrentTake.blockId,blCurrentTake.removeIndex);
    doFireEntryEvent(false,value);
    sendBackup(false,request.caller,null,blCurrentTake.blockId,0);
    if (!blCurrentTake.containsValidItem() && blCurrentTake.isFull()) {
      fireBlockRemoveEvent(blCurrentTake);
      blCurrentTake=null;
    }
    return value;
  }
  finally {
    boolean consumed=false;
    while (!consumed && lsScheduledOfferActions.size() > 0) {
      ScheduledOfferAction offerAction=lsScheduledOfferActions.remove(0);
      ClusterManager.get().deregisterScheduledAction(offerAction);
      if (offerAction.expired()) {
        offerAction.onExpire();
      }
 else {
        consumed=offerAction.consume();
      }
    }
  }
}
Program: 50696
Project: 50696
Buggy source:
void doFireEntryEvent(boolean add,Data value,long recordId){
  if (mapListeners.size() == 0)   return;
  if (add) {
    fireMapEvent(mapListeners,name,EntryEvent.TYPE_ADDED,value);
  }
 else {
    fireMapEvent(mapListeners,name,EntryEvent.TYPE_REMOVED,value);
  }
}

Fixed version (ground truth):
void doFireEntryEvent(boolean add,Data value){
  if (mapListeners.size() == 0)   return;
  if (add) {
    fireMapEvent(mapListeners,name,EntryEvent.TYPE_ADDED,value);
  }
 else {
    fireMapEvent(mapListeners,name,EntryEvent.TYPE_REMOVED,value);
  }
}