[
https://issues.apache.org/jira/browse/DAFFODIL-2701?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17544339#comment-17544339
]
Steve Lawrence commented on DAFFODIL-2701:
------------------------------------------
Here is a minimal schema that reproduces the issue:
{code:xml}
<schema
xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:dfdl="http://www.ogf.org/dfdl/dfdl-1.0/">
<include schemaLocation="org/apache/daffodil/xsd/DFDLGeneralFormat.dfdl.xsd"
/>
<annotation>
<appinfo source="http://www.ogf.org/dfdl/">
<dfdl:format xmlns="" ref="GeneralFormat"
lengthKind="delimited" />
</appinfo>
</annotation>
<element name="float" dfdl:terminator="%NL;">
<simpleType>
<restriction base="xs:float">
<minInclusive value="0" />
</restriction>
</simpleType>
</element>
</schema>
{code}
Parsing data that contains {{NaN}}, {{INF}}, or {{-INF}} followed by a newline
and with validation set to "limited" or "on" will trigger the exception.
> 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
> Priority: Critical
> 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)