[improve][client] Implement equals by compareTo to avoid logic unaligned - #18843
Conversation
Signed-off-by: tison <wander4096@gmail.com>
|
Nice catch! Maybe we can add a test in |
|
@labuladong this doesn't change any existing logic and easy to be proven. If you have good ideas on tests, you can send me a patch. |
I don't think so, the original implementation is a little complex... I suggest just constructing different types of messageID and comparing them, the tests pass would prove the correctness easily. |
|
@labuladong I get your point. Updating... |
Signed-off-by: tison <wander4096@gmail.com>
Signed-off-by: tison <wander4096@gmail.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #18843 +/- ##
============================================
+ Coverage 46.17% 47.77% +1.59%
- Complexity 10359 10636 +277
============================================
Files 703 703
Lines 68845 68832 -13
Branches 7382 7379 -3
============================================
+ Hits 31788 32883 +1095
+ Misses 33448 32242 -1206
- Partials 3609 3707 +98
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
| } else if (o instanceof TopicMessageIdImpl) { | ||
| return equals(((TopicMessageIdImpl) o).getInnerMessageId()); | ||
| if (o instanceof MessageId) { | ||
| return compareTo((MessageId) o) == 0; |
There was a problem hiding this comment.
This will throw an exception if o is an instance of MessageId but not MessageIdImpl nor TopicMessageIdImpl, like MultiMessageIdImpl.
Before this PR, it just return false.
There was a problem hiding this comment.
Updated. I change the impl in MultiMessageIdImpl also since it previous throws exception on type mistach in equals which seems unnecessary.
Signed-off-by: tison <wander4096@gmail.com>
Signed-off-by: tison <wander4096@gmail.com>
Signed-off-by: tison <wander4096@gmail.com>
Signed-off-by: tison <wander4096@gmail.com>
|
Merging... |
…ned (apache#18843) Signed-off-by: tison <wander4096@gmail.com>
…ned (apache#18843) Signed-off-by: tison <wander4096@gmail.com>
…ned (apache#18843) Signed-off-by: tison <wander4096@gmail.com>
Documentation
docdoc-requireddoc-not-neededdoc-completeMatching PR in forked repository
PR in forked repository: