Denovo1998 commented on code in PR #25066:
URL: https://github.com/apache/pulsar/pull/25066#discussion_r2616090617
##########
pulsar-proxy/src/main/java/org/apache/pulsar/proxy/server/LookupProxyHandler.java:
##########
@@ -392,7 +393,7 @@ private void internalPerformGetTopicsOfNamespace(long
clientRequestId, String na
return
CompletableFuture.completedFuture(null);
});
}
- }).thenApply(__ -> null);
+ });
Review Comment:
@lhotari It seems there might be some issues here?
The callback of handle returns a CompletableFuture<Void> (the success branch
returns withUpdatedPermits(...), and the failure branch returns
completedFuture(null)), so the overall return type of handle will become
nested: CompletableFuture<CompletableFuture<Void>> (the "result" of the outer
future is the inner future)
This "outer future" will be completed at the moment when the broker request
is finished and the handle callback returns the "inner future"; this will cause
withAcquiredPermits to think that the "future returned by the function is
completed", thereby prematurely releasing initial permits.
Perhaps need
```java
}).thenCompose(future -> future);
```
Make the final return value a CompletableFuture<Void>, and it should only be
considered complete after the "inner future" is also finished. This way,
withAcquiredPermits will hold the initial permits until withUpdatedPermits(...)
(and subsequent write-back of the response) is truly finished.
--
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]