Program: 73972
Project: 73972
Buggy source:
/** 
 * Valid bindings, return a list of invalid binding.
 * @param queryDefn
 * @param suppressException
 * @return
 * @throws DataException
 */
public static List validateBinding(ICubeQueryDefinition queryDefn,boolean suppressException) throws DataException {
  List result=new ArrayList();
  Set validDimLevels=new HashSet();
  populateLevel(queryDefn,validDimLevels,ICubeQueryDefinition.COLUMN_EDGE);
  populateLevel(queryDefn,validDimLevels,ICubeQueryDefinition.ROW_EDGE);
  for (int i=0; i < queryDefn.getBindings().size(); i++) {
    boolean isValid=true;
    IBinding binding=(IBinding)queryDefn.getBindings().get(i);
    if (binding.getAggrFunction() != null && binding.getExpression() instanceof IScriptExpression) {
      String expr=((IScriptExpression)binding.getExpression()).getText();
      if (expr == null && (AggregationFactory.getInstance().getAggrInfo(binding.getAggrFunction()) != null && !AggregationFactory.getInstance().getAggrInfo(binding.getAggrFunction()).needDataField()))       continue;
    }
    Set levels=OlapExpressionCompiler.getReferencedDimLevel(binding.getExpression(),queryDefn.getBindings());
    if (!validDimLevels.containsAll(levels)) {
      isValid=false;
      if (!suppressException)       throw new DataException(ResourceConstants.INVALID_BINDING_REFER_TO_INEXIST_DIMENSION,binding.getBindingName());
    }
    if ((binding.getAggregatOns().size() > 0 && binding.getAggrFunction() == null)) {
      isValid=false;
      if (!suppressException)       throw new DataException(ResourceConstants.INVALID_BINDING_MISSING_AGGR_FUNC,binding.getBindingName());
    }
    if (!isValid)     result.add(binding);
  }
  return result;
}

Fixed version (ground truth):
/** 
 * Valid bindings, return a list of invalid binding.
 * @param queryDefn
 * @param suppressException
 * @return
 * @throws DataException
 */
public static List validateBinding(ICubeQueryDefinition queryDefn,boolean suppressException) throws DataException {
  List result=new ArrayList();
  Set validDimLevels=new HashSet();
  populateLevel(queryDefn,validDimLevels,ICubeQueryDefinition.COLUMN_EDGE);
  populateLevel(queryDefn,validDimLevels,ICubeQueryDefinition.ROW_EDGE);
  for (int i=0; i < queryDefn.getBindings().size(); i++) {
    boolean isValid=true;
    IBinding binding=(IBinding)queryDefn.getBindings().get(i);
    if (binding.getAggrFunction() != null && binding.getExpression() instanceof IScriptExpression) {
      String expr=((IScriptExpression)binding.getExpression()).getText();
      if (expr == null && (AggregationFactory.getInstance().getAggrInfo(binding.getAggrFunction()) != null && !AggregationFactory.getInstance().getAggrInfo(binding.getAggrFunction()).needDataField()))       continue;
    }
    Set levels=OlapExpressionCompiler.getReferencedDimLevel(binding.getExpression(),queryDefn.getBindings());
    if (!validDimLevels.containsAll(levels)) {
      isValid=false;
      if (!suppressException)       throw new DataException(ResourceConstants.INVALID_BINDING_REFER_TO_INEXIST_DIMENSION,binding.getBindingName());
    }
    if (binding.getAggregatOns().size() > 0) {
      if (binding.getAggrFunction() == null) {
        isValid=false;
        if (!suppressException)         throw new DataException(ResourceConstants.INVALID_BINDING_MISSING_AGGR_FUNC,binding.getBindingName());
      }
      Set lvls=new HashSet();
      for (int j=0; j < binding.getAggregatOns().size(); j++) {
        lvls.add(OlapExpressionUtil.getTargetDimLevel(binding.getAggregatOns().get(j).toString()));
      }
      if (!validDimLevels.containsAll(lvls)) {
        isValid=false;
        if (!suppressException)         throw new DataException(ResourceConstants.INVALID_BINDING_REFER_TO_INEXIST_DIMENSION,binding.getBindingName());
      }
    }
    if (!isValid)     result.add(binding);
  }
  return result;
}