Repository navigation
Conversation
UniqueItemsValidator compared items with HashSet<JsonNode>, and JsonNode equality depends on node type: IntNode(1) does not equal DoubleNode(1.0), so [1, 1.0] passed uniqueItems. Items are now compared by the same key as on master: numbers become a scale-independent BigDecimal, and arrays and objects are compared element by element. Jackson 2 changes: node.fields() replaces node.properties(), and JsonNodeTypes.isNonFiniteNumber is added from master so that NaN and Infinity keep comparing as nodes instead of throwing. Brings over UniqueItemsNumericEqualityTest and restores the [1,1.0] instance in UniqueItemsApplicabilityTest to match master. Fixes networknt#1299
|
Code review (xhigh · 5 findings) Thanks for the backport. It matches #1273 apart from the Jackson 2 changes, and I found no bugs it introduces. Verification on Java 8 (the
Findings:
Once item 2 is in, this is ready to merge. |
|
Thanks. Pushed 9f053c1: the object loop now uses I'll leave items 4 and 5 for #1302, so master and 2.x can change together. |
stevehu
left a comment
There was a problem hiding this comment.
Thanks. 9f053c1 resolves item 2, and I checked it:
UniqueItemsValidatornow differs frommasteronly in the Jackson import, and the CRLF line endings are kept.- On Java 8, both
UniqueItems*Testclasses and the full JSON suites pass.
I added items 4 and 5 to #1302 so they're tracked with the speed work. Approving and merging.
Fixes #1299 (2.x backport of #1273)
On
2.x,UniqueItemsValidatorcompared items withHashSet<JsonNode>.JsonNodeequality depends on node type (IntNode(1)is not equal toDoubleNode(1.0)), so[1, 1.0]and[[1], [1.0]]passeduniqueItems. This brings overcomparisonKeyfrom #1273: numbers are compared as a scale-independentBigDecimal, and arrays and objects are compared element by element. Numbers still stay distinct from booleans and strings.Changes for
2.x:2.xdidn't haveJsonNodeTypes.isNonFiniteNumber(it came to master with Support handling of non-finite numbers if present #1241), so I added just that helper. Without it,decimalValue()would throw forNaNandInfinitywhen a mapper reads them withALLOW_NON_NUMERIC_NUMBERS. Those values keep comparing as nodes, as before. The rest of Support handling of non-finite numbers if present #1241 is not part of this PR.Tests:
UniqueItemsNumericEqualityTestwith the Jackson 2 imports.[1,1.0]inUniqueItemsApplicabilityTest, so the file now matches master. The{"a":1,"b":1.0}instance mentioned in the issue was already the same on both branches.Without the validator change, 10 of these test cases fail. With it,
mvn verifypasses on JDK 17 (8550 tests).