Skip to content

Commit 1a8ef60

Browse files
fix: ShimImpl uses shutdownAndAwait for userCallbackExecutor
ShimImpl registered its userCallbackExecutor with a bare shutdown() closer, while Client.create's path uses shutdownAndAwait (which gives in-flight listener.onClose tasks a 5-second drain window before shutdownNow). On ShimImpl close, queued callbacks were abandoned mid-flight — fine for quiescent shutdowns but a regression for fast-close patterns (test boundaries, dynamic config reloads) where in-flight callbacks have not yet drained. Promote Client.shutdownAndAwait from private-static to public-static so ShimImpl (different package) can reuse the same shutdown semantics, and update ShimImpl to call it.
1 parent a343ed6 commit 1a8ef60

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

  • java-bigtable/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/internal

java-bigtable/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/internal/api/Client.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -397,8 +397,10 @@ public T get() {
397397
}
398398

399399
// Drain in-flight listener.onClose tasks before the executor is shut down; bound the wait at 5s
400-
// so close() doesn't hang the caller on a pathological listener.
401-
private static void shutdownAndAwait(ExecutorService exec) {
400+
// so close() doesn't hang the caller on a pathological listener. Public so the compat
401+
// ShimImpl (different package) can reuse the same shutdown semantics for the user-callback
402+
// executor it owns.
403+
public static void shutdownAndAwait(ExecutorService exec) {
402404
exec.shutdown();
403405
try {
404406
if (!exec.awaitTermination(5, TimeUnit.SECONDS)) {

java-bigtable/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/internal/compat/ShimImpl.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,8 @@ public static Shim create(
178178
Resource.createShared(metrics),
179179
Resource.createShared(configManager),
180180
Resource.createShared(bgExecutor),
181-
Resource.createOwned(userCallbackExecutor, userCallbackExecutor::shutdown));
181+
Resource.createOwned(
182+
userCallbackExecutor, () -> Client.shutdownAndAwait(userCallbackExecutor)));
182183

183184
return new ShimImpl(configManager, client);
184185
}

0 commit comments

Comments
 (0)