Program: 112400
Project: 112400
Buggy source:
private RegionScanner collectStats(final RegionScanner innerScanner,StatisticsCollector stats,final Region region,final Scan scan,Configuration config) throws IOException {
  StatsCollectionCallable callable=new StatsCollectionCallable(stats,region,innerScanner,config,scan);
  byte[] asyncBytes=scan.getAttribute(BaseScannerRegionObserver.RUN_UPDATE_STATS_ASYNC_ATTRIB);
  boolean async=false;
  if (asyncBytes != null) {
    async=Bytes.toBoolean(asyncBytes);
  }
  long rowCount=0;
  StatisticsCollectionRunTracker statsRunTracker=StatisticsCollectionRunTracker.getInstance(config);
  boolean runUpdateStats=statsRunTracker.addUpdateStatsCommandRegion(region.getRegionInfo());
  if (runUpdateStats) {
    if (!async) {
      rowCount=callable.call();
    }
 else {
      statsRunTracker.runTask(callable);
    }
  }
 else {
    rowCount=CONCURRENT_UPDATE_STATS_ROW_COUNT;
    logger.info("String_Node_Str" + region.getRegionInfo().getRegionNameAsString());
  }
  byte[] rowCountBytes=PLong.INSTANCE.toBytes(Long.valueOf(rowCount));
  final Cell aggKeyValue=PhoenixKeyValueUtil.newKeyValue(UNGROUPED_AGG_ROW_KEY,SINGLE_COLUMN_FAMILY,SINGLE_COLUMN,AGG_TIMESTAMP,rowCountBytes,0,rowCountBytes.length);
  RegionScanner scanner=new BaseRegionScanner(innerScanner){
    @Override public HRegionInfo getRegionInfo(){
      return region.getRegionInfo();
    }
    @Override public boolean isFilterDone(){
      return true;
    }
    @Override public void close() throws IOException {
    }
    @Override public boolean next(    List<Cell> results) throws IOException {
      results.add(aggKeyValue);
      return false;
    }
    @Override public long getMaxResultSize(){
      return scan.getMaxResultSize();
    }
  }
;
  return scanner;
}

Fixed version (ground truth):
private RegionScanner collectStats(final RegionScanner innerScanner,StatisticsCollector stats,final Region region,final Scan scan,Configuration config) throws IOException {
  StatsCollectionCallable callable=new StatsCollectionCallable(stats,region,innerScanner,config,scan);
  byte[] asyncBytes=scan.getAttribute(BaseScannerRegionObserver.RUN_UPDATE_STATS_ASYNC_ATTRIB);
  boolean async=false;
  if (asyncBytes != null) {
    async=Bytes.toBoolean(asyncBytes);
  }
  long rowCount=0;
  StatisticsCollectionRunTracker statsRunTracker=StatisticsCollectionRunTracker.getInstance(config);
  boolean runUpdateStats=statsRunTracker.addUpdateStatsCommandRegion(region.getRegionInfo());
  if (runUpdateStats) {
    if (!async) {
      rowCount=callable.call();
    }
 else {
      statsRunTracker.runTask(callable);
    }
  }
 else {
    rowCount=CONCURRENT_UPDATE_STATS_ROW_COUNT;
    logger.info("String_Node_Str" + region.getRegionInfo().getRegionNameAsString());
  }
  byte[] rowCountBytes=PLong.INSTANCE.toBytes(Long.valueOf(rowCount));
  final Cell aggKeyValue=PhoenixKeyValueUtil.newKeyValue(UNGROUPED_AGG_ROW_KEY,SINGLE_COLUMN_FAMILY,SINGLE_COLUMN,AGG_TIMESTAMP,rowCountBytes,0,rowCountBytes.length);
  RegionScanner scanner=new BaseRegionScanner(innerScanner){
    @Override public RegionInfo getRegionInfo(){
      return region.getRegionInfo();
    }
    @Override public boolean isFilterDone(){
      return true;
    }
    @Override public void close() throws IOException {
    }
    @Override public boolean next(    List<Cell> results) throws IOException {
      results.add(aggKeyValue);
      return false;
    }
    @Override public long getMaxResultSize(){
      return scan.getMaxResultSize();
    }
  }
;
  return scanner;
}