You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2021/09/27 07:08:59 UTC

[GitHub] [pulsar] eolivelli commented on a change in pull request #12190: PIP-45: On LockResource.updateValue() revalidate the lock if needed

eolivelli commented on a change in pull request #12190:
URL: https://github.com/apache/pulsar/pull/12190#discussion_r716409181



##########
File path: pulsar-metadata/src/main/java/org/apache/pulsar/metadata/coordination/impl/ResourceLockImpl.java
##########
@@ -218,18 +205,22 @@ synchronized void lockWasInvalidated() {
         if (revalidateAfterReconnection) {
             revalidateAfterReconnection = false;
             log.warn("Revalidate lock at {} after reconnection", path);
-            return revalidate();
+            return revalidate(value);
         } else {
             return CompletableFuture.completedFuture(null);
         }
     }
 
-    synchronized CompletableFuture<Void> revalidate() {
+    synchronized CompletableFuture<Void> revalidate(T newValue) {
         return store.get(path)
                 .thenCompose(optGetResult -> {
                     if (!optGetResult.isPresent()) {
                         // The lock just disappeared, try to acquire it again
-                        return acquireWithNoRevalidation()
+                        synchronized (ResourceLockImpl.this) {

Review comment:
       May it be useful to have a synchonized setVersion() method to reduce code duplication and it will make code more readable?




-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org