From 642adfd79fffb0e47bc410a02435e85ba676496b Mon Sep 17 00:00:00 2001 From: Jeff Xiang Date: Wed, 23 Oct 2024 17:17:47 -0400 Subject: [PATCH] Convert hashmap to concurrenthashmap in TransactionManagerUtils --- .../psc/producer/transaction/TransactionManagerUtils.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/psc/src/main/java/com/pinterest/psc/producer/transaction/TransactionManagerUtils.java b/psc/src/main/java/com/pinterest/psc/producer/transaction/TransactionManagerUtils.java index 7e39708..938b920 100644 --- a/psc/src/main/java/com/pinterest/psc/producer/transaction/TransactionManagerUtils.java +++ b/psc/src/main/java/com/pinterest/psc/producer/transaction/TransactionManagerUtils.java @@ -4,8 +4,8 @@ import com.pinterest.psc.producer.transaction.kafka.KafkaTransactionManagerOperator; import org.apache.kafka.clients.producer.internals.TransactionManager; -import java.util.HashMap; import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.Future; /** @@ -21,7 +21,7 @@ */ public class TransactionManagerUtils { - private static final Map TXN_MANAGER_CLASSNAME_TO_OPERATOR = new HashMap<>(); + private static final Map TXN_MANAGER_CLASSNAME_TO_OPERATOR = new ConcurrentHashMap<>(); private static TransactionManagerOperator getOrCreateTransactionManagerOperator(Object transactionManager) { return TXN_MANAGER_CLASSNAME_TO_OPERATOR.computeIfAbsent(transactionManager.getClass().getName(), className -> {