Program: 26457
Project: 26457
Buggy source:
private AnalysisHolder analyzeIfNecessary(DataType type,String fieldName){
  if (type == null) {
    throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str");
  }
  if ((fieldName == null) || "String_Node_Str".equals(fieldName)) {
    throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str");
  }
  String key=type.getKey(fieldName);
  SoftReference<AnalysisHolder> holderRef=values.get(key);
  AnalysisHolder holder=null;
  if (holderRef != null) {
    holder=holderRef.get();
    if (holder != null) {
      return holder;
    }
  }
  holder=new AnalysisHolder();
  values.put(key,new SoftReference<AnalysisHolder>(holder));
  long startT=System.nanoTime();
  DataType typeToAnalyze=data.getType(type.getId());
  if ((typeToAnalyze != null) && typeToAnalyze.hasField(fieldName)) {
    List<Double> allValues=new java.util.ArrayList<Double>(data.getRecordCount());
    long lastGranularityTime=Math.max(interval.getStart(),data.getStartTime());
    int countSinceLastGranularity=0;
    double granularityTotal=0;
    for (    DataRecord dataRecord : data.getRecords(interval)) {
      if (dataRecord.hasData(typeToAnalyze)) {
        double value=dataRecord.getData(typeToAnalyze,fieldName);
        if (Double.isNaN(value)) {
          continue;
        }
        holder.sum+=value;
        if (value > holder.maximum) {
          holder.maximum=value;
        }
        if (value < holder.minimum) {
          holder.minimum=value;
        }
        allValues.add(value);
        ++countSinceLastGranularity;
        granularityTotal+=value;
        if ((dataRecord.getTime() - lastGranularityTime) >= granularity) {
          double peakAverage=granularityTotal / countSinceLastGranularity;
          if (peakAverage > holder.granularityMaximum) {
            holder.granularityMaximum=peakAverage;
          }
          countSinceLastGranularity=0;
          granularityTotal=0;
          lastGranularityTime=dataRecord.getTime();
        }
      }
    }
    if (allValues.size() > 0) {
      holder.count=allValues.size();
      holder.average=holder.sum / holder.count;
      java.util.Collections.sort(allValues);
      holder.median=calculatePercentile(.5,allValues);
      holder.percentile95=calculatePercentile(.95,allValues);
      holder.percentile99=calculatePercentile(.99,allValues);
      double sumSqDiffs=0;
      for (      double value : allValues) {
        sumSqDiffs+=Math.pow(value - holder.average,2);
      }
      holder.standardDeviation=Math.sqrt(sumSqDiffs / holder.count);
    }
 else {
      holder.maximum=Double.NaN;
      holder.minimum=Double.NaN;
      holder.granularityMaximum=Double.NaN;
    }
  }
 else {
    holder.maximum=Double.NaN;
    holder.minimum=Double.NaN;
    holder.granularityMaximum=Double.NaN;
  }
  if (LOGGER.isDebugEnabled()) {
    LOGGER.debug("String_Node_Str",new Object[]{data,type,fieldName,TimeFormatCache.formatInterval(interval),(System.nanoTime() - startT) / 1000000.0d});
  }
  return holder;
}

Fixed version (ground truth):
private AnalysisHolder analyzeIfNecessary(DataType type,String fieldName){
  if (type == null) {
    throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str");
  }
  if ((fieldName == null) || "String_Node_Str".equals(fieldName)) {
    throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str");
  }
  String key=type.getKey(fieldName);
  SoftReference<AnalysisHolder> holderRef=values.get(key);
  AnalysisHolder holder=null;
  if (holderRef != null) {
    holder=holderRef.get();
    if (holder != null) {
      return holder;
    }
  }
  holder=new AnalysisHolder();
  values.put(key,new SoftReference<AnalysisHolder>(holder));
  long startT=System.nanoTime();
  DataType typeToAnalyze=data.getType(type.getId());
  if ((typeToAnalyze != null) && typeToAnalyze.hasField(fieldName)) {
    List<Double> allValues=new java.util.ArrayList<Double>(data.getRecordCount());
    long lastGranularityTime=Math.max(interval.getStart(),data.getStartTime());
    int countSinceLastGranularity=0;
    double granularityTotal=0;
    boolean isProcess=type.getClass() == com.ibm.nmon.data.ProcessDataType.class;
    for (    DataRecord dataRecord : data.getRecords(interval)) {
      double value=Double.NaN;
      if (isProcess) {
        if (dataRecord.hasData(typeToAnalyze)) {
          value=dataRecord.getData(typeToAnalyze,fieldName);
        }
        if (Double.isNaN(value)) {
          value=0;
        }
      }
 else {
        if (dataRecord.hasData(typeToAnalyze)) {
          value=dataRecord.getData(typeToAnalyze,fieldName);
        }
        if (Double.isNaN(value)) {
          continue;
        }
      }
      holder.sum+=value;
      if (value > holder.maximum) {
        holder.maximum=value;
      }
      if (value < holder.minimum) {
        holder.minimum=value;
      }
      allValues.add(value);
      ++countSinceLastGranularity;
      granularityTotal+=value;
      if ((dataRecord.getTime() - lastGranularityTime) >= granularity) {
        double peakAverage=granularityTotal / countSinceLastGranularity;
        if (peakAverage > holder.granularityMaximum) {
          holder.granularityMaximum=peakAverage;
        }
        countSinceLastGranularity=0;
        granularityTotal=0;
        lastGranularityTime=dataRecord.getTime();
      }
    }
    if (allValues.size() > 0) {
      holder.count=allValues.size();
      holder.average=holder.sum / holder.count;
      java.util.Collections.sort(allValues);
      holder.median=calculatePercentile(.5,allValues);
      holder.percentile95=calculatePercentile(.95,allValues);
      holder.percentile99=calculatePercentile(.99,allValues);
      double sumSqDiffs=0;
      for (      double value : allValues) {
        sumSqDiffs+=Math.pow(value - holder.average,2);
      }
      holder.standardDeviation=Math.sqrt(sumSqDiffs / holder.count);
    }
 else {
      holder.maximum=Double.NaN;
      holder.minimum=Double.NaN;
      holder.granularityMaximum=Double.NaN;
    }
  }
 else {
    holder.maximum=Double.NaN;
    holder.minimum=Double.NaN;
    holder.granularityMaximum=Double.NaN;
  }
  if (LOGGER.isDebugEnabled()) {
    LOGGER.debug("String_Node_Str",new Object[]{data,type,fieldName,TimeFormatCache.formatInterval(interval),(System.nanoTime() - startT) / 1000000.0d});
  }
  return holder;
}