Program: 119327
Project: 119327
Buggy source:
private static Expression evaluateExpression(Expression expression,List<? extends IElementParameter> listParam,ElementParameter currentParam){
  int indexBegining=0, indexEnd;
  int expressionLevel=0;
  String string=expression.getExpressionString();
  boolean conditionFound=false;
  for (int i=0; i < string.length() && !conditionFound; i++) {
    if (string.charAt(i) == '(') {
      if (expressionLevel == 0) {
        indexBegining=i + 1;
      }
      expressionLevel++;
    }
 else     if (string.charAt(i) == ')') {
      expressionLevel--;
      indexEnd=i;
      if (expressionLevel == 0) {
        if (isThereCondition(string,AND) || isThereCondition(string,OR)) {
          String leftString=string.substring(indexBegining,indexEnd).trim();
          if (isThereCondition(leftString,AND) || isThereCondition(leftString,OR)) {
            Expression leftExpression=new Expression(leftString);
            expression.setLeftExpression(leftExpression);
            evaluateExpression(leftExpression,listParam,currentParam);
          }
 else {
            Expression leftExpression=new Expression(leftString);
            expression.setLeftExpression(leftExpression);
            leftExpression.setValid(evaluateSimpleExpression(leftString,listParam,currentParam));
          }
        }
 else {
          String newValue;
          newValue=string.replace("String_Node_Str","String_Node_Str");
          newValue=newValue.replace("String_Node_Str","String_Node_Str");
          expression.setExpressionString(newValue);
          expression.setValid(evaluateSimpleExpression(newValue,listParam,currentParam));
        }
      }
    }
 else     if (expressionLevel == 0) {
      if ((string.indexOf(AND,i) == i) || (string.indexOf(AND.toUpperCase(),i) == i)) {
        String subStr=string.substring(i - 3,i + 5);
        if (isThereCondition(subStr,AND)) {
          expression.setCondition(AND);
          conditionFound=true;
        }
      }
 else       if ((string.indexOf(OR,i) == i) || (string.indexOf(OR.toUpperCase(),i) == i)) {
        String subStr=string.substring(i - 3,i + 5);
        if (isThereCondition(subStr,OR)) {
          expression.setCondition(OR);
          conditionFound=true;
        }
      }
    }
    if (conditionFound) {
      if (expression.getLeftExpression() == null) {
        String leftString=string.substring(0,i - 1).trim();
        Expression leftExpression=new Expression(leftString);
        expression.setLeftExpression(leftExpression);
        leftExpression.setValid(evaluateSimpleExpression(leftString,listParam,currentParam));
      }
      String rightString=string.substring(i + 3,string.length()).trim();
      Expression rightExpression=new Expression(rightString);
      expression.setRightExpression(rightExpression);
      if (rightString.contains("String_Node_Str") || isThereCondition(rightString,AND) || isThereCondition(rightString,OR)) {
        evaluateExpression(rightExpression,listParam,currentParam);
      }
 else {
        rightExpression.setValid(evaluateSimpleExpression(rightString,listParam,currentParam));
      }
      if (expression.getCondition().equals(AND)) {
        if (expression.getLeftExpression().isValid() && expression.getRightExpression().isValid()) {
          expression.setValid(true);
        }
 else {
          expression.setValid(false);
        }
      }
 else       if (expression.getCondition().equals(OR)) {
        if (expression.getLeftExpression().isValid() || expression.getRightExpression().isValid()) {
          expression.setValid(true);
        }
 else {
          expression.setValid(false);
        }
      }
    }
  }
  if ((expression.getRightExpression() == null) && (expression.getLeftExpression() != null)) {
    expression.setValid(expression.getLeftExpression().isValid());
  }
  return expression;
}

Fixed version (ground truth):
private static Expression evaluateExpression(Expression expression,List<? extends IElementParameter> listParam,ElementParameter currentParam){
  int indexBegining=0, indexEnd;
  int expressionLevel=0;
  String string=expression.getExpressionString();
  boolean conditionFound=false;
  for (int i=0; i < string.length() && !conditionFound; i++) {
    if (string.charAt(i) == '(') {
      if (expressionLevel == 0) {
        indexBegining=i + 1;
      }
      expressionLevel++;
    }
 else     if (string.charAt(i) == ')') {
      expressionLevel--;
      indexEnd=i;
      if (expressionLevel == 0) {
        if (isThereCondition(string,AND) || isThereCondition(string,OR)) {
          String leftString=string.substring(indexBegining,indexEnd).trim();
          if (isThereCondition(leftString,AND) || isThereCondition(leftString,OR)) {
            Expression leftExpression=new Expression(leftString);
            expression.setLeftExpression(leftExpression);
            evaluateExpression(leftExpression,listParam,currentParam);
          }
 else {
            Expression leftExpression=new Expression(leftString);
            expression.setLeftExpression(leftExpression);
            leftExpression.setValid(evaluateSimpleExpression(leftString,listParam,currentParam));
          }
        }
 else {
          String newValue;
          newValue=string.replace("String_Node_Str","String_Node_Str");
          newValue=newValue.replace("String_Node_Str","String_Node_Str");
          expression.setExpressionString(newValue);
          expression.setValid(evaluateSimpleExpression(newValue,listParam,currentParam));
        }
      }
    }
 else     if (expressionLevel == 0) {
      if ((string.indexOf(AND,i) == i) || (string.indexOf(AND.toUpperCase(),i) == i)) {
        String subStr=string.substring(i - 3,i + 5);
        if (isThereCondition(subStr,AND)) {
          expression.setCondition(AND);
          conditionFound=true;
        }
      }
 else       if ((string.indexOf(OR,i) == i) || (string.indexOf(OR.toUpperCase(),i) == i)) {
        String subStr=string.substring(i - 3,i + 5);
        if (isThereCondition(subStr,OR)) {
          expression.setCondition(OR);
          conditionFound=true;
        }
      }
    }
    if (conditionFound) {
      if (expression.getLeftExpression() == null) {
        String leftString=string.substring(0,i - 1).trim();
        Expression leftExpression=new Expression(leftString);
        expression.setLeftExpression(leftExpression);
        leftExpression.setValid(evaluateSimpleExpression(leftString,listParam,currentParam));
      }
      boolean needValidRightExpression=true;
      if (expression.getCondition().equals(AND) && !expression.getLeftExpression().isValid()) {
        expression.setValid(false);
        needValidRightExpression=false;
      }
 else       if (expression.getCondition().equals(OR) && expression.getLeftExpression().isValid()) {
        expression.setValid(true);
        needValidRightExpression=false;
      }
      if (needValidRightExpression) {
        String rightString=string.substring(i + 3,string.length()).trim();
        Expression rightExpression=new Expression(rightString);
        expression.setRightExpression(rightExpression);
        if (rightString.contains("String_Node_Str") || isThereCondition(rightString,AND) || isThereCondition(rightString,OR)) {
          evaluateExpression(rightExpression,listParam,currentParam);
        }
 else {
          rightExpression.setValid(evaluateSimpleExpression(rightString,listParam,currentParam));
        }
        if (expression.getCondition().equals(AND)) {
          if (expression.getLeftExpression().isValid() && expression.getRightExpression().isValid()) {
            expression.setValid(true);
          }
 else {
            expression.setValid(false);
          }
        }
 else         if (expression.getCondition().equals(OR)) {
          if (expression.getLeftExpression().isValid() || expression.getRightExpression().isValid()) {
            expression.setValid(true);
          }
 else {
            expression.setValid(false);
          }
        }
      }
    }
  }
  if ((expression.getRightExpression() == null) && (expression.getLeftExpression() != null)) {
    expression.setValid(expression.getLeftExpression().isValid());
  }
  return expression;
}