From 04423bad12a4a3bb02e5345937bfcc8066c0296d Mon Sep 17 00:00:00 2001 From: rayluoluo Date: Fri, 10 Jan 2025 10:12:42 +0800 Subject: [PATCH] [improve][broker] Improve the extensibility of the TopicBundleAssignmentStrategy interface class (#23773) --- .../naming/ConsistentHashingTopicBundleAssigner.java | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/common/naming/ConsistentHashingTopicBundleAssigner.java b/pulsar-broker/src/main/java/org/apache/pulsar/common/naming/ConsistentHashingTopicBundleAssigner.java index ec19708948619..7ff6f3194a02f 100644 --- a/pulsar-broker/src/main/java/org/apache/pulsar/common/naming/ConsistentHashingTopicBundleAssigner.java +++ b/pulsar-broker/src/main/java/org/apache/pulsar/common/naming/ConsistentHashingTopicBundleAssigner.java @@ -28,8 +28,6 @@ public class ConsistentHashingTopicBundleAssigner implements TopicBundleAssignmentStrategy { private PulsarService pulsar; - private volatile HashFunction hashFunction; - @Override public NamespaceBundle findBundle(TopicName topicName, NamespaceBundles namespaceBundles) { NamespaceBundle bundle = namespaceBundles.getBundle(calculateBundleHashCode(topicName)); @@ -41,10 +39,7 @@ public NamespaceBundle findBundle(TopicName topicName, NamespaceBundles namespac @Override public long calculateBundleHashCode(TopicName topicName) { - if (hashFunction == null) { - hashFunction = getBundleHashFunc(); - } - return hashFunction.hashString(topicName.toString(), StandardCharsets.UTF_8).padToLong(); + return getBundleHashFunc().hashString(topicName.toString(), StandardCharsets.UTF_8).padToLong(); } @Override