Program: 67583
Project: 67583
Buggy source:
/** 
 * Constructor.
 * @param resultIterator
 * @param hasAggregation
 * @param isSubQuery
 * @param cm
 * @throws ChartException
 * @since 2.3
 */
public BaseGroupedQueryResultSetEvaluator(IResultIterator resultIterator,boolean hasAggregation,boolean isSubQuery,Chart cm,ExtendedItemHandle handle) throws ChartException {
  fHasSummaryAggregation=hasAggregation;
  fResultIterator=resultIterator;
  if (isSubQuery) {
    List subQuerys=new ArrayList();
    Collection c=fResultIterator.getQueryResults().getPreparedQuery().getReportQueryDefn().getSubqueries();
    if (c != null && !c.isEmpty()) {
      subQuerys.addAll(c);
    }
    List groups=fResultIterator.getQueryResults().getPreparedQuery().getReportQueryDefn().getGroups();
    if (groups != null) {
      for (Iterator iter=groups.iterator(); iter.hasNext(); ) {
        c=((IGroupDefinition)iter.next()).getSubqueries();
        if (c != null && !c.isEmpty()) {
          subQuerys.addAll(c);
        }
      }
    }
    for (int i=0; i < subQuerys.size(); i++) {
      if ((ChartReportItemConstants.NAME_SUBQUERY + handle.getElement().getID()).equals(((ISubqueryDefinition)subQuerys.get(i)).getName())) {
        fGroupDefinitions=((ISubqueryDefinition)subQuerys.get(i)).getGroups();
        break;
      }
    }
    if (fGroupDefinitions == null) {
      fGroupDefinitions=fResultIterator.getQueryResults().getPreparedQuery().getReportQueryDefn().getGroups();
    }
  }
 else {
    fGroupDefinitions=fResultIterator.getQueryResults().getPreparedQuery().getReportQueryDefn().getGroups();
  }
  if (fGroupDefinitions != null && fGroupDefinitions.size() > 0) {
    fIsGrouped=true;
    fGroupCount=fGroupDefinitions.size();
    faGroupBreaks=new List[fGroupDefinitions.size()];
    for (int i=0; i < faGroupBreaks.length; i++) {
      faGroupBreaks[i]=new ArrayList<Integer>();
    }
    updateEnabledGroupIndexes(cm,fGroupDefinitions);
  }
}

Fixed version (ground truth):
/** 
 * Constructor.
 * @param resultIterator
 * @param hasAggregation
 * @param isSubQuery
 * @param cm
 * @throws ChartException
 * @since 2.3
 */
public BaseGroupedQueryResultSetEvaluator(IResultIterator resultIterator,boolean hasAggregation,boolean isSubQuery,Chart cm,ExtendedItemHandle handle) throws ChartException {
  fHasSummaryAggregation=hasAggregation;
  itemHandle=handle;
  fResultIterator=resultIterator;
  if (isSubQuery) {
    List subQuerys=new ArrayList();
    Collection c=fResultIterator.getQueryResults().getPreparedQuery().getReportQueryDefn().getSubqueries();
    if (c != null && !c.isEmpty()) {
      subQuerys.addAll(c);
    }
    List groups=fResultIterator.getQueryResults().getPreparedQuery().getReportQueryDefn().getGroups();
    if (groups != null) {
      for (Iterator iter=groups.iterator(); iter.hasNext(); ) {
        c=((IGroupDefinition)iter.next()).getSubqueries();
        if (c != null && !c.isEmpty()) {
          subQuerys.addAll(c);
        }
      }
    }
    for (int i=0; i < subQuerys.size(); i++) {
      if ((ChartReportItemConstants.NAME_SUBQUERY + handle.getElement().getID()).equals(((ISubqueryDefinition)subQuerys.get(i)).getName())) {
        fGroupDefinitions=((ISubqueryDefinition)subQuerys.get(i)).getGroups();
        break;
      }
    }
    if (fGroupDefinitions == null) {
      fGroupDefinitions=fResultIterator.getQueryResults().getPreparedQuery().getReportQueryDefn().getGroups();
    }
  }
 else {
    fGroupDefinitions=fResultIterator.getQueryResults().getPreparedQuery().getReportQueryDefn().getGroups();
  }
  if (fGroupDefinitions != null && fGroupDefinitions.size() > 0) {
    fIsGrouped=true;
    fGroupCount=fGroupDefinitions.size();
    faGroupBreaks=new List[fGroupDefinitions.size()];
    for (int i=0; i < faGroupBreaks.length; i++) {
      faGroupBreaks[i]=new ArrayList<Integer>();
    }
    updateEnabledGroupIndexes(cm,fGroupDefinitions);
  }
}