artemlivshits commented on code in PR #12006:
URL: https://github.com/apache/kafka/pull/12006#discussion_r845433136


##########
clients/src/main/java/org/apache/kafka/clients/producer/internals/TransactionManager.java:
##########
@@ -187,7 +187,7 @@ private void startSequencesAtBeginning(TopicPartition 
topicPartition, ProducerId
         private static final Comparator<ProducerBatch> 
PRODUCER_BATCH_COMPARATOR = (b1, b2) -> {
             if (b1.baseSequence() < b2.baseSequence()) return -1;
             else if (b1.baseSequence() > b2.baseSequence()) return 1;
-            else return b1.equals(b2) ? 0 : 1;
+            else return b1.equals(b2) ? 0 : Integer.compare(b1.hashCode(), 
b2.hashCode());

Review Comment:
   `ProducerBatch` doesn't override hashCode, so a default implementation is 
used.  It's not fully specified what the default implementation of hashCode has 
to return, but it looks like the suggested implementation is to return a value 
based on the object address, so it should be different for different objects.
   BTW, we could probably just do
   ```
      else return Integer.compare(b1.hashCode(), b2.hashCode());
   ```
   if the objects are equal, their hash code must be equal too.
   
   



-- 
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: jira-unsubscr...@kafka.apache.org

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

Reply via email to