Repository navigation
Conversation
Update `OriginTrackedResource` to compare the wrapped resource with the wrapped resource, rather than the unwrapped with the wrapped. See spring-projectsgh-52205 Signed-off-by: zhoubiao188 <32508238+zhoubiao188@users.noreply.github.com>
philwebb
force-pushed
the
fix-origin-tracked-resource-equals
branch
from
October 17, 2026 01:54
8f67af0 to
72a5f8e
Compare
Member
|
Thanks @zhoubiao188! |
opensource-fork-sync Bot
pushed a commit
to cla7aye15I4nd/opensource-spring-projects__spring-boot
that referenced
this pull request
Oct 17, 2026
The method parameters changed in 4.1 and was missed during the forward merge. See spring-projectsgh-52205
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.
OriginTrackedResource.equalscompares the wrappedResourcewith theOriginTrackedResourceargument instead of with the argument's wrapped resource:Resourceimplementations such asClassPathResourceandFileSystemResourcedo notoverride
equals, sothis.resource.equals(other)is alwaysfalsefor a distinctinstance. Two wrappers around the same resource and the same origin are therefore never
considered equal:
hashCode(which usesthis.resource.hashCode()) already treats the two instances asequal, so the
equals/hashCodecontract is broken: such wrappers cannot bede-duplicated in a set or used as equal map keys.
The existing
equalsAndHashCodetest only asserted that an instance equals itself(
r1o1a.isEqualTo(r1o1a)) and never compared two distinct wrappers around the sameresource, which is why this went unnoticed. It now asserts that
r1o1ais equal tor1o1bas well. That assertion fails without the fix in this PR and passes with it.The class already uses
ObjectUtils.nullSafeEqualsfor the origin, so the same helper isused for the resource for consistency.