Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
1.3.6
-
None
Description
org.apache.ode.bpel.elang.xpath10.runtime.XPath10ExpressionRuntime.evaluate(OExpression, EvaluationContext) works incorrect when number function with String argument is used.
Following 'if' statement should have check for NaN:
org.apache.ode.bpel.elang.xpath10.runtime.XPath10ExpressionRuntime.java
public List evaluate(OExpression cexp, EvaluationContext ctx) throws FaultException, EvaluationException { if (ret instanceof Double) { // !!! should be ==> if (ret instanceof Double && !((Double) ret).isNaN()) // safely convert a double into a long if they are numerically equal. This // makes 1 from 1.0, which is more reliable when calling web services. if (Double.compare((Double)ret, Math.ceil((Double)ret)) == 0) { // the double is actually an int/long ret = ((Double)ret).longValue(); } } }
Following test can be used to reproduce the problem:
org.apache.ode.bpel.elang.xpath10.runtime.XPath10ExpressionRuntimeTest.java
public void testEvaluate_NaN() throws Exception { setVariableName("existVar"); OXPath10Expression exp = compile("number('/tns:Title/tns:Data')"); Map<String, String> nsMap = new HashMap<String, String>(); nsMap.put("tns", "http://foobar"); NSContext context = createNSContext(nsMap); exp.namespaceCtx = context; Node retVal = _runtime.evaluateNode(exp, this); assertNotNull(retVal); assertEquals(String.valueOf(Double.NaN), retVal.getTextContent()); }