Program: 74777
Project: 74777
Buggy source:
public List getReferencedLevels(String targetLevel,String bindingExpr,ICubeQueryDefinition queryDefn) throws AdapterException {
  try {
    List result=new ArrayList();
    DimLevel target=OlapExpressionUtil.getTargetDimLevel(targetLevel);
    String bindingName=OlapExpressionCompiler.getReferencedScriptObject(bindingExpr,"String_Node_Str");
    if (bindingName == null)     return result;
    IBinding binding=null;
    List bindings=queryDefn.getBindings();
    for (int i=0; i < bindings.size(); i++) {
      IBinding bd=(IBinding)bindings.get(i);
      if (bd.getBindingName().equals(bindingName)) {
        binding=bd;
        break;
      }
    }
    if (binding == null) {
      return result;
    }
    List aggrOns=binding.getAggregatOns();
    boolean isMeasure=false;
    if (aggrOns.size() == 0) {
      isMeasure=this.getReferencedMeasureName(binding.getExpression()) != null;
    }
    IEdgeDefinition axisQualifierEdge=queryDefn.getEdge(this.getAxisQualifierEdgeType(target,queryDefn));
    if (isMeasure) {
      for (int i=0; i < axisQualifierEdge.getDimensions().size(); i++) {
        IHierarchyDefinition hier=(IHierarchyDefinition)((IDimensionDefinition)axisQualifierEdge.getDimensions().get(i)).getHierarchy().get(0);
        result.addAll(hier.getLevels());
      }
    }
 else {
      for (int i=0; i < aggrOns.size(); i++) {
        DimLevel dimLevel=OlapExpressionUtil.getTargetDimLevel(aggrOns.get(i).toString());
        ILevelDefinition lvl=getAxisQualifierLevel(dimLevel,axisQualifierEdge);
        if (lvl != null)         result.add(lvl);
      }
    }
    return result;
  }
 catch (  DataException e) {
    throw new AdapterException(e.getLocalizedMessage(),e);
  }
}

Fixed version (ground truth):
public List getReferencedLevels(String targetLevel,String bindingExpr,ICubeQueryDefinition queryDefn) throws AdapterException {
  try {
    List result=new ArrayList();
    DimLevel target=OlapExpressionUtil.getTargetDimLevel(targetLevel);
    String bindingName=OlapExpressionCompiler.getReferencedScriptObject(bindingExpr,"String_Node_Str");
    if (bindingName == null)     return result;
    IBinding binding=null;
    List bindings=queryDefn.getBindings();
    for (int i=0; i < bindings.size(); i++) {
      IBinding bd=(IBinding)bindings.get(i);
      if (bd.getBindingName().equals(bindingName)) {
        binding=bd;
        break;
      }
    }
    if (binding == null) {
      return result;
    }
    List aggrOns=binding.getAggregatOns();
    boolean isMeasure=false;
    if (aggrOns.size() == 0) {
      isMeasure=this.getReferencedMeasureName(binding.getExpression()) != null;
    }
    int candidateEdge=this.getAxisQualifierEdgeType(target,queryDefn);
    if (candidateEdge == -1)     return result;
    IEdgeDefinition axisQualifierEdge=queryDefn.getEdge(candidateEdge);
    if (isMeasure) {
      for (int i=0; i < axisQualifierEdge.getDimensions().size(); i++) {
        IHierarchyDefinition hier=(IHierarchyDefinition)((IDimensionDefinition)axisQualifierEdge.getDimensions().get(i)).getHierarchy().get(0);
        result.addAll(hier.getLevels());
      }
    }
 else {
      for (int i=0; i < aggrOns.size(); i++) {
        DimLevel dimLevel=OlapExpressionUtil.getTargetDimLevel(aggrOns.get(i).toString());
        ILevelDefinition lvl=getAxisQualifierLevel(dimLevel,axisQualifierEdge);
        if (lvl != null)         result.add(lvl);
      }
    }
    return result;
  }
 catch (  DataException e) {
    throw new AdapterException(e.getLocalizedMessage(),e);
  }
}