You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ode.apache.org by "Tammo van Lessen (JIRA)" <ji...@apache.org> on 2014/07/22 16:07:38 UTC

[jira] [Resolved] (ODE-1016) ASSIGN returns 0 when number function with String argument is used

     [ https://issues.apache.org/jira/browse/ODE-1016?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Tammo van Lessen resolved ODE-1016.
-----------------------------------

    Resolution: Fixed

Jenkins is still confused, but the tests worked fine locally and on my personal travis setup.

> ASSIGN returns 0 when number function with String argument is used
> ------------------------------------------------------------------
>
>                 Key: ODE-1016
>                 URL: https://issues.apache.org/jira/browse/ODE-1016
>             Project: ODE
>          Issue Type: Bug
>          Components: BPEL Runtime
>    Affects Versions: 1.3.6
>            Reporter: Igor Vorobiov
>            Assignee: Tammo van Lessen
>             Fix For: 1.3.7, 1.4
>
>
> 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:
> {code:title=org.apache.ode.bpel.elang.xpath10.runtime.XPath10ExpressionRuntime.java|borderStyle=solid}
>       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();
>                     }
>                 }
>      }
> {code}
> Following test can be used to reproduce the problem:
> {code:title=org.apache.ode.bpel.elang.xpath10.runtime.XPath10ExpressionRuntimeTest.java|borderStyle=solid}
>     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());
>     }
> {code}



--
This message was sent by Atlassian JIRA
(v6.2#6252)