Program: 7651
Project: 7651
Buggy source:
private Iterator<AggregatesScanResult> createIterator(){
  return new AbstractIterator<AggregatesScanResult>(){
    private String context;
    private String metric;
    private String rid;
    private Iterator<Map.Entry<byte[],byte[]>> currentTag=null;
    @Override protected AggregatesScanResult computeNext(){
      AggregatesScanResult result=findNextResult();
      if (result != null) {
        return result;
      }
      ImmutablePair<byte[],Map<byte[],byte[]>> rowResult;
      while ((rowResult=scanner.next()) != null) {
        rowScanned++;
        byte[] rowKey=rowResult.getFirst();
        int offset=0;
        context=entityCodec.decode(MetricsEntityType.CONTEXT,rowKey,offset);
        if (contextPrefix != null && !context.startsWith(contextPrefix)) {
          continue;
        }
        offset+=entityCodec.getEncodedSize(MetricsEntityType.CONTEXT);
        metric=entityCodec.decode(MetricsEntityType.METRIC,rowKey,offset);
        if (metricPrefix != null && !metric.startsWith(metricPrefix)) {
          continue;
        }
        offset+=entityCodec.getEncodedSize(MetricsEntityType.METRIC);
        rid=entityCodec.decode(MetricsEntityType.RUN,rowKey,offset);
        if (runId != null && !runId.equals(rid)) {
          continue;
        }
        currentTag=rowResult.getSecond().entrySet().iterator();
        result=findNextResult();
        if (result != null) {
          return result;
        }
      }
      scanner.close();
      return endOfData();
    }
    private AggregatesScanResult findNextResult(){
      while (currentTag != null && currentTag.hasNext()) {
        Map.Entry<byte[],byte[]> tagValue=currentTag.next();
        String tag=Bytes.toString(tagValue.getKey());
        if (!tag.startsWith(tagPrefix)) {
          continue;
        }
        if (MetricsConstants.EMPTY_TAG.equals(tag)) {
          tag=null;
        }
        return new AggregatesScanResult(context,metric,rid,tag,Bytes.toLong(tagValue.getValue()));
      }
      return null;
    }
  }
;
}

Fixed version (ground truth):
private Iterator<AggregatesScanResult> createIterator(){
  return new AbstractIterator<AggregatesScanResult>(){
    private String context;
    private String metric;
    private String rid;
    private Iterator<Map.Entry<byte[],byte[]>> currentTag=null;
    @Override protected AggregatesScanResult computeNext(){
      AggregatesScanResult result=findNextResult();
      if (result != null) {
        return result;
      }
      ImmutablePair<byte[],Map<byte[],byte[]>> rowResult;
      while ((rowResult=scanner.next()) != null) {
        rowScanned++;
        byte[] rowKey=rowResult.getFirst();
        int offset=0;
        context=entityCodec.decode(MetricsEntityType.CONTEXT,rowKey,offset);
        if (contextPrefix != null && !context.startsWith(contextPrefix)) {
          continue;
        }
        offset+=entityCodec.getEncodedSize(MetricsEntityType.CONTEXT);
        metric=entityCodec.decode(MetricsEntityType.METRIC,rowKey,offset);
        if (metricPrefix != null && !metric.startsWith(metricPrefix)) {
          continue;
        }
        offset+=entityCodec.getEncodedSize(MetricsEntityType.METRIC);
        rid=entityCodec.decode(MetricsEntityType.RUN,rowKey,offset);
        if (runId != null && !runId.equals(rid)) {
          continue;
        }
        currentTag=rowResult.getSecond().entrySet().iterator();
        result=findNextResult();
        if (result != null) {
          return result;
        }
      }
      scanner.close();
      return endOfData();
    }
    private AggregatesScanResult findNextResult(){
      while (currentTag != null && currentTag.hasNext()) {
        Map.Entry<byte[],byte[]> tagValue=currentTag.next();
        String tag=Bytes.toString(tagValue.getKey());
        if (tagPrefix != null && !tag.startsWith(tagPrefix)) {
          continue;
        }
        if (MetricsConstants.EMPTY_TAG.equals(tag)) {
          tag=null;
        }
        return new AggregatesScanResult(context,metric,rid,tag,Bytes.toLong(tagValue.getValue()));
      }
      return null;
    }
  }
;
}