Program: 66704
Project: 66704
Buggy source:
private String getReplacedExpressionText(String text,Map measureMap,Map derivedMeasureMap,Map createdBindings,IBinding binding,List bindingsInCubeQuery) throws DataException {
  List measureNames=ExpressionCompilerUtil.extractColumnExpression(new ScriptExpression(text.substring(1,text.length() - 1)),ExpressionUtil.MEASURE_INDICATOR);
  for (int i=0; i < measureNames.size(); i++) {
    if (measureMap.containsKey(measureNames.get(i).toString())) {
      IBinding b=(IBinding)createdBindings.get(measureNames.get(i).toString());
      String bindingName=b.getBindingName();
      if (!Arrays.deepEquals(b.getAggregatOns().toArray(),binding.getAggregatOns().toArray())) {
        IBinding newBinding=new Binding(bindingName + "String_Node_Str" + binding.getBindingName());
        newBinding.setDataType(b.getDataType());
        newBinding.setAggrFunction(b.getAggrFunction());
        newBinding.setExpression(b.getExpression());
        newBinding.getAggregatOns().addAll(binding.getAggregatOns());
        IBinding sameBinding=getSameBindingInQuery(newBinding,bindingsInCubeQuery);
        if (sameBinding != null) {
          bindingName=sameBinding.getBindingName();
        }
 else {
          bindingName=newBinding.getBindingName();
          realBindings.add(newBinding);
        }
      }
      text=text.replace(ExpressionUtil.createJSMeasureExpression(measureNames.get(i).toString()),ExpressionUtil.createJSDataExpression(bindingName));
    }
 else     if (derivedMeasureMap.containsKey(measureNames.get(i).toString())) {
      text=text.replace(ExpressionUtil.createJSMeasureExpression(measureNames.get(i).toString()),"String_Node_Str" + ((ScriptExpression)((DerivedMeasureDefinition)derivedMeasureMap.get(measureNames.get(i).toString())).getExpression()).getText() + "String_Node_Str");
      text=getReplacedExpressionText(text,measureMap,derivedMeasureMap,createdBindings,binding,bindingsInCubeQuery);
    }
  }
  return text;
}

Fixed version (ground truth):
private String getReplacedExpressionText(String text,Map measureMap,Map derivedMeasureMap,Map createdBindings,IBinding binding,List bindingsInCubeQuery) throws DataException {
  List measureNames=ExpressionCompilerUtil.extractColumnExpression(new ScriptExpression(text.substring(1,text.length() - 1)),ExpressionUtil.MEASURE_INDICATOR);
  for (int i=0; i < measureNames.size(); i++) {
    if (measureMap.containsKey(measureNames.get(i).toString())) {
      IBinding b=(IBinding)createdBindings.get(measureNames.get(i).toString());
      String bindingName=b.getBindingName();
      if (!Arrays.deepEquals(b.getAggregatOns().toArray(),binding.getAggregatOns().toArray()) || b.getAggrFunction() != binding.getAggrFunction()) {
        IBinding newBinding=new Binding(bindingName + "String_Node_Str" + binding.getBindingName());
        newBinding.setDataType(b.getDataType());
        newBinding.setAggrFunction(binding.getAggrFunction());
        newBinding.setExpression(b.getExpression());
        newBinding.getAggregatOns().addAll(binding.getAggregatOns());
        IBinding sameBinding=getSameBindingInQuery(newBinding,bindingsInCubeQuery);
        if (sameBinding != null) {
          bindingName=sameBinding.getBindingName();
        }
 else {
          bindingName=newBinding.getBindingName();
          realBindings.add(newBinding);
        }
      }
      text=text.replace(ExpressionUtil.createJSMeasureExpression(measureNames.get(i).toString()),ExpressionUtil.createJSDataExpression(bindingName));
    }
 else     if (derivedMeasureMap.containsKey(measureNames.get(i).toString())) {
      text=text.replace(ExpressionUtil.createJSMeasureExpression(measureNames.get(i).toString()),"String_Node_Str" + ((ScriptExpression)((DerivedMeasureDefinition)derivedMeasureMap.get(measureNames.get(i).toString())).getExpression()).getText() + "String_Node_Str");
      text=getReplacedExpressionText(text,measureMap,derivedMeasureMap,createdBindings,binding,bindingsInCubeQuery);
    }
  }
  return text;
}