Skip to content

Commit c7ecd2b

Browse files
authored
fix: Do not use directExecutor() for the publish callback when ordering is enabled (#2693)
1 parent c4e10b9 commit c7ecd2b

File tree

1 file changed

+4
-1
lines changed
  • google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1

1 file changed

+4
-1
lines changed

google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/Publisher.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
import java.util.Map;
6767
import java.util.concurrent.Callable;
6868
import java.util.concurrent.CountDownLatch;
69+
import java.util.concurrent.Executor;
6970
import java.util.concurrent.ScheduledExecutorService;
7071
import java.util.concurrent.ScheduledFuture;
7172
import java.util.concurrent.TimeUnit;
@@ -569,6 +570,7 @@ public void onFailure(Throwable t) {
569570
};
570571

571572
ApiFuture<PublishResponse> future;
573+
Executor callbackExecutor = directExecutor();
572574
if (outstandingBatch.orderingKey == null || outstandingBatch.orderingKey.isEmpty()) {
573575
future = publishCall(outstandingBatch);
574576
} else {
@@ -581,8 +583,9 @@ public ApiFuture<PublishResponse> call() {
581583
return publishCall(outstandingBatch);
582584
}
583585
});
586+
callbackExecutor = this.executor;
584587
}
585-
ApiFutures.addCallback(future, futureCallback, directExecutor());
588+
ApiFutures.addCallback(future, futureCallback, callbackExecutor);
586589
}
587590

588591
private final class OutstandingBatch {

0 commit comments

Comments
 (0)