Program: 70678
Project: 70678
Buggy source:
/** 
 * Check if chart has aggregation.
 * @param cm
 */
public static boolean hasAggregation(Chart cm){
  SeriesDefinition baseSD=null;
  if (cm instanceof ChartWithAxes) {
    ChartWithAxes cwa=(ChartWithAxes)cm;
    baseSD=cwa.getBaseAxes()[0].getSeriesDefinitions().get(0);
  }
 else   if (cm instanceof ChartWithoutAxes) {
    ChartWithoutAxes cwoa=(ChartWithoutAxes)cm;
    baseSD=cwoa.getSeriesDefinitions().get(0);
  }
  if (isBaseGroupingDefined(baseSD) && !ChartUtil.isEmpty(baseSD.getGrouping().getAggregateExpression())) {
    return true;
  }
  if (cm instanceof ChartWithAxes) {
    EList<Axis> axisList=((ChartWithAxes)cm).getAxes().get(0).getAssociatedAxes();
    for (    Axis a : axisList) {
      for (      SeriesDefinition orthSD : a.getSeriesDefinitions()) {
        SeriesGrouping grouping=orthSD.getGrouping();
        if (grouping != null && grouping.isEnabled()) {
          for (          Query query : orthSD.getDesignTimeSeries().getDataDefinition()) {
            if (query.getGrouping() != null && !ChartUtil.isEmpty(query.getGrouping().getAggregateExpression())) {
              return true;
            }
          }
        }
      }
    }
  }
 else   if (cm instanceof ChartWithoutAxes) {
    for (    SeriesDefinition orthSD : ((ChartWithoutAxes)cm).getSeriesDefinitions().get(0).getSeriesDefinitions()) {
      SeriesGrouping grouping=orthSD.getGrouping();
      if (grouping != null && grouping.isEnabled()) {
        for (        Query query : orthSD.getDesignTimeSeries().getDataDefinition()) {
          if (query.getGrouping() != null && !ChartUtil.isEmpty(query.getGrouping().getAggregateExpression())) {
            return true;
          }
        }
      }
    }
  }
  return false;
}

Fixed version (ground truth):
/** 
 * Check if chart has aggregation.
 * @param cm
 */
public static boolean hasAggregation(Chart cm){
  SeriesDefinition baseSD=null;
  if (cm instanceof ChartWithAxes) {
    ChartWithAxes cwa=(ChartWithAxes)cm;
    baseSD=cwa.getBaseAxes()[0].getSeriesDefinitions().get(0);
  }
 else   if (cm instanceof ChartWithoutAxes) {
    ChartWithoutAxes cwoa=(ChartWithoutAxes)cm;
    baseSD=cwoa.getSeriesDefinitions().get(0);
  }
  if (isBaseGroupingDefined(baseSD) && !ChartUtil.isEmpty(baseSD.getGrouping().getAggregateExpression())) {
    return true;
  }
  try {
    if (cm instanceof ChartWithAxes) {
      EList<Axis> axisList=((ChartWithAxes)cm).getAxes().get(0).getAssociatedAxes();
      for (      Axis a : axisList) {
        for (        SeriesDefinition orthSD : a.getSeriesDefinitions()) {
          for (          Query query : orthSD.getDesignTimeSeries().getDataDefinition()) {
            if (ChartUtil.getAggregateFuncExpr(orthSD,baseSD,query) != null) {
              return true;
            }
          }
        }
      }
    }
 else     if (cm instanceof ChartWithoutAxes) {
      for (      SeriesDefinition orthSD : ((ChartWithoutAxes)cm).getSeriesDefinitions().get(0).getSeriesDefinitions()) {
        for (        Query query : orthSD.getDesignTimeSeries().getDataDefinition()) {
          if (ChartUtil.getAggregateFuncExpr(orthSD,baseSD,query) != null) {
            return true;
          }
        }
      }
    }
  }
 catch (  ChartException e) {
    logger.log(e);
  }
  return false;
}