Skip to content

Commit f0e97f4

Browse files
authored
[improve][broker] Use immutable base cursor properties (apache#20400)
1 parent 25c4b7c commit f0e97f4

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentSubscription.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,18 +120,15 @@ public class PersistentSubscription extends AbstractSubscription implements Subs
120120
// Map of properties that is used to mark this subscription as "replicated".
121121
// Since this is the only field at this point, we can just keep a static
122122
// instance of the map.
123-
private static final Map<String, Long> REPLICATED_SUBSCRIPTION_CURSOR_PROPERTIES = new TreeMap<>();
124-
private static final Map<String, Long> NON_REPLICATED_SUBSCRIPTION_CURSOR_PROPERTIES = Collections.emptyMap();
123+
private static final Map<String, Long> REPLICATED_SUBSCRIPTION_CURSOR_PROPERTIES =
124+
Map.of(REPLICATED_SUBSCRIPTION_PROPERTY, 1L);
125+
private static final Map<String, Long> NON_REPLICATED_SUBSCRIPTION_CURSOR_PROPERTIES = Map.of();
125126

126127
private volatile ReplicatedSubscriptionSnapshotCache replicatedSubscriptionSnapshotCache;
127128
private final PendingAckHandle pendingAckHandle;
128129
private volatile Map<String, String> subscriptionProperties;
129130
private volatile CompletableFuture<Void> fenceFuture;
130131

131-
static {
132-
REPLICATED_SUBSCRIPTION_CURSOR_PROPERTIES.put(REPLICATED_SUBSCRIPTION_PROPERTY, 1L);
133-
}
134-
135132
static Map<String, Long> getBaseCursorProperties(boolean isReplicated) {
136133
return isReplicated ? REPLICATED_SUBSCRIPTION_CURSOR_PROPERTIES : NON_REPLICATED_SUBSCRIPTION_CURSOR_PROPERTIES;
137134
}

0 commit comments

Comments
 (0)