You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/12/13 01:16:29 UTC
[GitHub] [pulsar] tisonkun commented on a diff in pull request #18843: [improve][client] Implement equals by compareTo to avoid logic unaligned
tisonkun commented on code in PR #18843:
URL: https://github.com/apache/pulsar/pull/18843#discussion_r1046568429
##########
pulsar-client/src/main/java/org/apache/pulsar/client/impl/BatchMessageIdImpl.java:
##########
@@ -90,30 +91,15 @@ public int hashCode() {
@Override
public boolean equals(Object o) {
- if (o instanceof MessageIdImpl) {
- MessageIdImpl other = (MessageIdImpl) o;
- int batchIndex = (o instanceof BatchMessageIdImpl) ? ((BatchMessageIdImpl) o).batchIndex : NO_BATCH;
- return messageIdEquals(
- this.ledgerId, this.entryId, this.partitionIndex, this.batchIndex,
- other.ledgerId, other.entryId, other.partitionIndex, batchIndex
- );
- } else if (o instanceof TopicMessageIdImpl) {
- return equals(((TopicMessageIdImpl) o).getInnerMessageId());
+ if (o instanceof MessageId) {
+ return compareTo((MessageId) o) == 0;
Review Comment:
Updated. I change the impl in `MultiMessageIdImpl` also since it previous throws exception on type mistach in `equals` which seems unnecessary.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org