nus-yam/ex-repair huggingface dataset:
Program: 60811
Project: 60811
Buggy source:
public boolean compact(CompactionContext compaction,HStore store,ThroughputController throughputController,User user) throws IOException {
}

Fixed version (ground truth):
/** 
 * We are trying to remove / relax the region read lock for compaction. Let's see what are the potential race conditions among the operations (user scan, region split, region close and region bulk load). user scan ---> region read lock region split --> region close first --> region write lock region close --> region write lock region bulk load --> region write lock read lock is compatible with read lock. ---> no problem with user scan/read region bulk load does not cause problem for compaction (no consistency problem, store lock will help the store file accounting). They can run almost concurrently at the region level. The only remaining race condition is between the region close and compaction. So we will evaluate, below, how region close intervenes with compaction if compaction does not acquire region read lock. Here are the steps for compaction: 1. obtain list of StoreFile's 2. create StoreFileScanner's based on list from #1 3. perform compaction and save resulting files under tmp dir 4. swap in compacted files #1 is guarded by store lock. This patch does not change this --> no worse or better For #2, we obtain smallest read point (for region) across all the Scanners (for both default compactor and stripe compactor). The read points are for user scans. Region keeps the read points for all currently open user scanners. Compaction needs to know the smallest read point so that during re-write of the hfiles, it can remove the mvcc points for the cells if their mvccs are older than the smallest since they are not needed anymore. This will not conflict with compaction. For #3, it can be performed in parallel to other operations. For #4 bulk load and compaction don't conflict with each other on the region level (for multi-family atomicy). Region close and compaction are guarded pretty well by the 'writestate'. In HRegion#doClose(), we have : synchronized (writestate) { // Disable compacting and flushing by background threads for this // region. canFlush = !writestate.readOnly; writestate.writesEnabled = false; LOG.debug("Closing " + this + ": disabling compactions & flushes"); waitForFlushesAndCompactions(); } waitForFlushesAndCompactions() would wait for writestate.compacting to come down to 0. and in HRegion.compact() try { synchronized (writestate) { if (writestate.writesEnabled) { wasStateSet = true; ++writestate.compacting; } else { String msg = "NOT compacting region " + this + ". Writes disabled."; LOG.info(msg); status.abort(msg); return false; } } Also in compactor.performCompaction(): check periodically to see if a system stop is requested if (closeCheckInterval > 0) { bytesWritten += len; if (bytesWritten > closeCheckInterval) { bytesWritten = 0; if (!store.areWritesEnabled()) { progress.cancel(); return false; } } }
 */
public boolean compact(CompactionContext compaction,HStore store,ThroughputController throughputController,User user) throws IOException {
}
Program: 60812
Project: 60812
Buggy source:
private void assertDisallow(Table table,TableAction action) throws IOException {
  try {
    action.call(table);
  }
 catch (  DoNotRetryIOException|RetriesExhaustedException e) {
    assertThat(e.getMessage(),containsString("String_Node_Str"));
  }
}

Fixed version (ground truth):
private void assertDisallow(Table table,TableAction action) throws IOException {
  try {
    action.call(table);
    fail("String_Node_Str");
  }
 catch (  DoNotRetryIOException|RetriesExhaustedException e) {
    assertThat(e.getMessage(),containsString("String_Node_Str"));
  }
}
Program: 60813
Project: 60813
Buggy source:
private static void waitUntilZnodeAvailable(int replicaId) throws Exception {
  String znode=util.getZooKeeperWatcher().znodePaths.getZNodeForReplica(replicaId);
  int i=0;
  while (i < 1000) {
    if (ZKUtil.checkExists(util.getZooKeeperWatcher(),znode) == -1) {
      Thread.sleep(100);
      i++;
    }
 else     break;
  }
  if (i == 1000)   throw new IOException("String_Node_Str" + replicaId + "String_Node_Str");
}

Fixed version (ground truth):
private static void waitUntilZnodeAvailable(int replicaId) throws Exception {
  String znode=util.getZooKeeperWatcher().getZNodePaths().getZNodeForReplica(replicaId);
  int i=0;
  while (i < 1000) {
    if (ZKUtil.checkExists(util.getZooKeeperWatcher(),znode) == -1) {
      Thread.sleep(100);
      i++;
    }
 else     break;
  }
  if (i == 1000)   throw new IOException("String_Node_Str" + replicaId + "String_Node_Str");
}
Program: 60814
Project: 60814
Buggy source:
private void testZNodeACLs() throws IOException, KeeperException, InterruptedException {
  ZKWatcher watcher=new ZKWatcher(conf,"String_Node_Str",null);
  RecoverableZooKeeper zk=ZKUtil.connect(this.conf,watcher);
  String baseZNode=watcher.znodePaths.baseZNode;
  LOG.info("String_Node_Str");
  LOG.info("String_Node_Str");
  LOG.info("String_Node_Str" + baseZNode);
  LOG.info("String_Node_Str");
  LOG.info("String_Node_Str");
  checkZnodePermsRecursive(watcher,zk,baseZNode);
  LOG.info("String_Node_Str");
}

Fixed version (ground truth):
private void testZNodeACLs() throws IOException, KeeperException, InterruptedException {
  ZKWatcher watcher=new ZKWatcher(conf,"String_Node_Str",null);
  RecoverableZooKeeper zk=ZKUtil.connect(this.conf,watcher);
  String baseZNode=watcher.getZNodePaths().baseZNode;
  LOG.info("String_Node_Str");
  LOG.info("String_Node_Str");
  LOG.info("String_Node_Str" + baseZNode);
  LOG.info("String_Node_Str");
  LOG.info("String_Node_Str");
  checkZnodePermsRecursive(watcher,zk,baseZNode);
  LOG.info("String_Node_Str");
}
Program: 60815
Project: 60815
Buggy source:
private void checkZnodePermsRecursive(ZKWatcher watcher,RecoverableZooKeeper zk,String znode) throws KeeperException, InterruptedException {
  boolean expectedWorldReadable=watcher.znodePaths.isClientReadable(znode);
  assertZnodePerms(zk,znode,expectedWorldReadable);
  try {
    List<String> children=zk.getChildren(znode,false);
    for (    String child : children) {
      checkZnodePermsRecursive(watcher,zk,ZNodePaths.joinZNode(znode,child));
    }
  }
 catch (  KeeperException ke) {
    if (ke.code() != Code.NOAUTH && ke.code() != Code.NONODE) {
      throw ke;
    }
  }
}

Fixed version (ground truth):
private void checkZnodePermsRecursive(ZKWatcher watcher,RecoverableZooKeeper zk,String znode) throws KeeperException, InterruptedException {
  boolean expectedWorldReadable=watcher.getZNodePaths().isClientReadable(znode);
  assertZnodePerms(zk,znode,expectedWorldReadable);
  try {
    List<String> children=zk.getChildren(znode,false);
    for (    String child : children) {
      checkZnodePermsRecursive(watcher,zk,ZNodePaths.joinZNode(znode,child));
    }
  }
 catch (  KeeperException ke) {
    if (ke.code() != Code.NOAUTH && ke.code() != Code.NONODE) {
      throw ke;
    }
  }
}
Program: 60816
Project: 60816
Buggy source:
private boolean refreshListIfRightPath(String path){
  if (!path.startsWith(this.watcher.znodePaths.rsZNode)) {
    return false;
  }
  return refreshOtherRegionServersList(true);
}

Fixed version (ground truth):
private boolean refreshListIfRightPath(String path){
  if (!path.startsWith(this.watcher.getZNodePaths().rsZNode)) {
    return false;
  }
  return refreshOtherRegionServersList(true);
}
Program: 60817
Project: 60817
Buggy source:
/** 
 * Get a list of all the other region servers in this cluster and set a watch
 * @return a list of server nanes
 */
private List<String> getRegisteredRegionServers(boolean watch){
  List<String> result=null;
  try {
    if (watch) {
      result=ZKUtil.listChildrenAndWatchThem(this.zookeeper,this.zookeeper.znodePaths.rsZNode);
    }
 else {
      result=ZKUtil.listChildrenNoWatch(this.zookeeper,this.zookeeper.znodePaths.rsZNode);
    }
  }
 catch (  KeeperException e) {
    this.abortable.abort("String_Node_Str",e);
  }
  return result;
}

Fixed version (ground truth):
/** 
 * Get a list of all the other region servers in this cluster and set a watch
 * @return a list of server nanes
 */
private List<String> getRegisteredRegionServers(boolean watch){
  List<String> result=null;
  try {
    if (watch) {
      result=ZKUtil.listChildrenAndWatchThem(this.zookeeper,this.zookeeper.getZNodePaths().rsZNode);
    }
 else {
      result=ZKUtil.listChildrenNoWatch(this.zookeeper,this.zookeeper.getZNodePaths().rsZNode);
    }
  }
 catch (  KeeperException e) {
    this.abortable.abort("String_Node_Str",e);
  }
  return result;
}
Program: 60818
Project: 60818
Buggy source:
protected ZKReplicationStorageBase(ZKWatcher zookeeper,Configuration conf){
  this.zookeeper=zookeeper;
  this.conf=conf;
  this.replicationZNode=ZNodePaths.joinZNode(this.zookeeper.znodePaths.baseZNode,conf.get(REPLICATION_ZNODE,REPLICATION_ZNODE_DEFAULT));
}

Fixed version (ground truth):
protected ZKReplicationStorageBase(ZKWatcher zookeeper,Configuration conf){
  this.zookeeper=zookeeper;
  this.conf=conf;
  this.replicationZNode=ZNodePaths.joinZNode(this.zookeeper.getZNodePaths().baseZNode,conf.get(REPLICATION_ZNODE,REPLICATION_ZNODE_DEFAULT));
}
Program: 60819
Project: 60819
Buggy source:
private static String initPeerClusterState(String baseZKNode) throws IOException, KeeperException {
  Configuration testConf=new Configuration(conf);
  testConf.set(HConstants.ZOOKEEPER_ZNODE_PARENT,baseZKNode);
  ZKWatcher zkw1=new ZKWatcher(testConf,"String_Node_Str",null);
  String fakeRs=ZNodePaths.joinZNode(zkw1.znodePaths.rsZNode,"String_Node_Str");
  ZKUtil.createWithParents(zkw1,fakeRs);
  ZKClusterId.setClusterId(zkw1,new ClusterId());
  return ZKConfig.getZooKeeperClusterKey(testConf);
}

Fixed version (ground truth):
private static String initPeerClusterState(String baseZKNode) throws IOException, KeeperException {
  Configuration testConf=new Configuration(conf);
  testConf.set(HConstants.ZOOKEEPER_ZNODE_PARENT,baseZKNode);
  ZKWatcher zkw1=new ZKWatcher(testConf,"String_Node_Str",null);
  String fakeRs=ZNodePaths.joinZNode(zkw1.getZNodePaths().rsZNode,"String_Node_Str");
  ZKUtil.createWithParents(zkw1,fakeRs);
  ZKClusterId.setClusterId(zkw1,new ClusterId());
  return ZKConfig.getZooKeeperClusterKey(testConf);
}
Program: 60820
Project: 60820
Buggy source:
@BeforeClass public static void setUpBeforeClass() throws Exception {
  utility=new HBaseZKTestingUtility();
  utility.startMiniZKCluster();
  conf=utility.getConfiguration();
  conf.setBoolean(HConstants.REPLICATION_BULKLOAD_ENABLE_KEY,true);
  zkw=utility.getZooKeeperWatcher();
  String replicationZNodeName=conf.get("String_Node_Str","String_Node_Str");
  replicationZNode=ZNodePaths.joinZNode(zkw.znodePaths.baseZNode,replicationZNodeName);
  KEY_ONE=initPeerClusterState("String_Node_Str");
  KEY_TWO=initPeerClusterState("String_Node_Str");
}

Fixed version (ground truth):
@BeforeClass public static void setUpBeforeClass() throws Exception {
  utility=new HBaseZKTestingUtility();
  utility.startMiniZKCluster();
  conf=utility.getConfiguration();
  conf.setBoolean(HConstants.REPLICATION_BULKLOAD_ENABLE_KEY,true);
  zkw=utility.getZooKeeperWatcher();
  String replicationZNodeName=conf.get("String_Node_Str","String_Node_Str");
  replicationZNode=ZNodePaths.joinZNode(zkw.getZNodePaths().baseZNode,replicationZNodeName);
  KEY_ONE=initPeerClusterState("String_Node_Str");
  KEY_TWO=initPeerClusterState("String_Node_Str");
}
Program: 60822
Project: 60822
Buggy source:
List<RSGroupInfo> retrieveGroupListFromZookeeper() throws IOException {
  String groupBasePath=ZNodePaths.joinZNode(watcher.znodePaths.baseZNode,rsGroupZNode);
  List<RSGroupInfo> RSGroupInfoList=Lists.newArrayList();
  try {
    if (ZKUtil.checkExists(watcher,groupBasePath) != -1) {
      List<String> children=ZKUtil.listChildrenAndWatchForNewChildren(watcher,groupBasePath);
      if (children == null) {
        return RSGroupInfoList;
      }
      for (      String znode : children) {
        byte[] data=ZKUtil.getData(watcher,ZNodePaths.joinZNode(groupBasePath,znode));
        if (data.length > 0) {
          ProtobufUtil.expectPBMagicPrefix(data);
          ByteArrayInputStream bis=new ByteArrayInputStream(data,ProtobufUtil.lengthOfPBMagic(),data.length);
          RSGroupInfoList.add(RSGroupProtobufUtil.toGroupInfo(RSGroupProtos.RSGroupInfo.parseFrom(bis)));
        }
      }
      LOG.debug("String_Node_Str" + RSGroupInfoList.size());
    }
  }
 catch (  KeeperException|DeserializationException|InterruptedException e) {
    throw new IOException("String_Node_Str",e);
  }
  return RSGroupInfoList;
}

Fixed version (ground truth):
List<RSGroupInfo> retrieveGroupListFromZookeeper() throws IOException {
  String groupBasePath=ZNodePaths.joinZNode(watcher.getZNodePaths().baseZNode,rsGroupZNode);
  List<RSGroupInfo> RSGroupInfoList=Lists.newArrayList();
  try {
    if (ZKUtil.checkExists(watcher,groupBasePath) != -1) {
      List<String> children=ZKUtil.listChildrenAndWatchForNewChildren(watcher,groupBasePath);
      if (children == null) {
        return RSGroupInfoList;
      }
      for (      String znode : children) {
        byte[] data=ZKUtil.getData(watcher,ZNodePaths.joinZNode(groupBasePath,znode));
        if (data.length > 0) {
          ProtobufUtil.expectPBMagicPrefix(data);
          ByteArrayInputStream bis=new ByteArrayInputStream(data,ProtobufUtil.lengthOfPBMagic(),data.length);
          RSGroupInfoList.add(RSGroupProtobufUtil.toGroupInfo(RSGroupProtos.RSGroupInfo.parseFrom(bis)));
        }
      }
      LOG.debug("String_Node_Str" + RSGroupInfoList.size());
    }
  }
 catch (  KeeperException|DeserializationException|InterruptedException e) {
    throw new IOException("String_Node_Str",e);
  }
  return RSGroupInfoList;
}
Program: 60823
Project: 60823
Buggy source:
private List<ServerName> getOnlineRS() throws IOException {
  if (masterServices != null) {
    return masterServices.getServerManager().getOnlineServersList();
  }
  LOG.debug("String_Node_Str");
  List<ServerName> servers=new LinkedList<>();
  try {
    for (    String el : ZKUtil.listChildrenNoWatch(watcher,watcher.znodePaths.rsZNode)) {
      servers.add(ServerName.parseServerName(el));
    }
  }
 catch (  KeeperException e) {
    throw new IOException("String_Node_Str",e);
  }
  return servers;
}

Fixed version (ground truth):
private List<ServerName> getOnlineRS() throws IOException {
  if (masterServices != null) {
    return masterServices.getServerManager().getOnlineServersList();
  }
  LOG.debug("String_Node_Str");
  List<ServerName> servers=new LinkedList<>();
  try {
    for (    String el : ZKUtil.listChildrenNoWatch(watcher,watcher.getZNodePaths().rsZNode)) {
      servers.add(ServerName.parseServerName(el));
    }
  }
 catch (  KeeperException e) {
    throw new IOException("String_Node_Str",e);
  }
  return servers;
}
Program: 60824
Project: 60824
Buggy source:
public void verify() throws IOException {
  Map<String,RSGroupInfo> groupMap=Maps.newHashMap();
  Set<RSGroupInfo> zList=Sets.newHashSet();
  for (  Result result : table.getScanner(new Scan())) {
    RSGroupProtos.RSGroupInfo proto=RSGroupProtos.RSGroupInfo.parseFrom(result.getValue(RSGroupInfoManager.META_FAMILY_BYTES,RSGroupInfoManager.META_QUALIFIER_BYTES));
    groupMap.put(proto.getName(),RSGroupProtobufUtil.toGroupInfo(proto));
  }
  Assert.assertEquals(Sets.newHashSet(groupMap.values()),Sets.newHashSet(wrapped.listRSGroups()));
  try {
    String groupBasePath=ZNodePaths.joinZNode(zkw.znodePaths.baseZNode,"String_Node_Str");
    for (    String znode : ZKUtil.listChildrenNoWatch(zkw,groupBasePath)) {
      byte[] data=ZKUtil.getData(zkw,ZNodePaths.joinZNode(groupBasePath,znode));
      if (data.length > 0) {
        ProtobufUtil.expectPBMagicPrefix(data);
        ByteArrayInputStream bis=new ByteArrayInputStream(data,ProtobufUtil.lengthOfPBMagic(),data.length);
        zList.add(RSGroupProtobufUtil.toGroupInfo(RSGroupProtos.RSGroupInfo.parseFrom(bis)));
      }
    }
    Assert.assertEquals(zList.size(),groupMap.size());
    for (    RSGroupInfo RSGroupInfo : zList) {
      Assert.assertTrue(groupMap.get(RSGroupInfo.getName()).equals(RSGroupInfo));
    }
  }
 catch (  KeeperException e) {
    throw new IOException("String_Node_Str",e);
  }
catch (  DeserializationException e) {
    throw new IOException("String_Node_Str",e);
  }
catch (  InterruptedException e) {
    throw new IOException("String_Node_Str",e);
  }
}

Fixed version (ground truth):
public void verify() throws IOException {
  Map<String,RSGroupInfo> groupMap=Maps.newHashMap();
  Set<RSGroupInfo> zList=Sets.newHashSet();
  for (  Result result : table.getScanner(new Scan())) {
    RSGroupProtos.RSGroupInfo proto=RSGroupProtos.RSGroupInfo.parseFrom(result.getValue(RSGroupInfoManager.META_FAMILY_BYTES,RSGroupInfoManager.META_QUALIFIER_BYTES));
    groupMap.put(proto.getName(),RSGroupProtobufUtil.toGroupInfo(proto));
  }
  Assert.assertEquals(Sets.newHashSet(groupMap.values()),Sets.newHashSet(wrapped.listRSGroups()));
  try {
    String groupBasePath=ZNodePaths.joinZNode(zkw.getZNodePaths().baseZNode,"String_Node_Str");
    for (    String znode : ZKUtil.listChildrenNoWatch(zkw,groupBasePath)) {
      byte[] data=ZKUtil.getData(zkw,ZNodePaths.joinZNode(groupBasePath,znode));
      if (data.length > 0) {
        ProtobufUtil.expectPBMagicPrefix(data);
        ByteArrayInputStream bis=new ByteArrayInputStream(data,ProtobufUtil.lengthOfPBMagic(),data.length);
        zList.add(RSGroupProtobufUtil.toGroupInfo(RSGroupProtos.RSGroupInfo.parseFrom(bis)));
      }
    }
    Assert.assertEquals(zList.size(),groupMap.size());
    for (    RSGroupInfo RSGroupInfo : zList) {
      Assert.assertTrue(groupMap.get(RSGroupInfo.getName()).equals(RSGroupInfo));
    }
  }
 catch (  KeeperException e) {
    throw new IOException("String_Node_Str",e);
  }
catch (  DeserializationException e) {
    throw new IOException("String_Node_Str",e);
  }
catch (  InterruptedException e) {
    throw new IOException("String_Node_Str",e);
  }
}
Program: 60825
Project: 60825
Buggy source:
public ZKNamespaceManager(ZKWatcher zkw) throws IOException {
  super(zkw);
  nsZNode=zkw.znodePaths.namespaceZNode;
  cache=new ConcurrentSkipListMap<>();
}

Fixed version (ground truth):
public ZKNamespaceManager(ZKWatcher zkw) throws IOException {
  super(zkw);
  nsZNode=zkw.getZNodePaths().namespaceZNode;
  cache=new ConcurrentSkipListMap<>();
}
Program: 60826
Project: 60826
Buggy source:
/** 
 * Delete the master znode if its content (ServerName string) is the same as the one in the znode file. (env: HBASE_ZNODE_FILE). I case of master-rs colloaction we extract ServerName string from rsZnode path.(HBASE-14861)
 * @return true on successful deletion, false otherwise.
 */
public static boolean clear(Configuration conf){
  Configuration tempConf=new Configuration(conf);
  tempConf.setInt("String_Node_Str",0);
  ZKWatcher zkw;
  try {
    zkw=new ZKWatcher(tempConf,"String_Node_Str",new Abortable(){
      @Override public void abort(      String why,      Throwable e){
      }
      @Override public boolean isAborted(){
        return false;
      }
    }
);
  }
 catch (  IOException e) {
    LOG.warn("String_Node_Str",e);
    return false;
  }
  String znodeFileContent;
  try {
    znodeFileContent=ZNodeClearer.readMyEphemeralNodeOnDisk();
    if (ZNodeClearer.tablesOnMaster(conf)) {
      ZKUtil.deleteNodeFailSilent(zkw,ZNodePaths.joinZNode(zkw.znodePaths.rsZNode,znodeFileContent));
      return MasterAddressTracker.deleteIfEquals(zkw,ZNodeClearer.parseMasterServerName(znodeFileContent));
    }
 else {
      return MasterAddressTracker.deleteIfEquals(zkw,znodeFileContent);
    }
  }
 catch (  FileNotFoundException fnfe) {
    LOG.warn("String_Node_Str",fnfe);
    return true;
  }
catch (  IOException e) {
    LOG.warn("String_Node_Str",e);
    return false;
  }
catch (  KeeperException e) {
    LOG.warn("String_Node_Str",e);
    return false;
  }
 finally {
    zkw.close();
  }
}

Fixed version (ground truth):
/** 
 * Delete the master znode if its content (ServerName string) is the same as the one in the znode file. (env: HBASE_ZNODE_FILE). I case of master-rs colloaction we extract ServerName string from rsZnode path.(HBASE-14861)
 * @return true on successful deletion, false otherwise.
 */
public static boolean clear(Configuration conf){
  Configuration tempConf=new Configuration(conf);
  tempConf.setInt("String_Node_Str",0);
  ZKWatcher zkw;
  try {
    zkw=new ZKWatcher(tempConf,"String_Node_Str",new Abortable(){
      @Override public void abort(      String why,      Throwable e){
      }
      @Override public boolean isAborted(){
        return false;
      }
    }
);
  }
 catch (  IOException e) {
    LOG.warn("String_Node_Str",e);
    return false;
  }
  String znodeFileContent;
  try {
    znodeFileContent=ZNodeClearer.readMyEphemeralNodeOnDisk();
    if (ZNodeClearer.tablesOnMaster(conf)) {
      ZKUtil.deleteNodeFailSilent(zkw,ZNodePaths.joinZNode(zkw.getZNodePaths().rsZNode,znodeFileContent));
      return MasterAddressTracker.deleteIfEquals(zkw,ZNodeClearer.parseMasterServerName(znodeFileContent));
    }
 else {
      return MasterAddressTracker.deleteIfEquals(zkw,znodeFileContent);
    }
  }
 catch (  FileNotFoundException fnfe) {
    LOG.warn("String_Node_Str",fnfe);
    return true;
  }
catch (  IOException e) {
    LOG.warn("String_Node_Str",e);
    return false;
  }
catch (  KeeperException e) {
    LOG.warn("String_Node_Str",e);
    return false;
  }
 finally {
    zkw.close();
  }
}
Program: 60827
Project: 60827
Buggy source:
/** 
 * @param conf conf to read for the base archive node
 * @param zooKeeper zookeeper to used for building the full path
 * @return get the znode for long-term archival of a table for
 */
public static String getArchiveZNode(Configuration conf,ZKWatcher zooKeeper){
  return ZNodePaths.joinZNode(zooKeeper.znodePaths.baseZNode,conf.get(ZOOKEEPER_ZNODE_HFILE_ARCHIVE_KEY,TableHFileArchiveTracker.HFILE_ARCHIVE_ZNODE_PARENT));
}

Fixed version (ground truth):
/** 
 * @param conf conf to read for the base archive node
 * @param zooKeeper zookeeper to used for building the full path
 * @return get the znode for long-term archival of a table for
 */
public static String getArchiveZNode(Configuration conf,ZKWatcher zooKeeper){
  return ZNodePaths.joinZNode(zooKeeper.getZNodePaths().baseZNode,conf.get(ZOOKEEPER_ZNODE_HFILE_ARCHIVE_KEY,TableHFileArchiveTracker.HFILE_ARCHIVE_ZNODE_PARENT));
}
Program: 60828
Project: 60828
Buggy source:
@Override public int remainingTasksInCoordination(){
  int count=0;
  try {
    List<String> tasks=ZKUtil.listChildrenNoWatch(watcher,watcher.znodePaths.splitLogZNode);
    if (tasks != null) {
      int listSize=tasks.size();
      for (int i=0; i < listSize; i++) {
        if (!ZKSplitLog.isRescanNode(tasks.get(i))) {
          count++;
        }
      }
    }
  }
 catch (  KeeperException ke) {
    LOG.warn("String_Node_Str",ke);
    count=-1;
  }
  return count;
}

Fixed version (ground truth):
@Override public int remainingTasksInCoordination(){
  int count=0;
  try {
    List<String> tasks=ZKUtil.listChildrenNoWatch(watcher,watcher.getZNodePaths().splitLogZNode);
    if (tasks != null) {
      int listSize=tasks.size();
      for (int i=0; i < listSize; i++) {
        if (!ZKSplitLog.isRescanNode(tasks.get(i))) {
          count++;
        }
      }
    }
  }
 catch (  KeeperException ke) {
    LOG.warn("String_Node_Str",ke);
    count=-1;
  }
  return count;
}
Program: 60829
Project: 60829
Buggy source:
private void lookForOrphans(){
  List<String> orphans;
  try {
    orphans=ZKUtil.listChildrenNoWatch(this.watcher,this.watcher.znodePaths.splitLogZNode);
    if (orphans == null) {
      LOG.warn("String_Node_Str" + this.watcher.znodePaths.splitLogZNode);
      return;
    }
  }
 catch (  KeeperException e) {
    LOG.warn("String_Node_Str" + this.watcher.znodePaths.splitLogZNode + "String_Node_Str"+ StringUtils.stringifyException(e));
    return;
  }
  int rescan_nodes=0;
  int listSize=orphans.size();
  for (int i=0; i < listSize; i++) {
    String path=orphans.get(i);
    String nodepath=ZNodePaths.joinZNode(watcher.znodePaths.splitLogZNode,path);
    if (ZKSplitLog.isRescanNode(watcher,nodepath)) {
      rescan_nodes++;
      LOG.debug("String_Node_Str" + path);
    }
 else {
      LOG.info("String_Node_Str" + path);
    }
    getDataSetWatch(nodepath,zkretries);
  }
  LOG.info("String_Node_Str" + (orphans.size() - rescan_nodes) + "String_Node_Str"+ rescan_nodes+ "String_Node_Str");
}

Fixed version (ground truth):
private void lookForOrphans(){
  List<String> orphans;
  try {
    orphans=ZKUtil.listChildrenNoWatch(this.watcher,this.watcher.getZNodePaths().splitLogZNode);
    if (orphans == null) {
      LOG.warn("String_Node_Str" + this.watcher.getZNodePaths().splitLogZNode);
      return;
    }
  }
 catch (  KeeperException e) {
    LOG.warn("String_Node_Str" + this.watcher.getZNodePaths().splitLogZNode + "String_Node_Str"+ StringUtils.stringifyException(e));
    return;
  }
  int rescan_nodes=0;
  int listSize=orphans.size();
  for (int i=0; i < listSize; i++) {
    String path=orphans.get(i);
    String nodepath=ZNodePaths.joinZNode(watcher.getZNodePaths().splitLogZNode,path);
    if (ZKSplitLog.isRescanNode(watcher,nodepath)) {
      rescan_nodes++;
      LOG.debug("String_Node_Str" + path);
    }
 else {
      LOG.info("String_Node_Str" + path);
    }
    getDataSetWatch(nodepath,zkretries);
  }
  LOG.info("String_Node_Str" + (orphans.size() - rescan_nodes) + "String_Node_Str"+ rescan_nodes+ "String_Node_Str");
}
Program: 60831
Project: 60831
Buggy source:
@Override public boolean isReady() throws InterruptedException {
  int result=-1;
  try {
    result=ZKUtil.checkExists(watcher,watcher.znodePaths.splitLogZNode);
  }
 catch (  KeeperException e) {
    LOG.warn("String_Node_Str" + watcher.znodePaths.splitLogZNode + "String_Node_Str",e);
  }
  if (result == -1) {
    LOG.info(watcher.znodePaths.splitLogZNode + "String_Node_Str");
    Thread.sleep(1000);
  }
  return (result != -1);
}

Fixed version (ground truth):
@Override public boolean isReady() throws InterruptedException {
  int result=-1;
  try {
    result=ZKUtil.checkExists(watcher,watcher.getZNodePaths().splitLogZNode);
  }
 catch (  KeeperException e) {
    LOG.warn("String_Node_Str" + watcher.getZNodePaths().splitLogZNode + "String_Node_Str",e);
  }
  if (result == -1) {
    LOG.info(watcher.getZNodePaths().splitLogZNode + "String_Node_Str");
    Thread.sleep(1000);
  }
  return (result != -1);
}
Program: 60832
Project: 60832
Buggy source:
private List<String> getTaskList() throws InterruptedException {
  List<String> childrenPaths=null;
  long sleepTime=1000;
  while (!shouldStop) {
    try {
      childrenPaths=ZKUtil.listChildrenAndWatchForNewChildren(watcher,watcher.znodePaths.splitLogZNode);
      if (childrenPaths != null) {
        return childrenPaths;
      }
    }
 catch (    KeeperException e) {
      LOG.warn("String_Node_Str" + watcher.znodePaths.splitLogZNode,e);
    }
    LOG.debug("String_Node_Str" + watcher.znodePaths.splitLogZNode + "String_Node_Str"+ sleepTime+ "String_Node_Str");
    Thread.sleep(sleepTime);
  }
  return childrenPaths;
}

Fixed version (ground truth):
private List<String> getTaskList() throws InterruptedException {
  List<String> childrenPaths=null;
  long sleepTime=1000;
  while (!shouldStop) {
    try {
      childrenPaths=ZKUtil.listChildrenAndWatchForNewChildren(watcher,watcher.getZNodePaths().splitLogZNode);
      if (childrenPaths != null) {
        return childrenPaths;
      }
    }
 catch (    KeeperException e) {
      LOG.warn("String_Node_Str" + watcher.getZNodePaths().splitLogZNode,e);
    }
    LOG.debug("String_Node_Str" + watcher.getZNodePaths().splitLogZNode + "String_Node_Str"+ sleepTime+ "String_Node_Str");
    Thread.sleep(sleepTime);
  }
  return childrenPaths;
}
Program: 60833
Project: 60833
Buggy source:
/** 
 * Override handler from   {@link ZKListener}
 */
@Override public void nodeChildrenChanged(String path){
  if (path.equals(watcher.znodePaths.splitLogZNode)) {
    if (LOG.isTraceEnabled()) {
      LOG.trace("String_Node_Str" + path);
    }
synchronized (taskReadySeq) {
      this.taskReadySeq.incrementAndGet();
      taskReadySeq.notify();
    }
  }
}

Fixed version (ground truth):
/** 
 * Override handler from   {@link ZKListener}
 */
@Override public void nodeChildrenChanged(String path){
  if (path.equals(watcher.getZNodePaths().splitLogZNode)) {
    if (LOG.isTraceEnabled()) {
      LOG.trace("String_Node_Str" + path);
    }
synchronized (taskReadySeq) {
      this.taskReadySeq.incrementAndGet();
      taskReadySeq.notify();
    }
  }
}
Program: 60834
Project: 60834
Buggy source:
/** 
 * This function calculates how many splitters this RS should create based on expected average tasks per RS and the hard limit upper bound(maxConcurrentTasks) set by configuration. <br> At any given time, a RS allows spawn MIN(Expected Tasks/RS, Hard Upper Bound)
 * @param numTasks total number of split tasks available
 * @return number of tasks this RS can grab
 */
private int getNumExpectedTasksPerRS(int numTasks){
  int availableRSs=1;
  try {
    List<String> regionServers=ZKUtil.listChildrenNoWatch(watcher,watcher.znodePaths.rsZNode);
    availableRSs=Math.max(availableRSs,(regionServers == null) ? 0 : regionServers.size());
  }
 catch (  KeeperException e) {
    LOG.debug("String_Node_Str",e);
  }
  int expectedTasksPerRS=(numTasks / availableRSs) + ((numTasks % availableRSs == 0) ? 0 : 1);
  return Math.max(1,expectedTasksPerRS);
}

Fixed version (ground truth):
/** 
 * This function calculates how many splitters this RS should create based on expected average tasks per RS and the hard limit upper bound(maxConcurrentTasks) set by configuration. <br> At any given time, a RS allows spawn MIN(Expected Tasks/RS, Hard Upper Bound)
 * @param numTasks total number of split tasks available
 * @return number of tasks this RS can grab
 */
private int getNumExpectedTasksPerRS(int numTasks){
  int availableRSs=1;
  try {
    List<String> regionServers=ZKUtil.listChildrenNoWatch(watcher,watcher.getZNodePaths().rsZNode);
    availableRSs=Math.max(availableRSs,(regionServers == null) ? 0 : regionServers.size());
  }
 catch (  KeeperException e) {
    LOG.debug("String_Node_Str",e);
  }
  int expectedTasksPerRS=(numTasks / availableRSs) + ((numTasks % availableRSs == 0) ? 0 : 1);
  return Math.max(1,expectedTasksPerRS);
}
Program: 60835
Project: 60835
Buggy source:
public void stop(){
  try {
synchronized (clusterHasActiveMaster) {
      clusterHasActiveMaster.notifyAll();
    }
    ServerName activeMaster=null;
    try {
      activeMaster=MasterAddressTracker.getMasterAddress(this.watcher);
    }
 catch (    IOException e) {
      LOG.warn("String_Node_Str" + e.toString());
    }
    if (activeMaster != null && activeMaster.equals(this.sn)) {
      ZKUtil.deleteNode(watcher,watcher.znodePaths.masterAddressZNode);
      ZNodeClearer.deleteMyEphemeralNodeOnDisk();
    }
  }
 catch (  KeeperException e) {
    LOG.debug(this.watcher.prefix("String_Node_Str" + e.getMessage()));
  }
}

Fixed version (ground truth):
public void stop(){
  try {
synchronized (clusterHasActiveMaster) {
      clusterHasActiveMaster.notifyAll();
    }
    ServerName activeMaster=null;
    try {
      activeMaster=MasterAddressTracker.getMasterAddress(this.watcher);
    }
 catch (    IOException e) {
      LOG.warn("String_Node_Str" + e.toString());
    }
    if (activeMaster != null && activeMaster.equals(this.sn)) {
      ZKUtil.deleteNode(watcher,watcher.getZNodePaths().masterAddressZNode);
      ZNodeClearer.deleteMyEphemeralNodeOnDisk();
    }
  }
 catch (  KeeperException e) {
    LOG.debug(this.watcher.prefix("String_Node_Str" + e.getMessage()));
  }
}
Program: 60836
Project: 60836
Buggy source:
@Override public void nodeDeleted(String path){
  if (path.equals(watcher.znodePaths.clusterStateZNode) && !master.isStopped()) {
    clusterShutDown.set(true);
  }
  handle(path);
}

Fixed version (ground truth):
@Override public void nodeDeleted(String path){
  if (path.equals(watcher.getZNodePaths().clusterStateZNode) && !master.isStopped()) {
    clusterShutDown.set(true);
  }
  handle(path);
}
Program: 60837
Project: 60837
Buggy source:
/** 
 * Handle a change in the master node.  Doesn't matter whether this was called from a nodeCreated or nodeDeleted event because there are no guarantees that the current state of the master node matches the event at the time of our next ZK request. <p>Uses the watchAndCheckExists method which watches the master address node regardless of whether it exists or not.  If it does exist (there is an active master), it returns true.  Otherwise it returns false. <p>A watcher is set which guarantees that this method will get called again if there is another change in the master node.
 */
private void handleMasterNodeChange(){
  try {
synchronized (clusterHasActiveMaster) {
      if (ZKUtil.watchAndCheckExists(watcher,watcher.znodePaths.masterAddressZNode)) {
        LOG.trace("String_Node_Str");
        clusterHasActiveMaster.set(true);
      }
 else {
        LOG.debug("String_Node_Str");
        clusterHasActiveMaster.set(false);
        clusterHasActiveMaster.notifyAll();
      }
    }
  }
 catch (  KeeperException ke) {
    master.abort("String_Node_Str",ke);
  }
}

Fixed version (ground truth):
/** 
 * Handle a change in the master node.  Doesn't matter whether this was called from a nodeCreated or nodeDeleted event because there are no guarantees that the current state of the master node matches the event at the time of our next ZK request. <p>Uses the watchAndCheckExists method which watches the master address node regardless of whether it exists or not.  If it does exist (there is an active master), it returns true.  Otherwise it returns false. <p>A watcher is set which guarantees that this method will get called again if there is another change in the master node.
 */
private void handleMasterNodeChange(){
  try {
synchronized (clusterHasActiveMaster) {
      if (ZKUtil.watchAndCheckExists(watcher,watcher.getZNodePaths().masterAddressZNode)) {
        LOG.trace("String_Node_Str");
        clusterHasActiveMaster.set(true);
      }
 else {
        LOG.debug("String_Node_Str");
        clusterHasActiveMaster.set(false);
        clusterHasActiveMaster.notifyAll();
      }
    }
  }
 catch (  KeeperException ke) {
    master.abort("String_Node_Str",ke);
  }
}
Program: 60838
Project: 60838
Buggy source:
void handle(final String path){
  if (path.equals(watcher.znodePaths.masterAddressZNode) && !master.isStopped()) {
    handleMasterNodeChange();
  }
}

Fixed version (ground truth):
void handle(final String path){
  if (path.equals(watcher.getZNodePaths().masterAddressZNode) && !master.isStopped()) {
    handleMasterNodeChange();
  }
}
Program: 60840
Project: 60840
Buggy source:
/** 
 * @return True if cluster has an active master.
 */
boolean hasActiveMaster(){
  try {
    if (ZKUtil.checkExists(watcher,watcher.znodePaths.masterAddressZNode) >= 0) {
      return true;
    }
  }
 catch (  KeeperException ke) {
    LOG.info("String_Node_Str" + "String_Node_Str" + ke);
  }
  return false;
}

Fixed version (ground truth):
/** 
 * @return True if cluster has an active master.
 */
boolean hasActiveMaster(){
  try {
    if (ZKUtil.checkExists(watcher,watcher.getZNodePaths().masterAddressZNode) >= 0) {
      return true;
    }
  }
 catch (  KeeperException ke) {
    LOG.info("String_Node_Str" + "String_Node_Str" + ke);
  }
  return false;
}
Program: 60841
Project: 60841
Buggy source:
@Override public void nodeChildrenChanged(final String path){
  if (path.equals(watcher.znodePaths.drainingZNode)) {
    try {
      final List<String> newNodes=ZKUtil.listChildrenAndWatchThem(watcher,watcher.znodePaths.drainingZNode);
      add(newNodes);
    }
 catch (    KeeperException e) {
      abortable.abort("String_Node_Str",e);
    }
catch (    IOException e) {
      abortable.abort("String_Node_Str",e);
    }
  }
}

Fixed version (ground truth):
@Override public void nodeChildrenChanged(final String path){
  if (path.equals(watcher.getZNodePaths().drainingZNode)) {
    try {
      final List<String> newNodes=ZKUtil.listChildrenAndWatchThem(watcher,watcher.getZNodePaths().drainingZNode);
      add(newNodes);
    }
 catch (    KeeperException e) {
      abortable.abort("String_Node_Str",e);
    }
catch (    IOException e) {
      abortable.abort("String_Node_Str",e);
    }
  }
}
Program: 60842
Project: 60842
Buggy source:
@Override public void nodeDeleted(final String path){
  if (path.startsWith(watcher.znodePaths.drainingZNode)) {
    final ServerName sn=ServerName.valueOf(ZKUtil.getNodeName(path));
    LOG.info("String_Node_Str" + sn + "String_Node_Str");
    remove(sn);
  }
}

Fixed version (ground truth):
@Override public void nodeDeleted(final String path){
  if (path.startsWith(watcher.getZNodePaths().drainingZNode)) {
    final ServerName sn=ServerName.valueOf(ZKUtil.getNodeName(path));
    LOG.info("String_Node_Str" + sn + "String_Node_Str");
    remove(sn);
  }
}
Program: 60843
Project: 60843
Buggy source:
/** 
 * Starts the tracking of draining RegionServers. <p>All Draining RSs will be tracked after this method is called.
 * @throws KeeperException
 */
public void start() throws KeeperException, IOException {
  watcher.registerListener(this);
  serverManager.registerListener(new ServerListener(){
    @Override public void serverAdded(    ServerName sn){
      if (drainingServers.contains(sn)) {
        serverManager.addServerToDrainList(sn);
      }
    }
  }
);
  List<String> servers=ZKUtil.listChildrenAndWatchThem(watcher,watcher.znodePaths.drainingZNode);
  add(servers);
}

Fixed version (ground truth):
/** 
 * Starts the tracking of draining RegionServers. <p>All Draining RSs will be tracked after this method is called.
 * @throws KeeperException
 */
public void start() throws KeeperException, IOException {
  watcher.registerListener(this);
  serverManager.registerListener(new ServerListener(){
    @Override public void serverAdded(    ServerName sn){
      if (drainingServers.contains(sn)) {
        serverManager.addServerToDrainList(sn);
      }
    }
  }
);
  List<String> servers=ZKUtil.listChildrenAndWatchThem(watcher,watcher.getZNodePaths().drainingZNode);
  add(servers);
}
Program: 60844
Project: 60844
Buggy source:
/** 
 * Restore operation. Stage 2: resolved Backup Image dependency
 * @param backupManifestMap : tableName, Manifest
 * @param sTableArray The array of tables to be restored
 * @param tTableArray The array of mapping tables to restore to
 * @throws IOException exception
 */
private void restore(HashMap<TableName,BackupManifest> backupManifestMap,TableName[] sTableArray,TableName[] tTableArray,boolean isOverwrite) throws IOException {
  TreeSet<BackupImage> restoreImageSet=new TreeSet<>();
  Set<String> backupIdSet=new HashSet<>();
  for (int i=0; i < sTableArray.length; i++) {
    TableName table=sTableArray[i];
    BackupManifest manifest=backupManifestMap.get(table);
    List<BackupImage> list=new ArrayList<>();
    list.add(manifest.getBackupImage());
    TreeSet<BackupImage> set=new TreeSet<>(list);
    List<BackupImage> depList=manifest.getDependentListByTable(table);
    set.addAll(depList);
    BackupImage[] arr=new BackupImage[set.size()];
    set.toArray(arr);
    restoreImages(arr,table,tTableArray[i],isOverwrite);
    restoreImageSet.addAll(list);
    if (restoreImageSet != null && !restoreImageSet.isEmpty()) {
      LOG.info("String_Node_Str");
      for (      BackupImage image : restoreImageSet) {
        LOG.info("String_Node_Str" + image.getBackupId() + "String_Node_Str"+ HBackupFileSystem.getTableBackupDir(image.getRootDir(),image.getBackupId(),table));
        if (image.getType() == BackupType.INCREMENTAL) {
          backupIdSet.add(image.getBackupId());
          LOG.debug("String_Node_Str" + image.getBackupId() + "String_Node_Str");
        }
      }
    }
  }
  LOG.debug("String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Restore operation. Stage 2: resolved Backup Image dependency
 * @param backupManifestMap : tableName, Manifest
 * @param sTableArray The array of tables to be restored
 * @param tTableArray The array of mapping tables to restore to
 * @throws IOException exception
 */
private void restore(HashMap<TableName,BackupManifest> backupManifestMap,TableName[] sTableArray,TableName[] tTableArray,boolean isOverwrite) throws IOException {
  TreeSet<BackupImage> restoreImageSet=new TreeSet<>();
  for (int i=0; i < sTableArray.length; i++) {
    TableName table=sTableArray[i];
    BackupManifest manifest=backupManifestMap.get(table);
    List<BackupImage> list=new ArrayList<>();
    list.add(manifest.getBackupImage());
    TreeSet<BackupImage> set=new TreeSet<>(list);
    List<BackupImage> depList=manifest.getDependentListByTable(table);
    set.addAll(depList);
    BackupImage[] arr=new BackupImage[set.size()];
    set.toArray(arr);
    restoreImages(arr,table,tTableArray[i],isOverwrite);
    restoreImageSet.addAll(list);
    if (restoreImageSet != null && !restoreImageSet.isEmpty()) {
      LOG.info("String_Node_Str");
      for (      BackupImage image : restoreImageSet) {
        LOG.info("String_Node_Str" + image.getBackupId() + "String_Node_Str"+ HBackupFileSystem.getTableBackupDir(image.getRootDir(),image.getBackupId(),table));
      }
    }
  }
  LOG.debug("String_Node_Str");
}
Program: 60845
Project: 60845
Buggy source:
/** 
 * Do the encoding, but do not cache the encoded data.
 * @return encoded data block with header and checksum
 */
public byte[] encodeData(){
  ByteArrayOutputStream baos=new ByteArrayOutputStream();
  try {
    baos.write(HConstants.HFILEBLOCK_DUMMY_HEADER);
    DataOutputStream out=new DataOutputStream(baos);
    this.dataBlockEncoder.startBlockEncoding(encodingCtx,out);
    ByteBuffer in=getUncompressedBuffer();
    in.rewind();
    int klength, vlength;
    int tagsLength=0;
    long memstoreTS=0L;
    KeyValue kv=null;
    while (in.hasRemaining()) {
      int kvOffset=in.position();
      klength=in.getInt();
      vlength=in.getInt();
      ByteBufferUtils.skip(in,klength + vlength);
      if (this.meta.isIncludesTags()) {
        tagsLength=((in.get() & 0xff) << 8) ^ (in.get() & 0xff);
        ByteBufferUtils.skip(in,tagsLength);
      }
      if (this.meta.isIncludesMvcc()) {
        memstoreTS=ByteBufferUtils.readVLong(in);
      }
      kv=new KeyValue(in.array(),kvOffset,(int)KeyValue.getKeyValueDataStructureSize(klength,vlength,tagsLength));
      kv.setSequenceId(memstoreTS);
      this.dataBlockEncoder.encode(kv,encodingCtx,out);
    }
    BufferGrabbingByteArrayOutputStream stream=new BufferGrabbingByteArrayOutputStream();
    baos.writeTo(stream);
    this.dataBlockEncoder.endBlockEncoding(encodingCtx,out,stream.ourBytes);
  }
 catch (  IOException e) {
    throw new RuntimeException(String.format("String_Node_Str" + "String_Node_Str",toString()),e);
  }
  return baos.toByteArray();
}

Fixed version (ground truth):
/** 
 * Do the encoding, but do not cache the encoded data.
 * @return encoded data block with header and checksum
 */
public byte[] encodeData(){
  ByteArrayOutputStream baos=new ByteArrayOutputStream();
  byte[] baosBytes=null;
  try {
    baos.write(HConstants.HFILEBLOCK_DUMMY_HEADER);
    DataOutputStream out=new DataOutputStream(baos);
    this.dataBlockEncoder.startBlockEncoding(encodingCtx,out);
    ByteBuffer in=getUncompressedBuffer();
    in.rewind();
    int klength, vlength;
    int tagsLength=0;
    long memstoreTS=0L;
    KeyValue kv=null;
    while (in.hasRemaining()) {
      int kvOffset=in.position();
      klength=in.getInt();
      vlength=in.getInt();
      ByteBufferUtils.skip(in,klength + vlength);
      if (this.meta.isIncludesTags()) {
        tagsLength=((in.get() & 0xff) << 8) ^ (in.get() & 0xff);
        ByteBufferUtils.skip(in,tagsLength);
      }
      if (this.meta.isIncludesMvcc()) {
        memstoreTS=ByteBufferUtils.readVLong(in);
      }
      kv=new KeyValue(in.array(),kvOffset,(int)KeyValue.getKeyValueDataStructureSize(klength,vlength,tagsLength));
      kv.setSequenceId(memstoreTS);
      this.dataBlockEncoder.encode(kv,encodingCtx,out);
    }
    baos.flush();
    baosBytes=baos.toByteArray();
    this.dataBlockEncoder.endBlockEncoding(encodingCtx,out,baosBytes);
  }
 catch (  IOException e) {
    throw new RuntimeException(String.format("String_Node_Str" + "String_Node_Str",toString()),e);
  }
  return baosBytes;
}
Program: 60846
Project: 60846
Buggy source:
@Override protected void periodicExecute(final TEnvironment env){
  if (completed.isEmpty()) {
    if (LOG.isTraceEnabled()) {
      LOG.trace("String_Node_Str");
    }
    return;
  }
  final long evictTtl=conf.getInt(EVICT_TTL_CONF_KEY,DEFAULT_EVICT_TTL);
  final long evictAckTtl=conf.getInt(EVICT_ACKED_TTL_CONF_KEY,DEFAULT_ACKED_EVICT_TTL);
  final int batchSize=conf.getInt(BATCH_SIZE_CONF_KEY,DEFAULT_BATCH_SIZE);
  final long[] batchIds=new long[batchSize];
  int batchCount=0;
  final long now=EnvironmentEdgeManager.currentTime();
  final Iterator<Map.Entry<Long,CompletedProcedureRetainer>> it=completed.entrySet().iterator();
  final boolean debugEnabled=LOG.isDebugEnabled();
  while (it.hasNext() && store.isRunning()) {
    final Map.Entry<Long,CompletedProcedureRetainer> entry=it.next();
    final CompletedProcedureRetainer retainer=entry.getValue();
    final Procedure<?> proc=retainer.getProcedure();
    if (retainer.isExpired(now,evictTtl,evictAckTtl)) {
      if (!(proc instanceof FailedProcedure)) {
        batchIds[batchCount++]=entry.getKey();
        if (batchCount == batchIds.length) {
          store.delete(batchIds,0,batchCount);
          batchCount=0;
        }
      }
      final NonceKey nonceKey=proc.getNonceKey();
      if (nonceKey != null) {
        nonceKeysToProcIdsMap.remove(nonceKey);
      }
      it.remove();
      LOG.trace("String_Node_Str",proc);
    }
  }
  if (batchCount > 0) {
    store.delete(batchIds,0,batchCount);
  }
}

Fixed version (ground truth):
@Override protected void periodicExecute(final TEnvironment env){
  if (completed.isEmpty()) {
    if (LOG.isTraceEnabled()) {
      LOG.trace("String_Node_Str");
    }
    return;
  }
  final long evictTtl=conf.getInt(EVICT_TTL_CONF_KEY,DEFAULT_EVICT_TTL);
  final long evictAckTtl=conf.getInt(EVICT_ACKED_TTL_CONF_KEY,DEFAULT_ACKED_EVICT_TTL);
  final int batchSize=conf.getInt(BATCH_SIZE_CONF_KEY,DEFAULT_BATCH_SIZE);
  final long[] batchIds=new long[batchSize];
  int batchCount=0;
  final long now=EnvironmentEdgeManager.currentTime();
  final Iterator<Map.Entry<Long,CompletedProcedureRetainer>> it=completed.entrySet().iterator();
  while (it.hasNext() && store.isRunning()) {
    final Map.Entry<Long,CompletedProcedureRetainer> entry=it.next();
    final CompletedProcedureRetainer retainer=entry.getValue();
    final Procedure<?> proc=retainer.getProcedure();
    if (retainer.isExpired(now,evictTtl,evictAckTtl)) {
      if (!(proc instanceof FailedProcedure)) {
        batchIds[batchCount++]=entry.getKey();
        if (batchCount == batchIds.length) {
          store.delete(batchIds,0,batchCount);
          batchCount=0;
        }
      }
      final NonceKey nonceKey=proc.getNonceKey();
      if (nonceKey != null) {
        nonceKeysToProcIdsMap.remove(nonceKey);
      }
      it.remove();
      LOG.trace("String_Node_Str",proc);
    }
  }
  if (batchCount > 0) {
    store.delete(batchIds,0,batchCount);
  }
}
Program: 60847
Project: 60847
Buggy source:
@Override protected boolean abort(final TEnvironment env){
  final TState state=getCurrentState();
  LOG.debug("String_Node_Str",this);
  if (hasMoreState()) {
    aborted.set(true);
    return true;
  }
  LOG.debug("String_Node_Str",this);
  return false;
}

Fixed version (ground truth):
@Override protected boolean abort(final TEnvironment env){
  LOG.debug("String_Node_Str",this);
  if (hasMoreState()) {
    aborted.set(true);
    return true;
  }
  LOG.debug("String_Node_Str",this);
  return false;
}