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 2021/02/03 05:31:17 UTC

[GitHub] [pulsar] merlimat commented on a change in pull request #9440: [Issue 9438][pulsar-client] Fix inconsistent equals and hashCode for MessageIds

merlimat commented on a change in pull request #9440:
URL: https://github.com/apache/pulsar/pull/9440#discussion_r569141846



##########
File path: pulsar-client/src/main/java/org/apache/pulsar/client/impl/MessageIdImpl.java
##########
@@ -63,17 +78,17 @@ public int getPartitionIndex() {
 
     @Override
     public int hashCode() {
-        return (int) (31 * (ledgerId + 31 * entryId) + partitionIndex);
+        return Objects.hash(ledgerId, entryId, partitionIndex, batchIndex);

Review comment:
       This call will involve several allocations on the heap, because `Objects.hash()` takes a `Object[]` and all the longs also need to get boxes into `Long` instances.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org