Program: 68106
Project: 68106
Buggy source:
/** 
 * Generates extra bindings for grouping and complex expressions. In addition, add them into query definition.
 * @param query
 * @throws ChartException
 */
protected void generateExtraBindings(BaseQueryDefinition query) throws ChartException {
  SeriesDefinition categorySD=null;
  SeriesDefinition orthSD=null;
  Axis[] orthAxisArray=null;
  if (fChartModel instanceof ChartWithAxes) {
    ChartWithAxes cwa=(ChartWithAxes)fChartModel;
    categorySD=cwa.getBaseAxes()[0].getSeriesDefinitions().get(0);
    orthAxisArray=cwa.getOrthogonalAxes(cwa.getBaseAxes()[0],true);
    orthSD=orthAxisArray[0].getSeriesDefinitions().get(0);
  }
 else   if (fChartModel instanceof ChartWithoutAxes) {
    ChartWithoutAxes cwoa=(ChartWithoutAxes)fChartModel;
    categorySD=cwoa.getSeriesDefinitions().get(0);
    orthSD=categorySD.getSeriesDefinitions().get(0);
  }
  initYGroupingNSortKey(query,categorySD,orthSD,orthAxisArray);
  GroupDefinition categoryGroupDefinition=initCategoryGrouping(query,categorySD);
  Map<String,String[]> valueExprMap=addAggregateBindings(query,categorySD,orthAxisArray);
  if (bCreateBindingForExpression) {
    String exprCategory=(categorySD.getDesignTimeSeries().getDataDefinition().get(0)).getDefinition();
    String exprYGroup=orthSD.getQuery().getDefinition();
    try {
      exprCodec.decode(exprCategory);
      if (!exprCodec.isRowBinding(false)) {
        addExtraBinding(query,exprCodec);
      }
      exprCodec.decode(exprYGroup);
      if (!exprCodec.isRowBinding(false)) {
        addExtraBinding(query,exprCodec);
      }
      if (query instanceof ISubqueryDefinition) {
        ChartReportItemUtil.copyAndInsertBindingFromContainer((ISubqueryDefinition)query,exprCategory);
        ChartReportItemUtil.copyAndInsertBindingFromContainer((ISubqueryDefinition)query,exprYGroup);
        if (!categorySD.getGrouping().isEnabled()) {
          for (          SeriesDefinition sd : ChartUtil.getAllOrthogonalSeriesDefinitions(fChartModel)) {
            List<Query> queries=sd.getDesignTimeSeries().getDataDefinition();
            for (            Query queryExpr : queries) {
              ChartReportItemUtil.copyAndInsertBindingFromContainer((ISubqueryDefinition)query,queryExpr.getDefinition());
            }
          }
        }
      }
    }
 catch (    DataException e) {
      throw new ChartException(ChartReportItemPlugin.ID,ChartException.DATA_BINDING,e);
    }
  }
  if (categorySD != null) {
    bindSortOnCategorySeries(query,categorySD,categoryGroupDefinition,valueExprMap);
  }
}

Fixed version (ground truth):
/** 
 * Generates extra bindings for grouping and complex expressions. In addition, add them into query definition.
 * @param query
 * @throws ChartException
 */
protected void generateExtraBindings(BaseQueryDefinition query) throws ChartException {
  SeriesDefinition categorySD=null;
  SeriesDefinition orthSD=null;
  Axis[] orthAxisArray=null;
  if (fChartModel instanceof ChartWithAxes) {
    ChartWithAxes cwa=(ChartWithAxes)fChartModel;
    categorySD=cwa.getBaseAxes()[0].getSeriesDefinitions().get(0);
    orthAxisArray=cwa.getOrthogonalAxes(cwa.getBaseAxes()[0],true);
    orthSD=orthAxisArray[0].getSeriesDefinitions().get(0);
  }
 else   if (fChartModel instanceof ChartWithoutAxes) {
    ChartWithoutAxes cwoa=(ChartWithoutAxes)fChartModel;
    categorySD=cwoa.getSeriesDefinitions().get(0);
    orthSD=categorySD.getSeriesDefinitions().get(0);
  }
  initYGroupingNSortKey(query,categorySD,orthSD,orthAxisArray);
  GroupDefinition categoryGroupDefinition=initCategoryGrouping(query,categorySD);
  Map<String,String[]> valueExprMap=addAggregateBindings(query,categorySD,orthAxisArray);
  if (bCreateBindingForExpression) {
    String exprCategory=(categorySD.getDesignTimeSeries().getDataDefinition().get(0)).getDefinition();
    String exprYGroup=orthSD.getQuery().getDefinition();
    try {
      exprCodec.decode(exprCategory);
      if (!exprCodec.isRowBinding(false)) {
        addExtraBinding(query,exprCodec);
      }
      exprCodec.decode(exprYGroup);
      if (!exprCodec.isRowBinding(false)) {
        addExtraBinding(query,exprCodec);
      }
      if (query instanceof ISubqueryDefinition) {
        ChartReportItemUtil.copyAndInsertBindingFromContainer((ISubqueryDefinition)query,exprCategory);
        ChartReportItemUtil.copyAndInsertBindingFromContainer((ISubqueryDefinition)query,exprYGroup);
        if (!categorySD.getGrouping().isEnabled()) {
          for (          SeriesDefinition sd : ChartUtil.getAllOrthogonalSeriesDefinitions(fChartModel)) {
            List<Query> queries=sd.getDesignTimeSeries().getDataDefinition();
            for (            Query queryExpr : queries) {
              ChartReportItemUtil.copyAndInsertBindingFromContainer((ISubqueryDefinition)query,queryExpr.getDefinition());
            }
          }
        }
      }
    }
 catch (    DataException e) {
      throw new ChartException(ChartReportItemPlugin.ID,ChartException.DATA_BINDING,e);
    }
  }
  if (categorySD != null) {
    bindSortOnCategorySeries(query,categorySD,categoryGroupDefinition,valueExprMap,orthAxisArray);
  }
}