Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,9 @@
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableMap;
import com.google.pubsub.v1.GetSubscriptionRequest;
import com.google.pubsub.v1.ProjectSubscriptionName;
import com.google.pubsub.v1.SubscriberGrpc;
import com.google.pubsub.v1.SubscriberGrpc.SubscriberFutureStub;
import com.google.pubsub.v1.SubscriberGrpc.SubscriberStub;
import com.google.pubsub.v1.Subscription;
import io.grpc.CallCredentials;
import io.grpc.Channel;
import io.grpc.auth.MoreCallCredentials;
Expand All @@ -56,7 +53,6 @@
import java.util.Map;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.Nullable;
Expand Down Expand Up @@ -301,7 +297,7 @@ protected void doStart() {
@Override
public void run() {
try {
startStreamingConnections();
startStreamingConnections();
notifyStarted();
} catch (Throwable t) {
notifyFailed(t);
Expand All @@ -313,16 +309,23 @@ public void run() {

@Override
protected void doStop() {
// stop connection is no-op if connections haven't been started.
stopAllStreamingConnections();
try {
for (AutoCloseable closeable : closeables) {
closeable.close();
}
notifyStopped();
} catch (Exception e) {
notifyFailed(e);
}
new Thread(
new Runnable() {
@Override
public void run() {
try {
// stop connection is no-op if connections haven't been started.
stopAllStreamingConnections();
for (AutoCloseable closeable : closeables) {
closeable.close();
}
notifyStopped();
} catch (Exception e) {
notifyFailed(e);
}
}
})
.start();
}

private void startStreamingConnections() throws IOException {
Expand Down