@@ -670,22 +670,22 @@ public synchronized Runnable start(ManagedClientTransport.Listener clientTranspo
670670
671671 @ GuardedBy ("this" )
672672 private void preAuthorizeServer () {
673- ServiceInfo serviceInfo = serviceBinding .resolve ();
673+ ServiceInfo serviceInfo ;
674+ try {
675+ serviceInfo = serviceBinding .resolve ();
676+ } catch (StatusException e ) {
677+ shutdownInternal (e .getStatus (), true );
678+ return ;
679+ }
674680
675- // It's unlikely, but in theory the server identity/existence represented by this ServiceInfo
676- // could change by the time we actually bind/ connect. It doesn't matter though, because:
681+ // It's unlikely, but the server identity/existence of this Service could change by the time
682+ // we actually connect. It doesn't matter though, because:
677683 // - If pre-auth fails (but would succeed for the new identity), grpc-core will retry
678684 // against the replacement server using a new instance of BinderClientTransport.
679685 // - If pre-auth succeeds (but would fail for the new identity), we might incorrectly bind
680- // to an unauthorized server, but we'll notice when we the SecurityPolicy again as part of the
681- // usual handshake.
682- if (serviceInfo == null ) {
683- preAuthResultFuture =
684- Futures .immediateFuture (
685- Status .UNIMPLEMENTED .withDescription ("resolveService() was null" ));
686- } else {
687- preAuthResultFuture = checkServerAuthorizationAsync (serviceInfo .applicationInfo .uid );
688- }
686+ // to an unauthorized server, but we'll notice when we check SecurityPolicy again as part of
687+ // the usual handshake.
688+ preAuthResultFuture = checkServerAuthorizationAsync (serviceInfo .applicationInfo .uid );
689689 Futures .addCallback (
690690 preAuthResultFuture ,
691691 new FutureCallback <Status >() {
0 commit comments