nus-yam/ex-repair huggingface dataset:
Program: 50697
Project: 50697
Buggy source:
public void set(String name,int operation,Object objKey,Object objValue) throws Exception {
  this.threadId=Thread.currentThread().hashCode();
  this.name=name;
  this.operation=operation;
  if (objValue != null) {
    value=ThreadContext.get().toData(objValue);
  }
  if (objKey != null) {
    key=ThreadContext.get().toData(objKey);
  }
}

Fixed version (ground truth):
public void set(String name,int operation,Object objKey,Object objValue) throws Exception {
  this.threadId=Thread.currentThread().hashCode();
  this.name=name;
  this.operation=operation;
  if (objKey != null) {
    key=ThreadContext.get().toData(objKey);
  }
  if (objValue != null) {
    value=ThreadContext.get().toData(objValue);
  }
}
Program: 50698
Project: 50698
Buggy source:
public void syncForDead(Address deadAddress){
  Collection<Block> blocks=mapBlocks.values();
  for (  Block block : blocks) {
    if (deadAddress.equals(block.owner)) {
      MemberImpl member=getNextMemberBeforeSync(block.owner,true,1);
      block.owner=(member == null) ? thisAddress : member.getAddress();
    }
    if (block.migrationAddress != null) {
      if (deadAddress.equals(block.migrationAddress)) {
        MemberImpl member=getNextMemberBeforeSync(block.migrationAddress,true,1);
        block.migrationAddress=(member == null) ? thisAddress : member.getAddress();
      }
    }
  }
  Collection<CMap> cmaps=maps.values();
  for (  CMap map : cmaps) {
    Collection<Record> records=map.mapRecords.values();
    for (    Record record : records) {
      record.onDisconnect(deadAddress);
    }
  }
  doResetRecords();
}

Fixed version (ground truth):
public void syncForDead(Address deadAddress){
  Collection<Block> blocks=mapBlocks.values();
  for (  Block block : blocks) {
    if (deadAddress.equals(block.owner)) {
      MemberImpl member=getNextMemberBeforeSync(block.owner,true,1);
      block.owner=(member == null) ? thisAddress : member.getAddress();
    }
    if (block.migrationAddress != null) {
      if (deadAddress.equals(block.migrationAddress)) {
        MemberImpl member=getNextMemberBeforeSync(block.migrationAddress,true,1);
        block.migrationAddress=(member == null) ? thisAddress : member.getAddress();
      }
    }
  }
  Collection<CMap> cmaps=maps.values();
  for (  CMap map : cmaps) {
    Collection<Record> records=map.mapRecords.values();
    for (    Record record : records) {
      record.onDisconnect(deadAddress);
    }
  }
  doResetRecords(deadAddress);
}
Program: 50699
Project: 50699
Buggy source:
public boolean backup(Request req){
  Record record=getRecord(req.key);
  if (record != null) {
    if (req.version > record.version + 1) {
      Request reqCopy=new Request();
      reqCopy.setFromRequest(req,false);
      req.key=null;
      req.value=null;
      record.addBackupOp(new VersionedBackupOp(reqCopy));
      return true;
    }
 else     if (req.version <= record.version) {
      return false;
    }
  }
  doBackup(req);
  if (record != null) {
    record.version=req.version;
    record.runBackupOps();
  }
  return true;
}

Fixed version (ground truth):
public boolean backup(Request req){
  Record record=getRecord(req.key);
  if (record != null) {
    if (req.version > record.version + 1) {
      Request reqCopy=new Request();
      reqCopy.setFromRequest(req,true);
      req.key=null;
      req.value=null;
      record.addBackupOp(new VersionedBackupOp(reqCopy));
      return true;
    }
 else     if (req.version <= record.version) {
      return false;
    }
  }
  doBackup(req);
  if (record != null) {
    record.version=req.version;
    record.runBackupOps();
  }
  return true;
}
Program: 50700
Project: 50700
Buggy source:
Address getTarget(String name,Data key){
  int blockId=getBlockId(key);
  Block block=mapBlocks.get(blockId);
  if (block == null) {
    if (isMaster() && !isSuperClient()) {
      block=getOrCreateBlock(blockId);
      block.owner=thisAddress;
    }
 else     return null;
  }
  if (block.isMigrating())   return null;
  if (block.owner == null)   return null;
  if (block.owner.equals(thisAddress)) {
    if (block.isMigrating()) {
      if (name == null)       return block.migrationAddress;
      CMap map=getMap(name);
      Record record=map.getRecord(key);
      if (record == null)       return block.migrationAddress;
 else {
        Address recordOwner=record.getOwner();
        if (recordOwner == null)         return thisAddress;
        if ((!recordOwner.equals(thisAddress)) && (!recordOwner.equals(block.migrationAddress))) {
          record.setOwner(thisAddress);
        }
        return record.getOwner();
      }
    }
  }
 else   if (thisAddress.equals(block.migrationAddress)) {
    if (name == null)     return thisAddress;
    CMap map=getMap(name);
    Record record=map.getRecord(key);
    if (record == null)     return thisAddress;
 else     return record.getOwner();
  }
  return block.owner;
}

Fixed version (ground truth):
Address getTarget(String name,Data key){
  int blockId=getBlockId(key);
  Block block=mapBlocks.get(blockId);
  if (block == null) {
    if (isMaster() && !isSuperClient()) {
      block=getOrCreateBlock(blockId);
      block.owner=thisAddress;
    }
 else     return null;
  }
  if (block.isMigrating())   return null;
  if (block.owner == null)   return null;
  if (block.owner.equals(thisAddress)) {
    if (block.isMigrating()) {
      if (name == null)       return block.migrationAddress;
      CMap map=getMap(name);
      Record record=map.getRecord(key);
      if (record == null)       return block.migrationAddress;
 else {
        Address recordOwner=record.owner;
        if (recordOwner == null)         return thisAddress;
        if ((!recordOwner.equals(thisAddress)) && (!recordOwner.equals(block.migrationAddress))) {
          record.owner=thisAddress;
        }
        return record.owner;
      }
    }
  }
 else   if (thisAddress.equals(block.migrationAddress)) {
    if (name == null)     return thisAddress;
    CMap map=getMap(name);
    Record record=map.getRecord(key);
    if (record == null)     return thisAddress;
 else     return record.owner;
  }
  return block.owner;
}
Program: 50701
Project: 50701
Buggy source:
void doResetRecords(){
  if (isSuperClient())   return;
  final Object[] records=mapRecordsById.values().toArray();
  mapRecordsById.clear();
  Collection<CMap> cmaps=maps.values();
  for (  CMap cmap : cmaps) {
    cmap.mapRecords.clear();
  }
  for (  Object recObj : records) {
    final Record rec=(Record)recObj;
    rec.forceBackupOps();
    CMap cmap=getMap(rec.name);
    cmap.removeRecord(rec.key);
    executeLocally(new Runnable(){
      public void run(){
        MMigrate mmigrate=new MMigrate();
        mmigrate.migrate(rec);
      }
    }
);
  }
  executeLocally(new Runnable(){
    public void run(){
      Processable processCompletion=new Processable(){
        public void process(){
          doMigrationComplete(thisAddress);
          sendMigrationComplete();
          if (DEBUG) {
            printBlocks();
            logger.log(Level.FINEST,"String_Node_Str");
          }
        }
      }
;
      enqueueAndReturn(processCompletion);
    }
  }
);
}

Fixed version (ground truth):
void doResetRecords(Address deadAddress){
  if (isSuperClient())   return;
  final Object[] records=mapRecordsById.values().toArray();
  mapRecordsById.clear();
  Collection<CMap> cmaps=maps.values();
  for (  CMap cmap : cmaps) {
    cmap.mapRecords.clear();
  }
  for (  Object recObj : records) {
    final Record rec=(Record)recObj;
    CMap cmap=getMap(rec.name);
    cmap.removeRecord(rec.key);
    boolean shouldMigrate=false;
    if (thisAddress.equals(rec.owner)) {
      shouldMigrate=true;
    }
 else     if (deadAddress != null && deadAddress.equals(rec.owner)) {
      rec.forceBackupOps();
      shouldMigrate=true;
    }
    if (shouldMigrate) {
      executeLocally(new Runnable(){
        public void run(){
          MMigrate mmigrate=new MMigrate();
          mmigrate.migrate(rec);
        }
      }
);
    }
  }
  executeLocally(new Runnable(){
    public void run(){
      Processable processCompletion=new Processable(){
        public void process(){
          doMigrationComplete(thisAddress);
          sendMigrationComplete();
          if (DEBUG) {
            printBlocks();
            logger.log(Level.FINEST,"String_Node_Str");
          }
        }
      }
;
      enqueueAndReturn(processCompletion);
    }
  }
);
}
Program: 50702
Project: 50702
Buggy source:
public void addBackupOp(VersionedBackupOp bo){
  if (backupOps == null) {
    backupOps=new TreeSet<VersionedBackupOp>();
  }
  backupOps.add(bo);
  if (backupOps.size() > 5) {
    logger.log(Level.FINEST,id + "String_Node_Str" + version);
    forceBackupOps();
  }
}

Fixed version (ground truth):
public void addBackupOp(VersionedBackupOp bo){
  if (backupOps == null) {
    backupOps=new TreeSet<VersionedBackupOp>();
  }
  backupOps.add(bo);
  if (backupOps.size() > 4) {
    logger.log(Level.FINEST,id + "String_Node_Str" + version);
    forceBackupOps();
  }
}
Program: 50704
Project: 50704
Buggy source:
@Override public void run(){
  logger.log(Level.FINEST,"String_Node_Str");
  shutdown();
}

Fixed version (ground truth):
@Override public void run(){
  completelyShutdown=true;
  logger.log(Level.FINEST,"String_Node_Str");
  shutdown();
}
Program: 50705
Project: 50705
Buggy source:
public void start(){
  firstMainThread=Thread.currentThread();
  clusterImpl=new ClusterImpl();
  final boolean inited=init();
  if (!inited)   return;
  final Thread inThread=new Thread(InSelector.get(),"String_Node_Str");
  inThread.start();
  inThread.setPriority(8);
  lsThreads.add(inThread);
  final Thread outThread=new Thread(OutSelector.get(),"String_Node_Str");
  outThread.start();
  outThread.setPriority(8);
  lsThreads.add(outThread);
  final Thread clusterServiceThread=new Thread(ClusterService.get(),"String_Node_Str");
  clusterServiceThread.start();
  clusterServiceThread.setPriority(7);
  lsThreads.add(clusterServiceThread);
  if (Config.get().join.multicastConfig.enabled) {
    startMulticastService();
  }
  join();
  firstMainThread=null;
  Runtime.getRuntime().addShutdownHook(new Thread(){
    @Override public void run(){
      logger.log(Level.FINEST,"String_Node_Str");
      shutdown();
    }
  }
);
}

Fixed version (ground truth):
public void start(){
  if (completelyShutdown)   return;
  firstMainThread=Thread.currentThread();
  clusterImpl=new ClusterImpl();
  final boolean inited=init();
  if (!inited)   return;
  final Thread inThread=new Thread(InSelector.get(),"String_Node_Str");
  inThread.start();
  inThread.setPriority(8);
  lsThreads.add(inThread);
  final Thread outThread=new Thread(OutSelector.get(),"String_Node_Str");
  outThread.start();
  outThread.setPriority(8);
  lsThreads.add(outThread);
  final Thread clusterServiceThread=new Thread(ClusterService.get(),"String_Node_Str");
  clusterServiceThread.start();
  clusterServiceThread.setPriority(7);
  lsThreads.add(clusterServiceThread);
  if (Config.get().join.multicastConfig.enabled) {
    startMulticastService();
  }
  join();
  firstMainThread=null;
  if (!completelyShutdown) {
    Runtime.getRuntime().addShutdownHook(new Thread(){
      @Override public void run(){
        completelyShutdown=true;
        logger.log(Level.FINEST,"String_Node_Str");
        shutdown();
      }
    }
);
  }
}
Program: 50707
Project: 50707
Buggy source:
public final void writeUTF(final String str) throws IOException {
  final int strlen=str.length();
  int utflen=0;
  int c, count=0;
  for (int i=0; i < strlen; i++) {
    c=str.charAt(i);
    if ((c >= 0x0001) && (c <= 0x007F)) {
      utflen++;
    }
 else     if (c > 0x07FF) {
      utflen+=3;
    }
 else {
      utflen+=2;
    }
  }
  if (utflen > 65535)   throw new UTFDataFormatException("String_Node_Str" + utflen + "String_Node_Str");
  final byte[] bytearr=new byte[utflen + 2];
  bytearr[count++]=(byte)((utflen >>> 8) & 0xFF);
  bytearr[count++]=(byte)((utflen >>> 0) & 0xFF);
  int i=0;
  for (i=0; i < strlen; i++) {
    c=str.charAt(i);
    if (!((c >= 0x0001) && (c <= 0x007F)))     break;
    bytearr[count++]=(byte)c;
  }
  for (; i < strlen; i++) {
    c=str.charAt(i);
    if ((c >= 0x0001) && (c <= 0x007F)) {
      bytearr[count++]=(byte)c;
    }
 else     if (c > 0x07FF) {
      bytearr[count++]=(byte)(0xE0 | ((c >> 12) & 0x0F));
      bytearr[count++]=(byte)(0x80 | ((c >> 6) & 0x3F));
      bytearr[count++]=(byte)(0x80 | ((c >> 0) & 0x3F));
    }
 else {
      bytearr[count++]=(byte)(0xC0 | ((c >> 6) & 0x1F));
      bytearr[count++]=(byte)(0x80 | ((c >> 0) & 0x3F));
    }
  }
  write(bytearr,0,utflen + 2);
}

Fixed version (ground truth):
public final void writeUTF(final String str) throws IOException {
  final int strlen=str.length();
  int utflen=0;
  int c, count=0;
  for (int i=0; i < strlen; i++) {
    c=str.charAt(i);
    if ((c >= 0x0001) && (c <= 0x007F)) {
      utflen++;
    }
 else     if (c > 0x07FF) {
      utflen+=3;
    }
 else {
      utflen+=2;
    }
  }
  final byte[] bytearr=new byte[utflen + 4];
  bytearr[count++]=(byte)((utflen >>> 24) & 0xFF);
  bytearr[count++]=(byte)((utflen >>> 16) & 0xFF);
  bytearr[count++]=(byte)((utflen >>> 8) & 0xFF);
  bytearr[count++]=(byte)((utflen >>> 0) & 0xFF);
  int i=0;
  for (i=0; i < strlen; i++) {
    c=str.charAt(i);
    if (!((c >= 0x0001) && (c <= 0x007F)))     break;
    bytearr[count++]=(byte)c;
  }
  for (; i < strlen; i++) {
    c=str.charAt(i);
    if ((c >= 0x0001) && (c <= 0x007F)) {
      bytearr[count++]=(byte)c;
    }
 else     if (c > 0x07FF) {
      bytearr[count++]=(byte)(0xE0 | ((c >> 12) & 0x0F));
      bytearr[count++]=(byte)(0x80 | ((c >> 6) & 0x3F));
      bytearr[count++]=(byte)(0x80 | ((c >> 0) & 0x3F));
    }
 else {
      bytearr[count++]=(byte)(0xC0 | ((c >> 6) & 0x1F));
      bytearr[count++]=(byte)(0x80 | ((c >> 0) & 0x3F));
    }
  }
  write(bytearr,0,utflen + 4);
}
Program: 50709
Project: 50709
Buggy source:
Record nextOwnedRecord(String name,long recordId,int blockId){
  Record rec=null;
  while (rec == null && recordId <= maxId) {
    rec=getRecordById(recordId);
    if (rec != null) {
      if (name != null && name.equals(rec.name)) {
        if (rec.blockId == blockId) {
          if (rec.owner.equals(thisAddress)) {
            return rec;
          }
        }
      }
    }
    rec=null;
    recordId++;
  }
  return rec;
}

Fixed version (ground truth):
Record nextOwnedRecord(String name,long recordId,int blockId){
  Record rec=null;
  while (rec == null && recordId <= maxId) {
    rec=getRecordById(recordId);
    if (rec != null) {
      if (rec.valueCount() > 0) {
        if (name != null && name.equals(rec.name)) {
          if (rec.blockId == blockId) {
            if (rec.owner.equals(thisAddress)) {
              return rec;
            }
          }
        }
      }
    }
    rec=null;
    recordId++;
  }
  return rec;
}
Program: 50710
Project: 50710
Buggy source:
public boolean removeKey(Object key){
  if (key == null)   throw new NullPointerException();
  try {
    Data dataKey=ThreadContext.get().toData(key);
    return remove(dataKey) != null;
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
  return false;
}

Fixed version (ground truth):
public boolean removeKey(Object key){
  if (key == null)   throw new NullPointerException();
  ConcurrentMapManager.MRemoveItem mRemoveItem=ConcurrentMapManager.get().new MRemoveItem();
  return mRemoveItem.removeItem(name,key);
}
Program: 50711
Project: 50711
Buggy source:
public void clear(){
}

Fixed version (ground truth):
public void clear(){
  MIterator it=ConcurrentMapManager.get().new MIterator();
  it.set(name,EntrySet.TYPE_KEYS);
  while (it.hasNext()) {
    it.next();
    it.remove();
  }
}
Program: 50712
Project: 50712
Buggy source:
int offer(Request req){
  int addIndex=blCurrentPut.add(req.value);
  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);
  if (blCurrentPut.isFull()) {
    fireBlockFullEvent(blCurrentPut);
    blCurrentPut=null;
    setCurrentPut();
  }
  return addIndex;
}

Fixed version (ground truth):
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 {
    if (blCurrentPut.isFull()) {
      fireBlockFullEvent(blCurrentPut);
      blCurrentPut=null;
      setCurrentPut();
    }
  }
  return addIndex;
}
Program: 50713
Project: 50713
Buggy source:
void doFireEntryEvent(boolean add,Data value,long recordId){
  if (mapListeners.size() == 0)   return;
  if (add) {
    fireMapEvent(mapListeners,name,EntryEvent.TYPE_ADDED,value,null,recordId);
  }
 else {
    fireMapEvent(mapListeners,name,EntryEvent.TYPE_REMOVED,value,null,recordId);
  }
}

Fixed version (ground truth):
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);
  }
}
Program: 50714
Project: 50714
Buggy source:
private void joinExisting(final Address masterAddress) throws Exception {
  Connection conn=ConnectionManager.get().getOrConnect(masterAddress);
  if (conn == null)   Thread.sleep(1000);
  conn=ConnectionManager.get().getConnection(masterAddress);
  if (DEBUG) {
    logger.log(Level.FINEST,"String_Node_Str" + conn);
  }
  if (conn != null)   ClusterManager.get().sendJoinRequest(masterAddress);
}

Fixed version (ground truth):
private void joinExisting(final Address masterAddress) throws Exception {
  if (masterAddress == null)   return;
  if (masterAddress.equals(getThisAddress()))   return;
  Connection conn=ConnectionManager.get().getOrConnect(masterAddress);
  if (conn == null)   Thread.sleep(1000);
  conn=ConnectionManager.get().getConnection(masterAddress);
  if (DEBUG) {
    logger.log(Level.FINEST,"String_Node_Str" + conn);
  }
  if (conn != null)   ClusterManager.get().sendJoinRequest(masterAddress);
}
Program: 50715
Project: 50715
Buggy source:
private void joinWithMulticast(){
  masterAddress=findMaster();
  if (DEBUG)   logger.log(Level.FINEST,address + "String_Node_Str" + masterAddress);
  if (masterAddress == null || masterAddress.equals(address)) {
    ClusterManager.get().addMember(address,getLocalNodeType());
    masterAddress=address;
    clusterImpl.setMembers(ClusterManager.get().lsMembers);
    unlock();
  }
 else {
    while (!joined) {
      try {
        if (DEBUG)         logger.log(Level.FINEST,"String_Node_Str" + masterAddress);
        while (!joined()) {
          joinExisting(masterAddress);
          Thread.sleep(500);
        }
        if (masterAddress == null) {
          joinWithMulticast();
        }
 else         if (masterAddress.equals(address)) {
          setAsMaster();
        }
      }
 catch (      final Exception e) {
        e.printStackTrace();
      }
    }
  }
}

Fixed version (ground truth):
private void joinWithMulticast(){
  masterAddress=findMaster();
  if (DEBUG)   logger.log(Level.FINEST,address + "String_Node_Str" + masterAddress);
  if (masterAddress == null || masterAddress.equals(address)) {
    ClusterManager.get().addMember(address,getLocalNodeType());
    masterAddress=address;
    clusterImpl.setMembers(ClusterManager.get().lsMembers);
    unlock();
  }
 else {
    while (!joined) {
      try {
        if (DEBUG)         logger.log(Level.FINEST,"String_Node_Str" + masterAddress);
        if (masterAddress == null) {
          joinWithMulticast();
        }
 else         if (masterAddress.equals(address)) {
          setAsMaster();
        }
        joinExisting(masterAddress);
        Thread.sleep(500);
      }
 catch (      final Exception e) {
        logger.log(Level.FINEST,"String_Node_Str",e);
      }
    }
  }
}
Program: 50717
Project: 50717
Buggy source:
public void run(){
  while (running) {
    Object obj=null;
    try {
      lsBuffer.clear();
      queue.drainTo(lsBuffer);
      final int size=lsBuffer.size();
      if (size > 0) {
        for (int i=0; i < size; i++) {
          obj=lsBuffer.get(i);
          checkPeriodics();
          process(obj);
        }
        lsBuffer.clear();
      }
 else {
        obj=queue.poll(100,TimeUnit.MILLISECONDS);
        checkPeriodics();
        if (obj != null) {
          process(obj);
        }
      }
    }
 catch (    final InterruptedException e) {
      Node.get().handleInterruptedException(Thread.currentThread(),e);
    }
catch (    final Throwable e) {
      logger.log(Level.FINEST,e + "String_Node_Str" + e+ "String_Node_Str"+ obj,e);
      e.printStackTrace();
    }
  }
  lsBuffer.clear();
  queue.clear();
}

Fixed version (ground truth):
public void run(){
  while (running) {
    Object obj=null;
    try {
      lsBuffer.clear();
      queue.drainTo(lsBuffer);
      final int size=lsBuffer.size();
      if (size > 0) {
        for (int i=0; i < size; i++) {
          obj=lsBuffer.get(i);
          checkPeriodics();
          process(obj);
        }
        lsBuffer.clear();
      }
 else {
        obj=queue.poll(100,TimeUnit.MILLISECONDS);
        checkPeriodics();
        if (obj != null) {
          process(obj);
        }
      }
    }
 catch (    final InterruptedException e) {
      Node.get().handleInterruptedException(Thread.currentThread(),e);
    }
catch (    final Throwable e) {
      logger.log(Level.FINEST,e + "String_Node_Str" + e+ "String_Node_Str"+ obj,e);
      e.printStackTrace();
      System.out.println("String_Node_Str" + obj);
    }
  }
  lsBuffer.clear();
  queue.clear();
}
Program: 50718
Project: 50718
Buggy source:
public boolean backup(Request req){
  Record record=getRecord(req.key);
  if (record != null) {
    record.version=req.version;
    if (req.version > record.version + 1) {
      Request reqCopy=new Request();
      reqCopy.setFromRequest(req,false);
      req.key=null;
      req.value=null;
      record.addBackupOp(new VersionedBackupOp(reqCopy));
      return true;
    }
 else     if (req.version <= record.version) {
      return false;
    }
  }
  doBackup(req);
  if (record != null) {
    record.version=req.version;
    record.runBackupOps();
  }
  return true;
}

Fixed version (ground truth):
public boolean backup(Request req){
  Record record=getRecord(req.key);
  if (record != null) {
    if (req.version > record.version + 1) {
      Request reqCopy=new Request();
      reqCopy.setFromRequest(req,false);
      req.key=null;
      req.value=null;
      record.addBackupOp(new VersionedBackupOp(reqCopy));
      return true;
    }
 else     if (req.version <= record.version) {
      return false;
    }
  }
  doBackup(req);
  if (record != null) {
    record.version=req.version;
    record.runBackupOps();
  }
  return true;
}
Program: 50720
Project: 50720
Buggy source:
void doResetRecords(){
  if (isSuperClient())   return;
  final Object[] records=mapRecordsById.values().toArray();
  mapRecordsById.clear();
  Collection<CMap> cmaps=maps.values();
  for (  CMap cmap : cmaps) {
    cmap.mapRecords.clear();
  }
  for (  Object recObj : records) {
    final Record rec=(Record)recObj;
    CMap cmap=getMap(rec.name);
    cmap.removeRecord(rec.key);
    executeLocally(new Runnable(){
      public void run(){
        MMigrate mmigrate=new MMigrate();
        mmigrate.migrate(rec);
      }
    }
);
  }
  executeLocally(new Runnable(){
    public void run(){
      Processable processCompletion=new Processable(){
        public void process(){
          doMigrationComplete(thisAddress);
          sendMigrationComplete();
          if (DEBUG) {
            printBlocks();
            logger.log(Level.FINEST,"String_Node_Str");
          }
        }
      }
;
      enqueueAndReturn(processCompletion);
    }
  }
);
}

Fixed version (ground truth):
void doResetRecords(){
  if (isSuperClient())   return;
  final Object[] records=mapRecordsById.values().toArray();
  mapRecordsById.clear();
  Collection<CMap> cmaps=maps.values();
  for (  CMap cmap : cmaps) {
    cmap.mapRecords.clear();
  }
  for (  Object recObj : records) {
    final Record rec=(Record)recObj;
    rec.runBackupOps();
    CMap cmap=getMap(rec.name);
    cmap.removeRecord(rec.key);
    executeLocally(new Runnable(){
      public void run(){
        MMigrate mmigrate=new MMigrate();
        mmigrate.migrate(rec);
      }
    }
);
  }
  executeLocally(new Runnable(){
    public void run(){
      Processable processCompletion=new Processable(){
        public void process(){
          doMigrationComplete(thisAddress);
          sendMigrationComplete();
          if (DEBUG) {
            printBlocks();
            logger.log(Level.FINEST,"String_Node_Str");
          }
        }
      }
;
      enqueueAndReturn(processCompletion);
    }
  }
);
}
Program: 50721
Project: 50721
Buggy source:
final void doPut(Request request){
  if (request.operation == OP_CMAP_MIGRATE_RECORD) {
    doMigrate(request);
    return;
  }
  if (request.operation == OP_CMAP_PUT_MULTI) {
    doPutMulti(request);
    return;
  }
  if (request.operation == OP_CMAP_PUT_IF_ABSENT) {
    Record record=recordExist(request);
    if (record != null && record.getValue() != null) {
      Data valueCopy=ThreadContext.get().hardCopy(record.getValue());
      request.response=valueCopy;
      return;
    }
  }
 else   if (request.operation == OP_CMAP_REPLACE_IF_NOT_NULL) {
    Record record=recordExist(request);
    if (record == null || record.getValue() == null) {
      request.response=null;
      return;
    }
  }
  if (!testLock(request)) {
    if (request.hasEnoughTimeToSchedule()) {
      Record record=ensureRecord(request);
      request.scheduled=true;
      final Request reqScheduled=(request.local) ? request : request.hardCopy();
      record.addScheduledAction(new ScheduledAction(request){
        @Override public boolean consume(){
          CMap cmap=getMap(reqScheduled.name);
          Data oldValue=cmap.put(reqScheduled);
          reqScheduled.response=oldValue;
          reqScheduled.key=null;
          reqScheduled.value=null;
          returnScheduledAsSuccess(reqScheduled);
          return true;
        }
      }
);
    }
 else {
      request.response=null;
    }
  }
 else {
    CMap cmap=getMap(request.name);
    Data oldValue=cmap.put(request);
    request.response=oldValue;
  }
}

Fixed version (ground truth):
final void doPut(Request request){
  if (request.operation == OP_CMAP_PUT_MULTI) {
    doPutMulti(request);
    return;
  }
  if (request.operation == OP_CMAP_PUT_IF_ABSENT) {
    Record record=recordExist(request);
    if (record != null && record.getValue() != null) {
      Data valueCopy=ThreadContext.get().hardCopy(record.getValue());
      request.response=valueCopy;
      return;
    }
  }
 else   if (request.operation == OP_CMAP_REPLACE_IF_NOT_NULL) {
    Record record=recordExist(request);
    if (record == null || record.getValue() == null) {
      request.response=null;
      return;
    }
  }
  if (!testLock(request)) {
    if (request.hasEnoughTimeToSchedule()) {
      Record record=ensureRecord(request);
      request.scheduled=true;
      final Request reqScheduled=(request.local) ? request : request.hardCopy();
      record.addScheduledAction(new ScheduledAction(request){
        @Override public boolean consume(){
          CMap cmap=getMap(reqScheduled.name);
          Data oldValue=cmap.put(reqScheduled);
          reqScheduled.response=oldValue;
          reqScheduled.key=null;
          reqScheduled.value=null;
          returnScheduledAsSuccess(reqScheduled);
          return true;
        }
      }
);
    }
 else {
      request.response=null;
    }
  }
 else {
    CMap cmap=getMap(request.name);
    Data oldValue=cmap.put(request);
    request.response=oldValue;
  }
}
Program: 50722
Project: 50722
Buggy source:
public RequestWrapper(final AppContext context,final HttpServletRequest req,final ResponseWrapper res){
  super(req);
  this.res=res;
  this.context=context;
  this.original=req;
  this.original.setAttribute(HAZELCAST_REQUEST,this);
  creationTime=System.nanoTime();
  final Cookie[] cookies=req.getCookies();
  if (cookies != null) {
    for (int i=0; i < cookies.length; i++) {
      final Cookie cookie=cookies[i];
      if (cookie.getName().equals("String_Node_Str")) {
        requestedSessionId=cookie.getValue();
        requestedSessionIdFromCookie=true;
        if (DEBUG) {
          log("String_Node_Str" + requestedSessionId);
        }
      }
    }
  }
  if (requestedSessionId == null) {
    if (DEBUG) {
      logger.log(Level.FINEST,"String_Node_Str" + getContextPath());
      logger.log(Level.FINEST,"String_Node_Str" + getQueryString());
      logger.log(Level.FINEST,"String_Node_Str" + getRequestURI());
      logger.log(Level.FINEST,"String_Node_Str" + getRequestURL());
    }
    requestedSessionId=res.extractSessionId(getRequestURL().toString());
    if (DEBUG) {
      log("String_Node_Str" + requestedSessionId);
    }
    if (requestedSessionId != null) {
      requestedSessionIdFromURL=true;
    }
  }
}

Fixed version (ground truth):
public RequestWrapper(final AppContext context,final HttpServletRequest req,final ResponseWrapper res){
  super(req);
  this.res=res;
  this.context=context;
  this.original=req;
  this.original.setAttribute(HAZELCAST_REQUEST,this);
  creationTime=System.nanoTime();
  final Cookie[] cookies=req.getCookies();
  if (cookies != null) {
    for (    final Cookie cookie : cookies) {
      if (cookie.getName().equalsIgnoreCase("String_Node_Str")) {
        requestedSessionId=cookie.getValue();
        requestedSessionIdFromCookie=true;
        if (DEBUG) {
          log("String_Node_Str" + requestedSessionId);
        }
      }
    }
  }
  if (requestedSessionId == null) {
    if (DEBUG) {
      logger.log(Level.FINEST,"String_Node_Str" + getContextPath());
      logger.log(Level.FINEST,"String_Node_Str" + getQueryString());
      logger.log(Level.FINEST,"String_Node_Str" + getRequestURI());
      logger.log(Level.FINEST,"String_Node_Str" + getRequestURL());
    }
    requestedSessionId=res.extractSessionId(getRequestURL().toString());
    if (DEBUG) {
      log("String_Node_Str" + requestedSessionId);
    }
    if (requestedSessionId != null) {
      requestedSessionIdFromURL=true;
    }
  }
}
Program: 50724
Project: 50724
Buggy source:
public void setMaxInactiveInterval(int maxInactiveSeconds){
  if (DEBUG)   log("String_Node_Str" + maxInactiveSeconds);
  if (maxInactiveSeconds < 0)   maxInactiveSeconds=-1;
  maxInactiveInterval.set(maxInactiveSeconds * 1000);
}

Fixed version (ground truth):
public void setMaxInactiveInterval(int maxInactiveSeconds){
  if (DEBUG)   log("String_Node_Str" + maxInactiveSeconds);
  if (maxInactiveSeconds < 0)   maxInactiveSeconds=-1;
  maxInactiveInterval.set(maxInactiveSeconds * 1000L);
}
Program: 50725
Project: 50725
Buggy source:
public boolean hasNext(){
  if (next != null) {
    if (next.copyCount-- <= 0) {
      next=null;
    }
  }
  while (next == null) {
    boolean canRead=setNextBlock();
    if (!canRead)     return false;
    next=read.read(name,currentBlockId,currentIndex);
    if (next == null) {
      currentIndex=-1;
    }
 else {
      currentIndex=read.lastReadRecordId;
      currentIndex++;
    }
  }
  hasNextCalled=true;
  return true;
}

Fixed version (ground truth):
public boolean hasNext(){
  if (next != null) {
    if (next.copyCount-- <= 0) {
      next=null;
    }
  }
  if (lsEntries != null) {
    if (lsEntries.size() > 0) {
      next=lsEntries.remove(0);
    }
 else {
      next=null;
      lsEntries=null;
    }
  }
  while (next == null) {
    boolean canRead=setNextBlock();
    if (!canRead)     return false;
    next=read.read(name,currentBlockId,currentIndex);
    if (next == null) {
      currentIndex=-1;
    }
 else {
      currentIndex=read.lastReadRecordId;
      currentIndex++;
      TransactionImpl txn=ThreadContext.get().txn;
      if (txn != null) {
        Object key=next.getKey();
        if (txn.has(name,key)) {
          next=null;
        }
      }
    }
  }
  hasNextCalled=true;
  return true;
}
Program: 50726
Project: 50726
Buggy source:
public void set(String name,int type){
  this.name=name;
  this.type=type;
}

Fixed version (ground truth):
public void set(String name,int type){
  this.name=name;
  this.type=type;
  TransactionImpl txn=ThreadContext.get().txn;
  if (txn != null) {
    lsEntries=txn.entries(name);
  }
}
Program: 50727
Project: 50727
Buggy source:
public EventTask(final int eventType,final String name,final Data dataKey,final Data dataValue,final long recordId){
  super(name);
  this.eventType=eventType;
  this.name=name;
  this.dataValue=dataValue;
  this.dataKey=dataKey;
  this.recordId=recordId;
}

Fixed version (ground truth):
public EventTask(final int eventType,final String name,final Data dataKey,final Data dataValue,final long recordId){
  super(name);
  this.eventType=eventType;
  this.dataValue=dataValue;
  this.dataKey=dataKey;
  this.recordId=recordId;
}
Program: 50728
Project: 50728
Buggy source:
void callListeners(EventTask event){
  String name=event.name;
  for (  ListenerItem listenerItem : lsListeners) {
    if (listenerItem.name.equals(name)) {
      if (listenerItem.key == null) {
        callListener(listenerItem,event);
      }
 else       if (event.getKey().equals(listenerItem.key)) {
        callListener(listenerItem,event);
      }
    }
  }
}

Fixed version (ground truth):
void callListeners(EventTask event){
  String name=event.getName();
  for (  ListenerItem listenerItem : lsListeners) {
    if (listenerItem.name.equals(name)) {
      if (listenerItem.key == null) {
        callListener(listenerItem,event);
      }
 else       if (event.getKey().equals(listenerItem.key)) {
        callListener(listenerItem,event);
      }
    }
  }
}
Program: 50729
Project: 50729
Buggy source:
public void returnScheduledAsSuccess(final Request request){
  if (request.local) {
    final TargetAwareOp mop=(TargetAwareOp)request.attachment;
    mop.setResult(request.response);
  }
 else {
    final Invocation inv=request.toInvocation();
    final Object result=request.response;
    if (result != null) {
      if (result instanceof Data) {
        final Data oldValue=(Data)result;
        if (oldValue != null && oldValue.size() > 0) {
          doSet(oldValue,inv.value);
        }
      }
    }
    sendResponse(inv,request.caller);
  }
}

Fixed version (ground truth):
public void returnScheduledAsSuccess(final Request request){
  if (request.local) {
    final TargetAwareOp mop=(TargetAwareOp)request.attachment;
    mop.setResult(request.response);
  }
 else {
    final Invocation inv=request.toInvocation();
    final Object result=request.response;
    if (result != null) {
      if (result instanceof Data) {
        final Data data=(Data)result;
        if (data.size() > 0) {
          doSet(data,inv.value);
        }
      }
    }
    sendResponse(inv,request.caller);
  }
}
Program: 50730
Project: 50730
Buggy source:
public Object getValue(){
  if (value == null) {
    if (valueData != null) {
      value=ThreadContext.get().toObject(valueData);
    }
  }
  return value;
}

Fixed version (ground truth):
public Object getValue(){
  if (value == null) {
    if (valueData != null) {
      value=ThreadContext.get().toObject(valueData);
    }
 else {
      return getKey();
    }
  }
  return value;
}
Program: 50731
Project: 50731
Buggy source:
public void run(){
  while (running) {
    Object obj=null;
    try {
      lsBuffer.clear();
      queue.drainTo(lsBuffer);
      final int size=lsBuffer.size();
      if (size > 0) {
        for (int i=0; i < size; i++) {
          obj=lsBuffer.get(i);
          checkPeriodics();
          process(obj);
        }
        lsBuffer.clear();
      }
 else {
        obj=queue.poll(100,TimeUnit.MILLISECONDS);
        checkPeriodics();
        if (obj != null) {
          process(obj);
        }
      }
    }
 catch (    final InterruptedException e) {
      Node.get().handleInterruptedException(Thread.currentThread(),e);
    }
catch (    final Throwable e) {
      if (DEBUG) {
        logger.log(Level.FINEST,e + "String_Node_Str" + e+ "String_Node_Str"+ obj);
        logger.log(Level.FINEST,e.getMessage(),e);
      }
    }
  }
  lsBuffer.clear();
  queue.clear();
}

Fixed version (ground truth):
public void run(){
  while (running) {
    Object obj=null;
    try {
      lsBuffer.clear();
      queue.drainTo(lsBuffer);
      final int size=lsBuffer.size();
      if (size > 0) {
        for (int i=0; i < size; i++) {
          obj=lsBuffer.get(i);
          checkPeriodics();
          process(obj);
        }
        lsBuffer.clear();
      }
 else {
        obj=queue.poll(100,TimeUnit.MILLISECONDS);
        checkPeriodics();
        if (obj != null) {
          process(obj);
        }
      }
    }
 catch (    final InterruptedException e) {
      Node.get().handleInterruptedException(Thread.currentThread(),e);
    }
catch (    final Throwable e) {
      logger.log(Level.FINEST,e + "String_Node_Str" + e+ "String_Node_Str"+ obj,e);
    }
  }
  lsBuffer.clear();
  queue.clear();
}
Program: 50732
Project: 50732
Buggy source:
public void run3(){
  Object obj=null;
  while (running) {
    try {
      obj=queue.take();
      process(obj);
    }
 catch (    final InterruptedException e) {
      Node.get().handleInterruptedException(Thread.currentThread(),e);
    }
catch (    final Exception e) {
      if (DEBUG) {
        logger.log(Level.FINEST,e + "String_Node_Str" + e.getMessage()+ "String_Node_Str"+ obj);
      }
      e.printStackTrace();
    }
  }
}

Fixed version (ground truth):
public void run3(){
  Object obj=null;
  while (running) {
    try {
      obj=queue.take();
      process(obj);
    }
 catch (    final InterruptedException e) {
      Node.get().handleInterruptedException(Thread.currentThread(),e);
    }
catch (    final Exception e) {
      logger.log(Level.FINEST,e + "String_Node_Str" + e.getMessage()+ "String_Node_Str"+ obj,e);
    }
  }
}
Program: 50733
Project: 50733
Buggy source:
void consumeResponse(Invocation inv){
  complete(true);
  inv.returnToContainer();
}

Fixed version (ground truth):
@Override void consumeResponse(Invocation inv){
  complete(true);
  inv.returnToContainer();
}
Program: 50734
Project: 50734
Buggy source:
void doRemoveAddress(Address deadAddress){
  if (DEBUG) {
    log("String_Node_Str" + deadAddress);
  }
  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()) {
    if (setJoins.contains(deadAddress)) {
      setJoins.remove(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 (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,0));
  }
  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);
}
Program: 50735
Project: 50735
Buggy source:
private void handleJoinRequest(JoinRequest joinRequest){
  if (getMember(joinRequest.address) != null)   return;
  if (DEBUG) {
  }
  Connection conn=joinRequest.getConnection();
  if (!Config.get().join.multicastConfig.enabled) {
    if (Node.get().getMasterAddress() != null && !isMaster()) {
      sendProcessableTo(new Master(Node.get().getMasterAddress()),conn);
    }
  }
  if (isMaster()) {
    Address newAddress=joinRequest.address;
    MemberInfo newMemberInfo=new MemberInfo(newAddress,joinRequest.nodeType);
    if (!joinInProgress) {
      if (setJoins.add(newMemberInfo)) {
        sendProcessableTo(new Master(Node.get().getMasterAddress()),conn);
        timeToStartJoin=System.currentTimeMillis() + waitTimeBeforeJoin;
      }
 else {
        if (System.currentTimeMillis() > timeToStartJoin) {
          startJoin();
        }
      }
    }
  }
}

Fixed version (ground truth):
private void handleJoinRequest(JoinRequest joinRequest){
  if (getMember(joinRequest.address) != null)   return;
  if (DEBUG) {
  }
  Connection conn=joinRequest.getConnection();
  if (!Config.get().join.multicastConfig.enabled) {
    if (Node.get().getMasterAddress() != null && !isMaster()) {
      sendProcessableTo(new Master(Node.get().getMasterAddress()),conn);
    }
  }
  if (isMaster()) {
    Address newAddress=joinRequest.address;
    if (!joinInProgress) {
      MemberInfo newMemberInfo=new MemberInfo(newAddress,joinRequest.nodeType);
      if (setJoins.add(newMemberInfo)) {
        sendProcessableTo(new Master(Node.get().getMasterAddress()),conn);
        timeToStartJoin=System.currentTimeMillis() + waitTimeBeforeJoin;
      }
 else {
        if (System.currentTimeMillis() > timeToStartJoin) {
          startJoin();
        }
      }
    }
  }
}
Program: 50736
Project: 50736
Buggy source:
public void onDisconnect(Address deadAddress){
}

Fixed version (ground truth):
@Override public void onDisconnect(Address deadAddress){
}
Program: 50737
Project: 50737
Buggy source:
public void doLocalOp(){
  arp.process();
  setResult(Boolean.TRUE);
}

Fixed version (ground truth):
@Override public void doLocalOp(){
  arp.process();
  setResult(Boolean.TRUE);
}
Program: 50738
Project: 50738
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);
  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){
  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;
}
Program: 50739
Project: 50739
Buggy source:
int offer(Request req){
  int addIndex=blCurrentPut.add(req.value);
  long recordId=getRecordId(blCurrentPut.blockId,addIndex);
  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);
  if (blCurrentPut.isFull()) {
    fireBlockFullEvent(blCurrentPut);
    blCurrentPut=null;
    setCurrentPut();
  }
  return addIndex;
}

Fixed version (ground truth):
int offer(Request req){
  int addIndex=blCurrentPut.add(req.value);
  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);
  if (blCurrentPut.isFull()) {
    fireBlockFullEvent(blCurrentPut);
    blCurrentPut=null;
    setCurrentPut();
  }
  return addIndex;
}