fix: fix equal bug in some files#10574
Open
enkilee wants to merge 2 commits into
Open
Conversation
fix equal bug in some files. equals/hashCode 基于当前字段值。若对象在集合中时字段被修改,可能导致定位失败——这是这些类本就存在的可变性问题,本次修复仅保证契约一致性,未改变可变性。
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.
Which Issue(s) This PR Fixes
Brief Description
compareTo 与 Object.equals 共存.
在 TreeSet/TreeMap 中,compareTo 返回 0 的两个对象会被视为"相等"但 equals() 返回 false,违反 Comparable 契约,可能导致集合中元素丢失或行为不一致。
修复:重写 equals/hashCode 与 compareTo 一致。
How Did You Test This Change?