poorbarcode commented on code in PR #23163:
URL: https://github.com/apache/pulsar/pull/23163#discussion_r1715048757
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentSubscription.java:
##########
@@ -794,18 +806,13 @@ public void findEntryFailed(ManagedLedgerException
exception,
}
@Override
- public CompletableFuture<Void> resetCursor(Position position) {
- CompletableFuture<Void> future = new CompletableFuture<>();
- resetCursor(position, future);
- return future;
- }
-
- private void resetCursor(Position finalPosition, CompletableFuture<Void>
future) {
+ public CompletableFuture<Void> resetCursor(Position finalPosition) {
if (!IS_FENCED_UPDATER.compareAndSet(PersistentSubscription.this,
FALSE, TRUE)) {
- future.completeExceptionally(new SubscriptionBusyException("Failed
to fence subscription"));
- return;
+ return CompletableFuture.failedFuture(new
SubscriptionBusyException("Failed to fence subscription"));
}
+ final CompletableFuture<Void> future = new CompletableFuture<>();;
Review Comment:
fixed
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentSubscription.java:
##########
@@ -220,6 +221,16 @@ public boolean setReplicated(boolean replicated) {
@Override
public CompletableFuture<Void> addConsumer(Consumer consumer) {
+ CompletableFuture<Void> inProgressResetCursorFuture =
this.inProgressResetCursorFuture;
+ if (inProgressResetCursorFuture != null) {
+ return inProgressResetCursorFuture.thenCompose(ignore ->
addConsumerInternal(consumer))
+ .exceptionallyCompose(ex -> addConsumerInternal(consumer));
Review Comment:
Improved
--
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]