You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kafka.apache.org by sh...@apache.org on 2022/04/09 03:03:05 UTC
[kafka] branch 3.2 updated: KAFKA-13794: Follow up to fix producer batch comparator (#12006)
This is an automated email from the ASF dual-hosted git repository.
showuon pushed a commit to branch 3.2
in repository https://gitbox.apache.org/repos/asf/kafka.git
The following commit(s) were added to refs/heads/3.2 by this push:
new 1483a86591 KAFKA-13794: Follow up to fix producer batch comparator (#12006)
1483a86591 is described below
commit 1483a86591e9143f0f2ffe097e068e5a5e493092
Author: Xiaoyue Xue <28...@qq.com>
AuthorDate: Sat Apr 9 10:58:16 2022 +0800
KAFKA-13794: Follow up to fix producer batch comparator (#12006)
In comparator, objects that are not equal need to have a stable order otherwise, binary search may not find the objects. Improve the producer batch comparator
Reviewers: Luke Chen <sh...@gmail.com>
---
.../org/apache/kafka/clients/producer/internals/TransactionManager.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clients/src/main/java/org/apache/kafka/clients/producer/internals/TransactionManager.java b/clients/src/main/java/org/apache/kafka/clients/producer/internals/TransactionManager.java
index aef6cfda8e..f4afc5369a 100644
--- a/clients/src/main/java/org/apache/kafka/clients/producer/internals/TransactionManager.java
+++ b/clients/src/main/java/org/apache/kafka/clients/producer/internals/TransactionManager.java
@@ -187,7 +187,7 @@ public class TransactionManager {
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 Integer.compare(b1.hashCode(), b2.hashCode());
};
TopicPartitionEntry() {