diff --git a/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/spi/v1/Subscriber.java b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/spi/v1/Subscriber.java index 902226db408f..047f9c4c6b61 100644 --- a/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/spi/v1/Subscriber.java +++ b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/spi/v1/Subscriber.java @@ -189,7 +189,7 @@ public boolean isRunning() { * } * }, executor); * subscriber.startAsync(); - * + * * // Wait for a stop signal. * done.get(); * subscriber.stopAsync().awaitTerminated(); @@ -466,9 +466,12 @@ private void startConnections( new Runnable() { @Override public void run() { - subscriber.startAsync().awaitRunning(); - subscribersStarting.countDown(); subscriber.addListener(connectionsListener, executor); + try { + subscriber.startAsync().awaitRunning(); + } finally { + subscribersStarting.countDown(); + } } }); }