3131import com .google .cloud .pubsub .spi .v1 .SubscriberSettings ;
3232import com .google .common .base .Function ;
3333import com .google .common .collect .Sets ;
34+ import com .google .common .util .concurrent .ForwardingListenableFuture ;
3435import com .google .common .util .concurrent .FutureCallback ;
3536import com .google .common .util .concurrent .Futures ;
3637import com .google .common .util .concurrent .ListenableFuture ;
6465
6566import java .io .IOException ;
6667import java .util .Set ;
67- import java .util .concurrent .ExecutionException ;
6868import java .util .concurrent .Future ;
6969import java .util .concurrent .ScheduledExecutorService ;
70- import java .util .concurrent .TimeUnit ;
71- import java .util .concurrent .TimeoutException ;
7270
7371public class DefaultPubSubRpc implements PubSubRpc {
7472
@@ -93,43 +91,17 @@ protected ExecutorFactory executorFactory() {
9391 }
9492 }
9593
96- private static final class PullFutureImpl implements PullFuture {
97-
98- private final ListenableFuture < PullResponse > delegate ;
94+ private static final class PullFutureImpl
95+ extends ForwardingListenableFuture . SimpleForwardingListenableFuture < PullResponse >
96+ implements PullFuture {
9997
10098 PullFutureImpl (ListenableFuture <PullResponse > delegate ) {
101- this .delegate = delegate ;
102- }
103-
104- @ Override
105- public boolean cancel (boolean mayInterruptIfRunning ) {
106- return delegate .cancel (mayInterruptIfRunning );
107- }
108-
109- @ Override
110- public boolean isCancelled () {
111- return delegate .isCancelled ();
112- }
113-
114- @ Override
115- public boolean isDone () {
116- return delegate .isDone ();
117- }
118-
119- @ Override
120- public PullResponse get () throws InterruptedException , ExecutionException {
121- return delegate .get ();
122- }
123-
124- @ Override
125- public PullResponse get (long timeout , TimeUnit unit ) throws InterruptedException ,
126- ExecutionException , TimeoutException {
127- return delegate .get (timeout , unit );
99+ super (delegate );
128100 }
129101
130102 @ Override
131103 public void addCallback (final PullCallback callback ) {
132- Futures .addCallback (delegate , new FutureCallback <PullResponse >() {
104+ Futures .addCallback (delegate () , new FutureCallback <PullResponse >() {
133105 @ Override
134106 public void onSuccess (PullResponse result ) {
135107 callback .success (result );
0 commit comments