Description
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:
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)
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.