Program: 66836
Project: 66836
Buggy source:
private List<IBinding> findSavedBinding(Iterator<IBinding> bindingIt){
  List<IBinding> bindingList=new ArrayList<IBinding>();
  while (bindingIt.hasNext()) {
    IBinding binding=bindingIt.next();
    List<String> referencedBindings=new ArrayList<String>();
    try {
      IBaseExpression expr=binding.getExpression();
      if (expr != null) {
        referencedBindings=ExpressionCompilerUtil.extractColumnExpression(binding.getExpression(),ExpressionUtil.DATASET_ROW_INDICATOR);
      }
      if (referencedBindings.isEmpty() && binding.getAggrFunction() != null) {
        for (        IBaseExpression argExpr : (List<IBaseExpression>)binding.getArguments()) {
          referencedBindings=ExpressionCompilerUtil.extractColumnExpression(argExpr,ExpressionUtil.DATASET_ROW_INDICATOR);
          if (!referencedBindings.isEmpty())           break;
        }
      }
      if (!referencedBindings.isEmpty()) {
        bindingList.add(binding);
      }
    }
 catch (    DataException e) {
    }
  }
  return bindingList;
}

Fixed version (ground truth):
private List<IBinding> findSavedBinding(Map bindingMap){
  Iterator bindingIt=bindingMap.values().iterator();
  List<IBinding> bindingList=new ArrayList<IBinding>();
  while (bindingIt.hasNext()) {
    IBinding binding=(IBinding)bindingIt.next();
    List<String> referencedBindings=new ArrayList<String>();
    try {
      if (binding.getAggrFunction() != null) {
        IBaseExpression expr=binding.getExpression();
        if (expr != null) {
          referencedBindings=ExpressionCompilerUtil.extractColumnExpression(binding.getExpression(),ExpressionUtil.DATASET_ROW_INDICATOR);
        }
        if (!referencedBindings.isEmpty()) {
          bindingList.add(binding);
          continue;
        }
        for (        IBaseExpression argExpr : (List<IBaseExpression>)binding.getArguments()) {
          referencedBindings=ExpressionCompilerUtil.extractColumnExpression(argExpr,ExpressionUtil.DATASET_ROW_INDICATOR);
          if (!referencedBindings.isEmpty())           break;
        }
        if (!referencedBindings.isEmpty()) {
          bindingList.add(binding);
          continue;
        }
        boolean needRecalcualte=false;
        if (expr != null) {
          referencedBindings=ExpressionCompilerUtil.extractColumnExpression(binding.getExpression(),ExpressionUtil.ROW_INDICATOR);
          for (int i=0; i < referencedBindings.size(); i++) {
            IBinding b=(IBinding)bindingMap.get(referencedBindings.get(i));
            if (b != null && b.getAggrFunction() != null) {
              needRecalcualte=true;
              break;
            }
          }
        }
        if (needRecalcualte) {
          continue;
        }
        for (        IBaseExpression argExpr : (List<IBaseExpression>)binding.getArguments()) {
          referencedBindings=ExpressionCompilerUtil.extractColumnExpression(argExpr,ExpressionUtil.ROW_INDICATOR);
          for (int i=0; i < referencedBindings.size(); i++) {
            IBinding b=(IBinding)bindingMap.get(referencedBindings.get(i));
            if (b != null && b.getAggrFunction() != null) {
              needRecalcualte=true;
              break;
            }
          }
          if (needRecalcualte)           break;
        }
        if (!needRecalcualte) {
          bindingList.add(binding);
        }
      }
 else {
        bindingList.add(binding);
      }
    }
 catch (    DataException e) {
      bindingList.add(binding);
    }
  }
  return bindingList;
}