BewareMyPower commented on code in PR #21162:
URL: https://github.com/apache/pulsar/pull/21162#discussion_r1321738595
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/SystemTopicTxnBufferSnapshotService.java:
##########
@@ -108,6 +112,20 @@ public CompletableFuture<SystemTopicClient.Reader<T>>
createReader(TopicName top
return
getTransactionBufferSystemTopicClient(topicName.getNamespaceObject()).newReaderAsync();
}
+ public CompletableFuture<TableView<T>> getTableView(TopicName topicName) {
+ if (tableViewMap.containsKey(topicName.getNamespaceObject())) {
+ return tableViewMap.get(topicName.getNamespaceObject());
+ } else {
+ synchronized (tableViewMap) {
+ if (tableViewMap.containsKey(topicName.getNamespaceObject())) {
+ return tableViewMap.get(topicName.getNamespaceObject());
+ } else {
+ return
getTransactionBufferSystemTopicClient(topicName.getNamespaceObject()).getTableView();
+ }
+ }
+ }
Review Comment:
It's not thread safe. There is no guarantee for what will happen when
calling any method on a `HashMap` is accessed by multiple threads.
It's different from the double-check locking case because a volatile
variable has the visibility and it's applied by the happens-before rule. While
there is no concurrent guarantee on a `HashMap`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]