Program: 68729
Project: 68729
Buggy source:
private static List<IBinding> getQueryBindings(CrosstabReportItemHandle crosstabItem) throws BirtException {
  List<String> rowLevelNameList=new ArrayList<String>();
  List<String> columnLevelNameList=new ArrayList<String>();
  if (crosstabItem.getDimensionCount(ICrosstabConstants.ROW_AXIS_TYPE) > 0) {
    for (int i=0; i < crosstabItem.getDimensionCount(ICrosstabConstants.ROW_AXIS_TYPE); i++) {
      DimensionViewHandle dv=crosstabItem.getDimension(ICrosstabConstants.ROW_AXIS_TYPE,i);
      if (dv.getCubeDimension() == null) {
        throw new CrosstabException(dv.getModelHandle().getElement(),Messages.getString("String_Node_Str",dv.getCubeDimensionName()));
      }
      for (int j=0; j < dv.getLevelCount(); j++) {
        LevelViewHandle lv=dv.getLevel(j);
        if (lv.getCubeLevel() == null) {
          throw new CrosstabException(lv.getModelHandle().getElement(),Messages.getString("String_Node_Str",lv.getCubeLevelName()));
        }
        rowLevelNameList.add(lv.getCubeLevel().getFullName());
      }
    }
  }
  if (crosstabItem.getDimensionCount(ICrosstabConstants.COLUMN_AXIS_TYPE) > 0) {
    for (int i=0; i < crosstabItem.getDimensionCount(ICrosstabConstants.COLUMN_AXIS_TYPE); i++) {
      DimensionViewHandle dv=crosstabItem.getDimension(ICrosstabConstants.COLUMN_AXIS_TYPE,i);
      if (dv.getCubeDimension() == null) {
        throw new CrosstabException(dv.getModelHandle().getElement(),Messages.getString("String_Node_Str",dv.getCubeDimensionName()));
      }
      for (int j=0; j < dv.getLevelCount(); j++) {
        LevelViewHandle lv=dv.getLevel(j);
        if (lv.getCubeLevel() == null) {
          throw new CrosstabException(lv.getModelHandle().getElement(),Messages.getString("String_Node_Str",lv.getCubeLevelName()));
        }
        columnLevelNameList.add(lv.getCubeLevel().getFullName());
      }
    }
  }
  List<IBinding> bindingList=new ArrayList<IBinding>();
  Iterator bindingItr=((ExtendedItemHandle)crosstabItem.getModelHandle()).columnBindingsIterator();
  ModuleHandle module=((ExtendedItemHandle)crosstabItem.getModelHandle()).getModuleHandle();
  if (bindingItr != null) {
    Map<String,String> cache=new HashMap<String,String>();
    DataRequestSession session=DataRequestSession.newSession(new DataSessionContext(DataSessionContext.MODE_DIRECT_PRESENTATION));
    try {
      IModelAdapter modelAdapter=session.getModelAdaptor();
      while (bindingItr.hasNext()) {
        ComputedColumnHandle column=(ComputedColumnHandle)bindingItr.next();
        Binding binding=new Binding(column.getName());
        binding.setAggrFunction(column.getAggregateFunction() == null ? null : DataAdapterUtil.adaptModelAggregationType(column.getAggregateFunction()));
        binding.setExpression(modelAdapter.adaptExpression((Expression)column.getExpressionProperty(ComputedColumn.EXPRESSION_MEMBER).getValue()));
        binding.setDataType(DataAdapterUtil.adaptModelDataType(column.getDataType()));
        if (column.getFilterExpression() != null) {
          binding.setFilter(modelAdapter.adaptExpression((Expression)column.getExpressionProperty(ComputedColumn.FILTER_MEMBER).getValue()));
        }
        for (Iterator argItr=column.argumentsIterator(); argItr.hasNext(); ) {
          AggregationArgumentHandle aah=(AggregationArgumentHandle)argItr.next();
          binding.addArgument(modelAdapter.adaptExpression((Expression)aah.getExpressionProperty(AggregationArgument.VALUE_MEMBER).getValue()));
        }
        List aggrList=column.getAggregateOnList();
        if (aggrList != null) {
          for (Iterator aggrItr=aggrList.iterator(); aggrItr.hasNext(); ) {
            String baseLevel=(String)aggrItr.next();
            addHierachyAggregateOn(module,binding,baseLevel,rowLevelNameList,columnLevelNameList,cache);
          }
        }
        bindingList.add(binding);
      }
    }
  finally {
      session.shutdown();
    }
  }
  return bindingList;
}

Fixed version (ground truth):
private static List<IBinding> getQueryBindings(CrosstabReportItemHandle crosstabItem) throws BirtException {
  List<String> rowLevelNameList=new ArrayList<String>();
  List<String> columnLevelNameList=new ArrayList<String>();
  if (crosstabItem.getDimensionCount(ICrosstabConstants.ROW_AXIS_TYPE) > 0) {
    for (int i=0; i < crosstabItem.getDimensionCount(ICrosstabConstants.ROW_AXIS_TYPE); i++) {
      DimensionViewHandle dv=crosstabItem.getDimension(ICrosstabConstants.ROW_AXIS_TYPE,i);
      if (dv.getCubeDimension() == null) {
        throw new CrosstabException(dv.getModelHandle().getElement(),Messages.getString("String_Node_Str",dv.getCubeDimensionName()));
      }
      for (int j=0; j < dv.getLevelCount(); j++) {
        LevelViewHandle lv=dv.getLevel(j);
        if (lv.getCubeLevel() == null) {
          throw new CrosstabException(lv.getModelHandle().getElement(),Messages.getString("String_Node_Str",lv.getCubeLevelName()));
        }
        rowLevelNameList.add(lv.getCubeLevel().getFullName());
      }
    }
  }
  if (crosstabItem.getDimensionCount(ICrosstabConstants.COLUMN_AXIS_TYPE) > 0) {
    for (int i=0; i < crosstabItem.getDimensionCount(ICrosstabConstants.COLUMN_AXIS_TYPE); i++) {
      DimensionViewHandle dv=crosstabItem.getDimension(ICrosstabConstants.COLUMN_AXIS_TYPE,i);
      if (dv.getCubeDimension() == null) {
        throw new CrosstabException(dv.getModelHandle().getElement(),Messages.getString("String_Node_Str",dv.getCubeDimensionName()));
      }
      for (int j=0; j < dv.getLevelCount(); j++) {
        LevelViewHandle lv=dv.getLevel(j);
        if (lv.getCubeLevel() == null) {
          throw new CrosstabException(lv.getModelHandle().getElement(),Messages.getString("String_Node_Str",lv.getCubeLevelName()));
        }
        columnLevelNameList.add(lv.getCubeLevel().getFullName());
      }
    }
  }
  List<IBinding> bindingList=new ArrayList<IBinding>();
  Iterator bindingItr=((ExtendedItemHandle)crosstabItem.getModelHandle()).columnBindingsIterator();
  ModuleHandle module=((ExtendedItemHandle)crosstabItem.getModelHandle()).getModuleHandle();
  if (bindingItr != null) {
    Map<String,String> cache=new HashMap<String,String>();
    DataRequestSession session=DataRequestSession.newSession(new DataSessionContext(DataSessionContext.MODE_DIRECT_PRESENTATION));
    try {
      IModelAdapter modelAdapter=session.getModelAdaptor();
      while (bindingItr.hasNext()) {
        ComputedColumnHandle column=(ComputedColumnHandle)bindingItr.next();
        Binding binding=new Binding(column.getName());
        binding.setAggrFunction(column.getAggregateFunction() == null ? null : DataAdapterUtil.adaptModelAggregationType(column.getAggregateFunction()));
        binding.setExpression(modelAdapter.adaptExpression((Expression)column.getExpressionProperty(ComputedColumn.EXPRESSION_MEMBER).getValue(),ExpressionLocation.CUBE));
        binding.setDataType(DataAdapterUtil.adaptModelDataType(column.getDataType()));
        if (column.getFilterExpression() != null) {
          binding.setFilter(modelAdapter.adaptExpression((Expression)column.getExpressionProperty(ComputedColumn.FILTER_MEMBER).getValue(),ExpressionLocation.CUBE));
        }
        for (Iterator argItr=column.argumentsIterator(); argItr.hasNext(); ) {
          AggregationArgumentHandle aah=(AggregationArgumentHandle)argItr.next();
          binding.addArgument(modelAdapter.adaptExpression((Expression)aah.getExpressionProperty(AggregationArgument.VALUE_MEMBER).getValue(),ExpressionLocation.CUBE));
        }
        List aggrList=column.getAggregateOnList();
        if (aggrList != null) {
          for (Iterator aggrItr=aggrList.iterator(); aggrItr.hasNext(); ) {
            String baseLevel=(String)aggrItr.next();
            addHierachyAggregateOn(module,binding,baseLevel,rowLevelNameList,columnLevelNameList,cache);
          }
        }
        bindingList.add(binding);
      }
    }
  finally {
      session.shutdown();
    }
  }
  return bindingList;
}