Program: 26479
Project: 26479
Buggy source:
public void addBar(BarChartDefinition barDefinition,AnalysisRecord record){
  if (chart == null) {
    throw new IllegalStateException("String_Node_Str");
  }
  if (barDefinition == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  CategoryPlot plot=(CategoryPlot)chart.getPlot();
  DataTupleCategoryDataset dataset=(DataTupleCategoryDataset)plot.getDataset(barDefinition.hasSecondaryYAxis() ? 1 : 0);
  DataSet data=record.getDataSet();
  Statistic previousStat=null;
  for (  DataDefinition definition : barDefinition.getCategories()) {
    if (definition.matchesHost(data)) {
      for (      DataType type : definition.getMatchingTypes(data)) {
        for (        String field : definition.getMatchingFields(type)) {
          String barName=barDefinition.getBarNamingMode().getName(definition,data,type,field,granularity);
          String categoryName=barDefinition.getCategoryNamingMode().getName(definition,data,type,field,granularity);
          Statistic currentStat=definition.getStatistic();
          double value=currentStat.getValue(record,type,field);
          if ((previousStat != null) && (previousStat != currentStat)) {
            dataset.setCategoriesHaveDifferentStats(true);
          }
          previousStat=currentStat;
          dataset.addValue(value,barName,categoryName);
          dataset.associateTuple(barName,categoryName,new DataTuple(data,type,field));
        }
      }
    }
  }
  if ((dataset.getRowCount() > 1) && (chart.getLegend() == null)) {
    addLegend();
  }
  if (barDefinition.isSubtractionNeeded() && (dataset.getRowCount() != 0)) {
    for (int i=0; i < dataset.getColumnCount(); i++) {
      double total=(double)dataset.getValue(0,i).doubleValue();
      String barName=(String)dataset.getColumnKey(i);
      for (int j=1; j < dataset.getRowCount(); j++) {
        double value=dataset.getValue(j,i).doubleValue() - total;
        String categoryName=(String)dataset.getRowKey(j);
        dataset.setValue(value,categoryName,barName);
        total+=value;
      }
    }
  }
}

Fixed version (ground truth):
public void addBar(BarChartDefinition barDefinition,AnalysisRecord record){
  if (chart == null) {
    throw new IllegalStateException("String_Node_Str");
  }
  if (barDefinition == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  CategoryPlot plot=(CategoryPlot)chart.getPlot();
  DataTupleCategoryDataset dataset=(DataTupleCategoryDataset)plot.getDataset(barDefinition.hasSecondaryYAxis() ? 1 : 0);
  DataSet data=record.getDataSet();
  Statistic previousStat=null;
  for (  DataDefinition definition : barDefinition.getCategories()) {
    if (definition.matchesHost(data)) {
      for (      DataType type : definition.getMatchingTypes(data)) {
        for (        String field : definition.getMatchingFields(type)) {
          String barName=barDefinition.getBarNamingMode().getName(definition,data,type,field,granularity);
          String categoryName=barDefinition.getCategoryNamingMode().getName(definition,data,type,field,granularity);
          Statistic currentStat=definition.getStatistic();
          double value=currentStat.getValue(record,type,field);
          if ((previousStat != null) && (previousStat != currentStat)) {
            dataset.setCategoriesHaveDifferentStats(true);
          }
          previousStat=currentStat;
          dataset.addValue(value,barName,categoryName);
          dataset.associateTuple(barName,categoryName,new DataTuple(data,type,field));
        }
      }
    }
  }
  if (barDefinition.isSubtractionNeeded() && (dataset.getRowCount() != 0)) {
    for (int i=0; i < dataset.getColumnCount(); i++) {
      double total=(double)dataset.getValue(0,i).doubleValue();
      String barName=(String)dataset.getColumnKey(i);
      for (int j=1; j < dataset.getRowCount(); j++) {
        double value=dataset.getValue(j,i).doubleValue() - total;
        String categoryName=(String)dataset.getRowKey(j);
        dataset.setValue(value,categoryName,barName);
        total+=value;
      }
    }
  }
  if (chart.getLegend() == null) {
    int rowCount=plot.getDataset(0).getRowCount();
    if (hasSecondaryYAxis) {
      rowCount+=plot.getDataset(1).getRowCount();
    }
    if (rowCount > 1) {
      addLegend();
    }
  }
  plot.configureRangeAxes();
}