Steve Lawrence created DAFFODIL-2701:
----------------------------------------

             Summary: Facet checks throw exception for non-numeric float/double 
values
                 Key: DAFFODIL-2701
                 URL: https://issues.apache.org/jira/browse/DAFFODIL-2701
             Project: Daffodil
          Issue Type: Bug
          Components: Back End
    Affects Versions: 3.3.0
            Reporter: Steve Lawrence
             Fix For: 3.4.0


xs:float and xs:double types are allow to have the non-numeric values "NaN", 
"INF", and "-INF". We represent these internally using Java float and double, 
which support these non-numeric values.

If validation is enabled (with either limited or full) and a float/double 
element has certain facet restrictions, then we get the following exception:

{code:java}
        at java.math.BigDecimal.<init>(BigDecimal.java:497)
        at java.math.BigDecimal.<init>(BigDecimal.java:383)
        at java.math.BigDecimal.<init>(BigDecimal.java:809)
        at org.apache.daffodil.util.Numbers$.asJBigDecimal(Numbers.scala:275)
        at 
org.apache.daffodil.infoset.DISimple.dataValueAsBigDecimal(InfosetImpl.scala:1372)
        at 
org.apache.daffodil.processors.SimpleTypeRuntimeData.checkMinInc(RuntimeData.scala:431)
        at 
org.apache.daffodil.processors.SimpleTypeRuntimeData.$anonfun$executeFacetCheck$4(RuntimeData.scala:340)
        at 
org.apache.daffodil.processors.SimpleTypeRuntimeData.$anonfun$executeFacetCheck$4$adapted(RuntimeData.scala:339)
        at scala.Option.foreach(Option.scala:407)
        at 
org.apache.daffodil.processors.SimpleTypeRuntimeData.executeFacetCheck(RuntimeData.scala:339)
        at 
org.apache.daffodil.processors.SimpleTypeRuntimeData.executeCheck(RuntimeData.scala:264)
        at 
org.apache.daffodil.dpath.DFDLCheckConstraintsFunction$.executeCheck(DFDLCheckConstraintsFunction.scala:54)
        at 
org.apache.daffodil.dpath.DFDLCheckConstraintsFunction$.validate(DFDLCheckConstraintsFunction.scala:37)
        at 
org.apache.daffodil.processors.parsers.ElementParserBase.validate(ElementCombinator1.scala:76)
{code}

In order to perform certain facet checks, we convert the float/double to a 
BigDecimal using dataValueAsBigDecimal. However, BigDecimals do not support 
these non-numeric values, so this leads to an exception.

Quickly scanning the code in RuntimeData.scala, it looks like at the following 
facets checks may be affected by this:
* minInclusive
* minExclusive
* maxInclusive
* minExclusive
* totalDigits (not valid for float/double, may not be affected)
* fractionDigits (not valid for float/double, may not be affected)

There may be other places where we convert float/double values to a BigDecimal 
that have this same issue. We should inspect the codebase and determine if 
there are other related issues.



--
This message was sent by Atlassian Jira
(v8.20.7#820007)

Reply via email to