Program: 73198
Project: 73198
Buggy source:
private void addLookupForOrthogonalSeries(SeriesDefinition baseSD,EList lstOrthogonalSDs,IActionEvaluator iae) throws ChartException {
  for (int k=0; k < lstOrthogonalSDs.size(); k++) {
    SeriesDefinition orthoSD=(SeriesDefinition)lstOrthogonalSDs.get(k);
    Query qOrthogonalSeriesDefinition=orthoSD.getQuery();
    if (qOrthogonalSeriesDefinition == null) {
      return;
    }
    String strOrthoAgg=getOrthogonalAggregationExpression(orthoSD);
    if (addDataExp(qOrthogonalSeriesDefinition.getDefinition(),strOrthoAgg)) {
      addDataExpForAggregate(qOrthogonalSeriesDefinition.getDefinition());
    }
    String ySortKey=getSortKey(orthoSD);
    Series seOrthogonal=orthoSD.getDesignTimeSeries();
    EList elOrthogonalSeries=seOrthogonal.getDataDefinition();
    if (elOrthogonalSeries.isEmpty()) {
      throw new ChartException(ChartEnginePlugin.ID,ChartException.DATA_BINDING,"String_Node_Str",new Object[]{String.valueOf(k),seOrthogonal},Messages.getResourceBundle(this.locale));
    }
    boolean bAnyQueries=false;
    for (int i=0; i < elOrthogonalSeries.size(); i++) {
      Query qOrthogonalSeries=(Query)elOrthogonalSeries.get(i);
      if (qOrthogonalSeries == null) {
        continue;
      }
      if (addDataExp(qOrthogonalSeries.getDefinition(),strOrthoAgg)) {
        addDataExpForAggregate(ChartUtil.createValueSeriesRowFullExpression(qOrthogonalSeries.getDefinition(),orthoSD,baseSD));
        bAnyQueries=true;
        if (fBaseSortExprIndex < 0) {
          String sortExpr=getSortKey(baseSD);
          if (sortExpr != null && sortExpr.equals(qOrthogonalSeries.getDefinition()) && baseSD.eIsSet(DataPackage.eINSTANCE.getSeriesDefinition_Sorting())) {
            fBaseSortExprIndex=findIndex(qOrthogonalSeries.getDefinition(),strOrthoAgg);
          }
        }
        if (fYSortExprIndex < 0) {
          if (ySortKey != null && ySortKey.equals(qOrthogonalSeries.getDefinition()) && orthoSD.eIsSet(DataPackage.eINSTANCE.getSeriesDefinition_Sorting())) {
            fYSortExprIndex=findIndex(qOrthogonalSeries.getDefinition(),strOrthoAgg);
          }
        }
      }
    }
    if (!bAnyQueries) {
      throw new ChartException(ChartEnginePlugin.ID,ChartException.DATA_BINDING,"String_Node_Str",new Object[]{String.valueOf(k),seOrthogonal},Messages.getResourceBundle(this.locale));
    }
    String[] triggerExprs=DataProcessor.getSeriesTriggerExpressions(seOrthogonal,iae);
    if (triggerExprs != null) {
      for (int t=0; t < triggerExprs.length; t++) {
        if (addDataExp(triggerExprs[t],strOrthoAgg)) {
          addDataExpForAggregate(triggerExprs[t]);
        }
      }
    }
  }
}

Fixed version (ground truth):
private void addLookupForOrthogonalSeries(SeriesDefinition baseSD,EList lstOrthogonalSDs,IActionEvaluator iae) throws ChartException {
  for (int k=0; k < lstOrthogonalSDs.size(); k++) {
    SeriesDefinition orthoSD=(SeriesDefinition)lstOrthogonalSDs.get(k);
    Query qOrthogonalSeriesDefinition=orthoSD.getQuery();
    if (qOrthogonalSeriesDefinition == null) {
      return;
    }
    String strOrthoAgg=getOrthogonalAggregationExpression(orthoSD);
    if (addDataExp(qOrthogonalSeriesDefinition.getDefinition(),strOrthoAgg)) {
      addDataExpForAggregate(qOrthogonalSeriesDefinition.getDefinition(),strOrthoAgg);
    }
    String ySortKey=getSortKey(orthoSD);
    Series seOrthogonal=orthoSD.getDesignTimeSeries();
    EList elOrthogonalSeries=seOrthogonal.getDataDefinition();
    if (elOrthogonalSeries.isEmpty()) {
      throw new ChartException(ChartEnginePlugin.ID,ChartException.DATA_BINDING,"String_Node_Str",new Object[]{String.valueOf(k),seOrthogonal},Messages.getResourceBundle(this.locale));
    }
    boolean bAnyQueries=false;
    for (int i=0; i < elOrthogonalSeries.size(); i++) {
      Query qOrthogonalSeries=(Query)elOrthogonalSeries.get(i);
      if (qOrthogonalSeries == null) {
        continue;
      }
      if (addDataExp(qOrthogonalSeries.getDefinition(),strOrthoAgg)) {
        addDataExpForAggregate(ChartUtil.createValueSeriesRowFullExpression(qOrthogonalSeries.getDefinition(),orthoSD,baseSD),strOrthoAgg);
        bAnyQueries=true;
        if (fBaseSortExprIndex < 0) {
          String sortExpr=getSortKey(baseSD);
          if (sortExpr != null && sortExpr.equals(qOrthogonalSeries.getDefinition()) && baseSD.eIsSet(DataPackage.eINSTANCE.getSeriesDefinition_Sorting())) {
            fBaseSortExprIndex=findIndex(qOrthogonalSeries.getDefinition(),strOrthoAgg);
          }
        }
        if (fYSortExprIndex < 0) {
          if (ySortKey != null && ySortKey.equals(qOrthogonalSeries.getDefinition()) && orthoSD.eIsSet(DataPackage.eINSTANCE.getSeriesDefinition_Sorting())) {
            fYSortExprIndex=findIndex(qOrthogonalSeries.getDefinition(),strOrthoAgg);
          }
        }
      }
    }
    if (!bAnyQueries) {
      throw new ChartException(ChartEnginePlugin.ID,ChartException.DATA_BINDING,"String_Node_Str",new Object[]{String.valueOf(k),seOrthogonal},Messages.getResourceBundle(this.locale));
    }
    String[] triggerExprs=DataProcessor.getSeriesTriggerExpressions(seOrthogonal,iae);
    if (triggerExprs != null) {
      for (int t=0; t < triggerExprs.length; t++) {
        if (addDataExp(triggerExprs[t],strOrthoAgg)) {
          addDataExpForAggregate(triggerExprs[t],strOrthoAgg);
        }
      }
    }
  }
}