Repository navigation
fix(compare): avoid ordering differences for identical arrays - #113
Merged
puneetkhanduri merged 1 commit intoNov 7, 2026
Merged
puneetkhanduri merged 1 commit into
puneetkhanduri merged 1 commit into
Conversation
Agent on behalf of @prado-rafael
mrgustavosantiagosyngenta
approved these changes
Nov 4, 2026
william-lcs
approved these changes
Nov 4, 2026
puneetkhanduri
added a commit
that referenced
this pull request
Nov 7, 2026
FieldMap had no equals/hashCode, so diffSeq's removeAll never matched JSON objects. Reordered object arrays fell through to an index-by-index comparison and were reported as field-level PrimitiveDifferences instead of an OrderingDifference. Give FieldMap value equality. Identical arrays of objects are still walked element by element so their field-level NoDifference metadata is retained rather than collapsing into a single array-level entry. Builds on #113, which this depends on: without its equal-list guard, FieldMap equality would make identical object arrays report a false OrderingDifference. Co-authored-by: Puneet Khanduri <puneet.khanduri@gmail.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.
Summary
Return
NoDifferencefor identical lists before dispatching todiffSeq. Equal arrays should not be classified as ordering regressions or increment the different-request counter.This is a one-line, list-specific equality guard. It preserves object/map traversal and field-level
NoDifferencemetadata, rather than introducing a broad object-equality short circuit or suppressing all ordering differences.Problem and minimal reproduction
Comparing two identical responses currently produces:
Non-empty equal arrays have the same problem:
["a", "b"]versus["a", "b"]yields anOrderingDifferencewith[0, 1]on both sides.diffSeqemits that type whenever the arrays have matching elements, without first checking whether the lists are already equal. The request counter excludes onlyNoDifference, so these comparisons become false-positive different requests.An earlier report describes this exact empty/singleton-array behavior: #95 (comment).
Expected behavior
[][]NoDifference["a", "b"]["a", "b"]NoDifference[1, 1, 2][1, 1, 2]NoDifference[1, 2][2, 1]OrderingDifference[1, 2][1, 3][1, 2][1, 2, 3]TDD and validation
Tests were added before modifying
Difference.java:git diff --checkpassed.Coverage includes empty, singleton, populated, repeated-element, nested and mixed JSON arrays, native arrays, retained field-level metadata, actual ordering/value/size differences, and the real in-memory request counter. Genuine ordering differences still increment the counter; identical responses do not.
Commands (JDK 21):
Frontend tasks were skipped for this backend-only change. My local Maven settings add unrelated repositories, so the commands were executed with temporary
-s/-gssettings pointing to Maven Central. No project build configuration or dependencies were changed.Scope
The equivalent Scala fix and regression tests are proposed separately in the downstream fork: syngenta#6. This PR targets the current Java implementation and contains no deployment changes, UI changes, counter workarounds, or production data.
Agent on behalf of @prado-rafael