GrpclbLoadBalancer extends LoadBalancer<T> { @Override public void shutdown() { InterimTransport<T> savedInterimTransport; synchronized (lock) { if (closed) { return; } closed = true; if (lbRequestWriter != null) { lbRequestWriter.onCompleted(); } savedInterimTransport = interimTransport; interimTransport = null; executor = SharedResourceHolder.release(GrpcUtil.SHARED_CHANNEL_EXECUTOR, executor); } if (savedInterimTransport != null) { savedInterimTransport.closeWithError(SHUTDOWN_STATUS); } } GrpclbLoadBalancer(String serviceName, TransportManager<T> tm); @Override T pickTransport(Attributes affinity); @Override void handleResolvedAddresses(
      List<ResolvedServerInfo> updatedServers, Attributes config); @Override void handleNameResolutionError(Status error); @Override void shutdown(); @Override void handleTransportShutdown(EquivalentAddressGroup addressGroup, Status status);  }
@Test public void shutdown() throws Exception { simulateLbAddressResolved(30001); assertNotNull(loadBalancer.sentLbRequests.poll(1000, TimeUnit.SECONDS)); List<ResolvedServerInfo> serverList = createResolvedServerInfoList(4000, 4001); loadBalancer.getLbResponseObserver().onNext(buildLbResponse(serverList)); verify(mockTransportManager).getTransport(eq(lbAddressGroup)); assertEquals(buildRoundRobinList(serverList), loadBalancer.getRoundRobinServerList().getList()); loadBalancer.shutdown(); loadBalancer.getLbResponseObserver().onError(Status.CANCELLED.asException()); assertEquals(0, loadBalancer.sentLbRequests.size()); loadBalancer.handleTransportShutdown(lbAddressGroup, Status.CANCELLED); verify(mockTransportManager).getTransport(any(EquivalentAddressGroup.class)); }