Program: 77292
Project: 77292
Buggy source:
/** 
 * Groups rows of data as specified in the grouping criteria for the series definition
 * @throws ChartException
 */
public void applyBaseSeriesSortingAndGrouping(SeriesDefinition sd,String[] saExpressionKeys) throws ChartException {
  if (bBaseGroupingApplied) {
    return;
  }
  bBaseGroupingApplied=true;
  boolean needBaseGrouping=true;
  final SeriesGrouping sg=sd.getGrouping();
  if (sg == null || !sg.isEnabled()) {
    needBaseGrouping=false;
    ;
  }
  final Series seBaseDesignTime=sd.getDesignTimeSeries();
  final Query q=(Query)seBaseDesignTime.getDataDefinition().get(0);
  final int iSortColumnIndex=((Integer)htLookup.get(q.getDefinition())).intValue();
  SortOption so=null;
  if (!sd.isSetSorting()) {
    logger.log(ILogger.WARNING,Messages.getString("String_Node_Str",new Object[]{sd},ULocale.getDefault()));
    if (needBaseGrouping) {
      so=SortOption.ASCENDING_LITERAL;
    }
  }
 else {
    so=sd.getSorting();
  }
  new GroupingSorter().sort(workingResultSet,iSortColumnIndex,so,iaGroupBreaks);
  if (!needBaseGrouping) {
    return;
  }
  final String sFunctionName=sg.getAggregateExpression();
  final int iOrthogonalSeriesCount=saExpressionKeys.length;
  IAggregateFunction[] iafa=new IAggregateFunction[iOrthogonalSeriesCount];
  try {
    for (int i=0; i < iOrthogonalSeriesCount; i++) {
      iafa[i]=PluginSettings.instance().getAggregateFunction(sFunctionName);
      iafa[i].initialize();
    }
  }
 catch (  ChartException pex) {
    throw new ChartException(ChartEnginePlugin.ID,ChartException.DATA_BINDING,pex);
  }
  final DataType dtGrouping=sg.getGroupType();
  if (dtGrouping == DataType.NUMERIC_LITERAL) {
    groupNumerically(workingResultSet,iSortColumnIndex,saExpressionKeys,iaGroupBreaks,null,sg.getGroupingInterval(),iafa);
  }
 else   if (dtGrouping == DataType.DATE_TIME_LITERAL) {
    groupDateTime(workingResultSet,iSortColumnIndex,saExpressionKeys,iaGroupBreaks,null,sg.getGroupingInterval(),sg.getGroupingUnit(),iafa);
  }
 else   if (dtGrouping == DataType.TEXT_LITERAL) {
    groupTextually(workingResultSet,iSortColumnIndex,saExpressionKeys,iaGroupBreaks,null,sg.getGroupingInterval(),iafa);
  }
  initializeMeta();
}

Fixed version (ground truth):
/** 
 * Groups rows of data as specified in the grouping criteria for the series definition
 * @throws ChartException
 */
public void applyBaseSeriesSortingAndGrouping(SeriesDefinition sd,String[] saExpressionKeys) throws ChartException {
  if (bBaseGroupingApplied) {
    return;
  }
  bBaseGroupingApplied=true;
  boolean needBaseGrouping=true;
  final SeriesGrouping sg=sd.getGrouping();
  if (sg == null || !sg.isEnabled()) {
    needBaseGrouping=false;
    ;
  }
  final Series seBaseDesignTime=sd.getDesignTimeSeries();
  final Query q=(Query)seBaseDesignTime.getDataDefinition().get(0);
  final int iSortColumnIndex=((Integer)htLookup.get(q.getDefinition())).intValue();
  SortOption so=null;
  if (!sd.isSetSorting()) {
    if (needBaseGrouping) {
      so=SortOption.ASCENDING_LITERAL;
    }
  }
 else {
    so=sd.getSorting();
  }
  new GroupingSorter().sort(workingResultSet,iSortColumnIndex,so,iaGroupBreaks);
  if (!needBaseGrouping) {
    return;
  }
  final String sFunctionName=sg.getAggregateExpression();
  final int iOrthogonalSeriesCount=saExpressionKeys.length;
  IAggregateFunction[] iafa=new IAggregateFunction[iOrthogonalSeriesCount];
  try {
    for (int i=0; i < iOrthogonalSeriesCount; i++) {
      iafa[i]=PluginSettings.instance().getAggregateFunction(sFunctionName);
      iafa[i].initialize();
    }
  }
 catch (  ChartException pex) {
    throw new ChartException(ChartEnginePlugin.ID,ChartException.DATA_BINDING,pex);
  }
  final DataType dtGrouping=sg.getGroupType();
  if (dtGrouping == DataType.NUMERIC_LITERAL) {
    groupNumerically(workingResultSet,iSortColumnIndex,saExpressionKeys,iaGroupBreaks,null,sg.getGroupingInterval(),iafa);
  }
 else   if (dtGrouping == DataType.DATE_TIME_LITERAL) {
    groupDateTime(workingResultSet,iSortColumnIndex,saExpressionKeys,iaGroupBreaks,null,sg.getGroupingInterval(),sg.getGroupingUnit(),iafa);
  }
 else   if (dtGrouping == DataType.TEXT_LITERAL) {
    groupTextually(workingResultSet,iSortColumnIndex,saExpressionKeys,iaGroupBreaks,null,sg.getGroupingInterval(),iafa);
  }
  initializeMeta();
}