Program: 66078
Project: 66078
Buggy source:
private void populateMeasureDefinitionForCalculateMeasures(ICubeQueryDefinition query) throws DataException, AdapterException {
  List calculatedMeasures=query.getDerivedMeasures();
  if (calculatedMeasures == null || calculatedMeasures.size() == 0)   return;
  List measures=query.getMeasures();
  List measureNameList=new ArrayList();
  for (int i=0; i < measures.size(); i++) {
    measureNameList.add(((IMeasureDefinition)measures.get(i)).getName());
  }
  List derivedMeasureNameList=new ArrayList();
  for (int i=0; i < calculatedMeasures.size(); i++) {
    derivedMeasureNameList.add(((IDerivedMeasureDefinition)calculatedMeasures.get(i)).getName());
  }
  for (int i=0; i < calculatedMeasures.size(); i++) {
    IDerivedMeasureDefinition dmd=(IDerivedMeasureDefinition)calculatedMeasures.get(i);
    List measureNames=ExpressionCompilerUtil.extractColumnExpression(dmd.getExpression(),ExpressionUtil.MEASURE_INDICATOR);
    for (int j=0; j < measureNames.size(); j++) {
      if (!measureNameList.contains(measureNames.get(j).toString()) && !derivedMeasureNameList.contains(measureNames.get(j).toString())) {
        IMeasureDefinition md=query.createMeasure(measureNames.get(j).toString());
        if (this.cubeHandleMap != null && this.cubeHandleMap.containsKey(query.getName())) {
          CubeHandle cubeHandle=(CubeHandle)this.cubeHandleMap.get(query.getName());
          MeasureHandle measureHandle=cubeHandle.getMeasure(measureNames.get(j).toString());
          md.setAggrFunction(DataAdapterUtil.adaptModelAggregationType(measureHandle.getFunction()));
        }
      }
    }
  }
}

Fixed version (ground truth):
private void populateMeasureDefinitionForCalculateMeasures(ICubeQueryDefinition query) throws DataException, AdapterException {
  List calculatedMeasures=query.getDerivedMeasures();
  if (calculatedMeasures == null || calculatedMeasures.size() == 0)   return;
  List measures=query.getMeasures();
  List measureNameList=new ArrayList();
  for (int i=0; i < measures.size(); i++) {
    measureNameList.add(((IMeasureDefinition)measures.get(i)).getName());
  }
  List derivedMeasureNameList=new ArrayList();
  for (int i=0; i < calculatedMeasures.size(); i++) {
    derivedMeasureNameList.add(((IDerivedMeasureDefinition)calculatedMeasures.get(i)).getName());
  }
  for (int i=0; i < calculatedMeasures.size(); i++) {
    IDerivedMeasureDefinition dmd=(IDerivedMeasureDefinition)calculatedMeasures.get(i);
    List measureNames=ExpressionCompilerUtil.extractColumnExpression(dmd.getExpression(),ExpressionUtil.MEASURE_INDICATOR);
    for (int j=0; j < measureNames.size(); j++) {
      if (!measureNameList.contains(measureNames.get(j).toString()) && !derivedMeasureNameList.contains(measureNames.get(j).toString())) {
        IMeasureDefinition md=query.createMeasure(measureNames.get(j).toString());
        if (this.cubeMetaDataHandleMap != null && this.cubeMetaDataHandleMap.containsKey(query.getName())) {
          CubeHandle cubeHandle=(CubeHandle)this.cubeMetaDataHandleMap.get(query.getName());
          MeasureHandle measureHandle=cubeHandle.getMeasure(measureNames.get(j).toString());
          md.setAggrFunction(DataAdapterUtil.adaptModelAggregationType(measureHandle.getFunction()));
        }
      }
    }
  }
}