This is an automated email from the ASF dual-hosted git repository.
sijie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar.git
The following commit(s) were added to refs/heads/master by this push:
new 26fd380 fix Double-Checked locking using volatile (#8475)
26fd380 is described below
commit 26fd38009ef6b3746f3072ce156a9e83c882e0d5
Author: feynmanlin <[email protected]>
AuthorDate: Sun Nov 8 16:44:18 2020 +0800
fix Double-Checked locking using volatile (#8475)
```java
private void createSystemTopicFactoryIfNeeded() {
if (namespaceEventsSystemTopicFactory == null) {
synchronized (this) {
if (namespaceEventsSystemTopicFactory == null) {
try {
namespaceEventsSystemTopicFactory = new
NamespaceEventsSystemTopicFactory(pulsarService.getClient());
} catch (PulsarServerException e) {
log.error("Create namespace event system topic
factory error.", e);
}
}
}
}
}
```
The creation of `namespaceEventsSystemTopicFactory` uses double-check
locking, but does not add volatile
---
.../pulsar/broker/service/SystemTopicBasedTopicPoliciesService.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git
a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/SystemTopicBasedTopicPoliciesService.java
b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/SystemTopicBasedTopicPoliciesService.java
index 1f10827..2627f4d 100644
---
a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/SystemTopicBasedTopicPoliciesService.java
+++
b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/SystemTopicBasedTopicPoliciesService.java
@@ -53,7 +53,7 @@ import java.util.concurrent.atomic.AtomicInteger;
public class SystemTopicBasedTopicPoliciesService implements
TopicPoliciesService {
private final PulsarService pulsarService;
- private NamespaceEventsSystemTopicFactory
namespaceEventsSystemTopicFactory;
+ private volatile NamespaceEventsSystemTopicFactory
namespaceEventsSystemTopicFactory;
private final Map<TopicName, TopicPolicies> policiesCache = new
ConcurrentHashMap<>();