Repository navigation
Conversation
JavaFloatHolder.compare and JavaDoubleHolder.compare order NaN above every other value, so a NaN instance value passed minInclusive and minExclusive, and a NaN max bound accepted every number. XML Schema makes NaN equal to itself but incomparable with every other value, so it satisfies no bound facet of a non-NaN bound. The four bound checks in both holders now also fail when exactly one side is NaN.
pjfanning
reviewed
Nov 23, 2026
pjfanning
left a comment
Member
There was a problem hiding this comment.
Thanks, the change looks right to me: incomparable only fires when exactly one side is NaN, so it does not overlap with #174.
One request before approving: the tests only use a bound of 0. The description also says that NaN against a NaN bound behaves as before and that a NaN max bound no longer accepts every number, but neither is pinned by a test. Could you add cases with a NaN bound to IncomparableMinFacetValidateTest (NaN value vs NaN bound for each of the four facets, and a non-NaN value vs a NaN bound)?
Possible follow-up, not needed here: compareValue still returns 1/-1 for NaN against a number rather than 2 (incomparable).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Differential run,
XmlObject.validate()vs the JDK Xerces validator,xs:doublewith<xs:minInclusive value="0"/>:How it was found: I ran NaN, INF, -INF and 0 against each of the four bound facets on
xs:floatandxs:double, with bounds of 0, NaN, INF and -INF. 24 of the 128 cases disagreed with Xerces. Every one had NaN on exactly one side.Observations:
JavaFloatHolder.compareandJavaDoubleHolder.comparefall back to the bit patterns, which puts NaN above every other value.minInclusiveandminExclusiveaccept it. A NaN max bound accepts every number.Conclusion: a schema that bounds a float or double with
minInclusive="0"does not keep NaN out, and NaN then slips past range checks in the code that reads the value, since every comparison with it is false. The four bound checks inJavaFloatHolderEx.validateValueandJavaDoubleHolderEx.validateValuenow also fail when exactly one side is NaN. NaN against a NaN bound, and every non-NaN value, behave as before. After the fix all 128 cases agree with Xerces.Cases added to
IncomparableMinFacetValidateTest.nanFailsEveryBoundfails on trunk and passes with the fix../gradlew testis otherwise green, apart fromCompilationTests.partialsandSaverTest.testLengthAssertion, which fail the same way on an untouched trunk checkout here on Windows (they look like line-ending issues).