Program: 65493
Project: 65493
Buggy source:
/** 
 * Evaluates a IJSExpression or IConditionalExpression
 * @param expr
 * @param cx
 * @param scope
 * @param source
 * @param lineNo
 * @return 
 * @throws BirtException 
 */
public static Object evalExpr(IBaseExpression expr,ScriptContext cx,String source,int lineNo) throws DataException {
  try {
    if (logger.isLoggable(Level.FINER))     logger.entering(ScriptEvalUtil.class.getName(),"String_Node_Str","String_Node_Str" + LogUtil.toString(expr) + "String_Node_Str"+ source+ "String_Node_Str"+ lineNo);
    Object result;
    if (expr == null) {
      result=null;
    }
 else     if (expr instanceof IConditionalExpression) {
      Object handle=expr.getHandle();
      if (handle instanceof NEvaluator) {
        result=Boolean.valueOf(((NEvaluator)handle).evaluate(cx,((IDataScriptEngine)cx.getScriptEngine(IDataScriptEngine.ENGINE_NAME)).getJSScope(cx),null));
      }
 else {
        ConditionalExpression conditionalExpr=(ConditionalExpression)expr;
        Object expression=evalExpr(conditionalExpr.getExpression(),cx,source,lineNo);
        if (conditionalExpr.getOperand1() instanceof IExpressionCollection) {
          IExpressionCollection combinedExpr=(IExpressionCollection)((IConditionalExpression)expr).getOperand1();
          Object[] exprs=combinedExpr.getExpressions().toArray();
          Object[] opValues=new Object[exprs.length];
          for (int i=0; i < opValues.length; i++) {
            opValues[i]=evalExpr((IBaseExpression)exprs[i],cx,source,lineNo);
          }
          result=evalConditionalExpr(expression,conditionalExpr.getOperator(),MiscUtil.flatternMultipleValues(opValues),null);
        }
 else {
          Object Op1=evalExpr(MiscUtil.constructValidScriptExpression((IScriptExpression)conditionalExpr.getOperand1()),cx,source,lineNo);
          Object Op2=evalExpr(MiscUtil.constructValidScriptExpression((IScriptExpression)conditionalExpr.getOperand2()),cx,source,lineNo);
          result=evalConditionalExpr(expression,conditionalExpr.getOperator(),new Object[]{Op1,Op2},null);
        }
      }
    }
 else     if (expr instanceof ICollectionConditionalExpression) {
      Collection<IScriptExpression> testExpr=((ICollectionConditionalExpression)expr).getExpr();
      Collection<Collection<IScriptExpression>> operand=((ICollectionConditionalExpression)expr).getOperand();
      List<Object> testObj=new ArrayList<Object>();
      boolean in=false;
      for (      IScriptExpression se : testExpr) {
        testObj.add(evalExpr(se,cx,source,lineNo));
      }
      for (      Collection<IScriptExpression> op : operand) {
        List<Object> targetObj=new ArrayList<Object>();
        for (        IScriptExpression se : op) {
          if (se == null) {
            targetObj.add(null);
          }
 else {
            if (se.getHandle() == null) {
              se.setHandle(evalExpr(se,cx,source,lineNo));
            }
            targetObj.add(se.getHandle());
          }
        }
        if (compareIgnoreNull(testObj,targetObj) == 0) {
          in=Boolean.TRUE;
          break;
        }
      }
      result=(((ICollectionConditionalExpression)expr).getOperator() == ICollectionConditionalExpression.OP_IN) ? in : (!in);
    }
 else {
      IScriptExpression jsExpr=(IScriptExpression)expr;
      if (jsExpr.isConstant() && jsExpr.getConstantValue() != null) {
        result=jsExpr.getConstantValue();
      }
 else {
        if (jsExpr.isConstant()) {
          result=JavascriptEvalUtil.evaluateJsConstants(jsExpr.getText());
          jsExpr.setConstantValue(result);
        }
 else         if (jsExpr.getText() != null && jsExpr.getHandle() != null) {
          if (jsExpr.getHandle() instanceof ICompiledScript) {
            result=cx.evaluate((ICompiledScript)jsExpr.getHandle());
          }
 else {
            result=((CompiledExpression)jsExpr.getHandle()).evaluate(cx,((IDataScriptEngine)cx.getScriptEngine(IDataScriptEngine.ENGINE_NAME)).getJSScope(cx));
          }
        }
 else {
          result=evaluateJSAsExpr(cx,((IDataScriptEngine)cx.getScriptEngine(IDataScriptEngine.ENGINE_NAME)).getJSScope(cx),jsExpr.getText(),source,lineNo);
        }
      }
    }
    if (logger.isLoggable(Level.FINER))     logger.exiting(ScriptEvalUtil.class.getName(),"String_Node_Str",result);
    return result;
  }
 catch (  BirtException e) {
    throw DataException.wrap(e);
  }
}

Fixed version (ground truth):
/** 
 * Evaluates a IJSExpression or IConditionalExpression
 * @param expr
 * @param cx
 * @param scope
 * @param source
 * @param lineNo
 * @return 
 * @throws BirtException 
 */
public static Object evalExpr(IBaseExpression expr,ScriptContext cx,String source,int lineNo) throws DataException {
  try {
    if (logger.isLoggable(Level.FINER))     logger.entering(ScriptEvalUtil.class.getName(),"String_Node_Str","String_Node_Str" + LogUtil.toString(expr) + "String_Node_Str"+ source+ "String_Node_Str"+ lineNo);
    Object result;
    if (expr == null) {
      result=null;
    }
 else     if (expr instanceof IConditionalExpression) {
      Object handle=expr.getHandle();
      if (handle instanceof NEvaluator) {
        result=Boolean.valueOf(((NEvaluator)handle).evaluate(cx,((IDataScriptEngine)cx.getScriptEngine(IDataScriptEngine.ENGINE_NAME)).getJSScope(cx),null));
      }
 else {
        ConditionalExpression conditionalExpr=(ConditionalExpression)expr;
        Object expression=evalExpr(conditionalExpr.getExpression(),cx,source,lineNo);
        if (conditionalExpr.getOperand1() instanceof IExpressionCollection) {
          IExpressionCollection combinedExpr=(IExpressionCollection)((IConditionalExpression)expr).getOperand1();
          Object[] exprs=combinedExpr.getExpressions().toArray();
          Object[] opValues=new Object[exprs.length];
          for (int i=0; i < opValues.length; i++) {
            opValues[i]=evalExpr((IBaseExpression)exprs[i],cx,source,lineNo);
          }
          result=evalConditionalExpr(expression,conditionalExpr.getOperator(),MiscUtil.flatternMultipleValues(opValues),null);
        }
 else {
          Object Op1=evalExpr(MiscUtil.constructValidScriptExpression((IScriptExpression)conditionalExpr.getOperand1()),cx,source,lineNo);
          Object Op2=evalExpr(MiscUtil.constructValidScriptExpression((IScriptExpression)conditionalExpr.getOperand2()),cx,source,lineNo);
          result=evalConditionalExpr(expression,conditionalExpr.getOperator(),new Object[]{Op1,Op2},null);
        }
      }
    }
 else     if (expr instanceof ICollectionConditionalExpression) {
      Collection<IScriptExpression> testExpr=((ICollectionConditionalExpression)expr).getExpr();
      Collection<Collection<IScriptExpression>> operand=((ICollectionConditionalExpression)expr).getOperand();
      List<Object> testObj=new ArrayList<Object>();
      boolean in=false;
      for (      IScriptExpression se : testExpr) {
        testObj.add(evalExpr(se,cx,source,lineNo));
      }
      for (      Collection<IScriptExpression> op : operand) {
        List<Object> targetObj=new ArrayList<Object>();
        for (        IScriptExpression se : op) {
          if (se == null) {
            targetObj.add(null);
          }
 else {
            if (se.getHandle() == null) {
              se.setHandle(evalExpr(se,cx,source,lineNo));
            }
            targetObj.add(se.getHandle());
          }
        }
        if (compareIgnoreNull(testObj,targetObj) == 0) {
          in=Boolean.TRUE;
          break;
        }
      }
      result=(((ICollectionConditionalExpression)expr).getOperator() == ICollectionConditionalExpression.OP_IN) ? in : (!in);
    }
 else {
      IScriptExpression jsExpr=(IScriptExpression)expr;
      if (BaseExpression.constantId.equals(jsExpr.getScriptId()) && jsExpr.getHandle() != null) {
        result=jsExpr.getHandle();
      }
 else {
        if (BaseExpression.constantId.equals(jsExpr.getScriptId())) {
          result=JavascriptEvalUtil.evaluateJsConstants(jsExpr.getText());
          jsExpr.setHandle(result);
        }
 else         if (jsExpr.getText() != null && jsExpr.getHandle() != null) {
          if (jsExpr.getHandle() instanceof ICompiledScript) {
            result=cx.evaluate((ICompiledScript)jsExpr.getHandle());
          }
 else {
            result=((CompiledExpression)jsExpr.getHandle()).evaluate(cx,((IDataScriptEngine)cx.getScriptEngine(IDataScriptEngine.ENGINE_NAME)).getJSScope(cx));
          }
        }
 else {
          result=evaluateJSAsExpr(cx,((IDataScriptEngine)cx.getScriptEngine(IDataScriptEngine.ENGINE_NAME)).getJSScope(cx),jsExpr.getText(),source,lineNo);
        }
      }
    }
    if (logger.isLoggable(Level.FINER))     logger.exiting(ScriptEvalUtil.class.getName(),"String_Node_Str",result);
    return result;
  }
 catch (  BirtException e) {
    throw DataException.wrap(e);
  }
}