Program: 72043
Project: 72043
Buggy source:
/** 
 * @param dataExpr
 * @param odiResult
 * @param scope
 * @param logger
 * @return
 * @throws BirtException
 */
public static Object evaluateExpression(IBaseExpression dataExpr,IResultIterator odiResult,Scriptable scope) throws BirtException {
  Object exprValue=null;
  if (dataExpr == null)   throw new DataException(ResourceConstants.BAD_DATA_EXPRESSION);
  Object handle=dataExpr.getHandle();
  if (handle instanceof CompiledExpression) {
    CompiledExpression expr=(CompiledExpression)handle;
    Object value=evaluateCompiledExpression(expr,odiResult,scope);
    try {
      if (value instanceof BirtException)       throw (BirtException)value;
      exprValue=DataTypeUtil.convert(value,dataExpr.getDataType());
    }
 catch (    BirtException e) {
      throw DataException.wrap(e);
    }
  }
 else   if (handle instanceof ConditionalExpression) {
    ConditionalExpression ce=(ConditionalExpression)handle;
    Object resultExpr=evaluateExpression(ce.getExpression(),odiResult,scope);
    Object[] op1Value=new Object[0], op2Value=new Object[0];
    boolean isCombined=false;
    if (ce.getOperand1() != null) {
      if (ce.getOperand1() instanceof IScriptExpression) {
        op1Value=new Object[1];
        op1Value[0]=evaluateExpression(ce.getOperand1(),odiResult,scope);
      }
 else       if (ce.getOperand1() instanceof IExpressionCollection) {
        isCombined=true;
        Object[] exprs=((IExpressionCollection)ce.getOperand1()).getExpressions().toArray();
        int length=exprs.length;
        Object[] result=new Object[length];
        for (int i=0; i < length; i++) {
          result[i]=evaluateExpression((IBaseExpression)exprs[i],odiResult,scope);
        }
        op1Value=flatternMultipleValues(result);
      }
    }
    if (ce.getOperand2() != null) {
      if (ce.getOperand2() instanceof IScriptExpression) {
        op2Value=new Object[1];
        op2Value[0]=evaluateExpression(ce.getOperand2(),odiResult,scope);
      }
    }
    if (isCombined)     exprValue=ScriptEvalUtil.evalConditionalExpr(resultExpr,ce.getOperator(),op1Value);
 else     exprValue=ScriptEvalUtil.evalConditionalExpr(resultExpr,ce.getOperator(),op1Value.length > 0 ? op1Value[0] : null,op2Value.length > 0 ? op2Value[0] : null);
  }
 else {
    DataException e=new DataException(ResourceConstants.INVALID_EXPR_HANDLE);
    throw e;
  }
  if (exprValue instanceof DataExceptionMocker) {
    throw ((DataExceptionMocker)exprValue).getCause();
  }
  return exprValue;
}

Fixed version (ground truth):
/** 
 * @param dataExpr
 * @param odiResult
 * @param scope
 * @param logger
 * @return
 * @throws BirtException
 */
public static Object evaluateExpression(IBaseExpression dataExpr,IResultIterator odiResult,Scriptable scope) throws BirtException {
  Object exprValue=null;
  if (dataExpr == null)   throw new DataException(ResourceConstants.BAD_DATA_EXPRESSION);
  Object handle=dataExpr.getHandle();
  if (handle instanceof CompiledExpression) {
    CompiledExpression expr=(CompiledExpression)handle;
    Object value=evaluateCompiledExpression(expr,odiResult,scope);
    try {
      if (value instanceof BirtException)       throw (BirtException)value;
      exprValue=DataTypeUtil.convert(value,dataExpr.getDataType());
    }
 catch (    BirtException e) {
      throw DataException.wrap(e);
    }
  }
 else   if (handle instanceof ConditionalExpression) {
    ConditionalExpression ce=(ConditionalExpression)handle;
    Object resultExpr=evaluateExpression(ce.getExpression(),odiResult,scope);
    Object[] op1Value=new Object[0], op2Value=new Object[0];
    boolean isCombined=false;
    if (ce.getOperand1() != null) {
      if (ce.getOperand1() instanceof IScriptExpression) {
        op1Value=new Object[1];
        op1Value[0]=evaluateExpression(ce.getOperand1(),odiResult,scope);
      }
 else       if (ce.getOperand1() instanceof IExpressionCollection) {
        isCombined=true;
        Object[] exprs=((IExpressionCollection)ce.getOperand1()).getExpressions().toArray();
        int length=exprs.length;
        Object[] result=new Object[length];
        for (int i=0; i < length; i++) {
          result[i]=evaluateExpression((IBaseExpression)exprs[i],odiResult,scope);
        }
        op1Value=flatternMultipleValues(result);
      }
    }
    if (ce.getOperand2() != null) {
      if (ce.getOperand2() instanceof IScriptExpression) {
        op2Value=new Object[1];
        op2Value[0]=evaluateExpression(ce.getOperand2(),odiResult,scope);
      }
    }
    if (isCombined)     exprValue=ScriptEvalUtil.evalConditionalExpr(resultExpr,ce.getOperator(),op1Value);
 else     exprValue=ScriptEvalUtil.evalConditionalExpr(resultExpr,ce.getOperator(),op1Value.length > 0 ? op1Value[0] : null,op2Value.length > 0 ? op2Value[0] : null);
  }
 else {
    DataException e=new DataException(ResourceConstants.INVALID_EXPR_HANDLE);
    throw e;
  }
  return exprValue;
}