lhotari commented on a change in pull request #9900:
URL: https://github.com/apache/pulsar/pull/9900#discussion_r594368113



##########
File path: 
pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/BaseResources.java
##########
@@ -97,6 +98,28 @@ public void set(String path, Function<T, T> modifyFunction) 
throws MetadataStore
         }
     }
 
+    public void set(String path, OrderedExecutor executor, Function<T, T> 
modifyFunction) throws MetadataStoreException {
+        CompletableFuture<Void> callback = new CompletableFuture<>();
+        // Use orderedExecutor to ensure that
+        // concurrent updates in each path are handled by a single thread
+        executor.executeOrdered(path, () ->

Review comment:
       The object instances aren't technically immutable objects where all 
fields are final. In the "Java Concurrency In Practice" book this type of 
objects are called "effectively immutable objects". According to this book, 
they must be safely published when shared to other threads (In the book "3.5.3 
Safe publication idioms" and "3.5.4 Effectively Immutable Objects" cover the 
topic).
   
   An explicity "lock" isn't necessary, but it continues to be necessary to 
achieve safe publication in a way or another.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to