Program: 72800
Project: 72800
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);
  populateLevel(queryDefn,validDimLevels,ICubeQueryDefinition.PAGE_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();
      final IAggrFunction aggrFunc=AggregationManager.getInstance().getAggregation(binding.getAggrFunction());
      if (expr == null && AggregationUtil.needDataField(aggrFunc))       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;
}

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);
  populateLevel(queryDefn,validDimLevels,ICubeQueryDefinition.PAGE_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();
      final IAggrFunction aggrFunc=AggregationManager.getInstance().getAggregation(binding.getAggrFunction());
      if (expr == null && AggregationUtil.needDataField(aggrFunc))       continue;
    }
    Set levels=OlapExpressionCompiler.getReferencedDimLevel(binding.getExpression(),queryDefn.getBindings());
    if (levels != null && levels.size() > 0 && !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;
}