fix: include all operands in AbstractLogicalMatcher equals/hashCode#3400
Merged
tomakehurst merged 2 commits intoApr 30, 2026
Merged
Conversation
AbstractLogicalMatcher inherits equals()/hashCode() from StringValuePattern, which only compares the expectedValue field. Since the constructor passes only the first operand's expected value to the parent, two LogicalAnd/LogicalOr instances with the same first operand but different subsequent operands are incorrectly treated as equal. Override equals() and hashCode() to also compare the full operands list, so matchers with different operand sets are correctly distinguished. This fixes incorrect stub deduplication when ignoreRepeatRequests is used with a StubMappingTransformer that produces logical AND/OR body patterns. Fixes wiremock#3353 Made-with: Cursor
Member
|
Please can you run |
sivakumarbuddha
approved these changes
Apr 29, 2026
|
@rnagulapalle can you take a look at the above review comments |
Made-with: Cursor
|
@tomakehurst please review. |
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.
What
Overrides
equals()andhashCode()inAbstractLogicalMatcherto compare the full operands list, not just the inheritedexpectedValue.Why
AbstractLogicalMatcherinheritsequals()/hashCode()fromStringValuePattern, which only compares theexpectedValuefield. The constructor passes only the first operand's expected value to the parent viacheckAtLeast2OperandsAndReturnFirstExpected().This means two
LogicalAnd/LogicalOrinstances with the same first operand but different subsequent operands are incorrectly treated as equal:This causes incorrect stub deduplication when
ignoreRepeatRequestsis used with aStubMappingTransformerthat produces logical AND/OR body patterns.Changes
AbstractLogicalMatcher.java— overrideequals()to also compareoperandslist; overridehashCode()to includeoperandsLogicalAndTest.java— added test: same first operand, different later operands → not equalLogicalOrTest.java— added same test forLogicalOrFixes #3353
Made with Cursor