Program: 68786
Project: 68786
Buggy source:
/** 
 * @param cubeHandle
 * @param query
 * @param resultMetaList
 * @throws DataException 
 * @throws AdapterException 
 */
private static void prepareMeasure(TabularCubeHandle cubeHandle,QueryDefinition query,List metaList) throws AdapterException {
  try {
    List measureGroups=cubeHandle.getContents(CubeHandle.MEASURE_GROUPS_PROP);
    for (int i=0; i < measureGroups.size(); i++) {
      MeasureGroupHandle mgh=(MeasureGroupHandle)measureGroups.get(i);
      List measures=mgh.getContents(MeasureGroupHandle.MEASURES_PROP);
      for (int j=0; j < measures.size(); j++) {
        MeasureHandle measure=(MeasureHandle)measures.get(j);
        String function=measure.getFunction();
        String exprText=measure.getMeasureExpression();
        IScriptExpression expr=exprText != null ? new ScriptExpression(exprText) : null;
        if (query.getGroups().size() > 0) {
          Binding binding=new Binding(measure.getName(),expr);
          binding.setAggrFunction(DataAdapterUtil.adaptModelAggregationType(function));
          IGroupDefinition group=(IGroupDefinition)query.getGroups().get(query.getGroups().size() - 1);
          binding.addAggregateOn(group.getName());
          query.addBinding(binding);
        }
 else {
          query.addBinding(new Binding(measure.getName(),expr));
        }
        DataSetIterator.ColumnMeta meta=new DataSetIterator.ColumnMeta(measure.getName(),null,DataSetIterator.ColumnMeta.MEASURE_TYPE);
        meta.setDataType(DataAdapterUtil.adaptModelDataType(measure.getDataType()));
        metaList.add(meta);
      }
    }
  }
 catch (  DataException e) {
    throw new AdapterException(e.getLocalizedMessage(),e);
  }
}

Fixed version (ground truth):
/** 
 * @param cubeHandle
 * @param query
 * @param resultMetaList
 * @throws DataException 
 * @throws AdapterException 
 */
private void prepareMeasure(TabularCubeHandle cubeHandle,QueryDefinition query,List metaList) throws AdapterException {
  try {
    List measureGroups=cubeHandle.getContents(CubeHandle.MEASURE_GROUPS_PROP);
    for (int i=0; i < measureGroups.size(); i++) {
      MeasureGroupHandle mgh=(MeasureGroupHandle)measureGroups.get(i);
      List measures=mgh.getContents(MeasureGroupHandle.MEASURES_PROP);
      for (int j=0; j < measures.size(); j++) {
        MeasureHandle measure=(MeasureHandle)measures.get(j);
        String function=measure.getFunction();
        String exprText=measure.getMeasureExpression();
        ExpressionHandle measureExprHandle=measure.getExpressionProperty(IMeasureModel.MEASURE_EXPRESSION_PROP);
        IScriptExpression expr=null;
        if (exprText != null && measureExprHandle != null) {
          expr=modelAdaptor.adaptJSExpression(measureExprHandle.getStringExpression(),measureExprHandle.getType());
        }
        if (query.getGroups().size() > 0) {
          Binding binding=new Binding(measure.getName(),expr);
          binding.setAggrFunction(DataAdapterUtil.adaptModelAggregationType(function));
          IGroupDefinition group=(IGroupDefinition)query.getGroups().get(query.getGroups().size() - 1);
          binding.addAggregateOn(group.getName());
          query.addBinding(binding);
        }
 else {
          query.addBinding(new Binding(measure.getName(),expr));
        }
        DataSetIterator.ColumnMeta meta=new DataSetIterator.ColumnMeta(measure.getName(),null,DataSetIterator.ColumnMeta.MEASURE_TYPE);
        meta.setDataType(DataAdapterUtil.adaptModelDataType(measure.getDataType()));
        metaList.add(meta);
      }
    }
  }
 catch (  DataException e) {
    throw new AdapterException(e.getLocalizedMessage(),e);
  }
}