@Test
    void testNullSelectedEndpoint() {
        final EndpointSelector nullEndpointSelector = new EndpointSelector() {
            @Nullable
            @Override
            public Endpoint selectNow(ClientRequestContext ctx) {
                // Intentionally return null to simulate that the EndpointGroup become empty when
                // initializing context. for case 2)
                return null;
            }

            @Override
            public CompletableFuture<Endpoint> select(ClientRequestContext ctx,
                                                      ScheduledExecutorService executor, long timeoutMillis) {
                final CompletableFuture<Endpoint> future = new CompletableFuture<>();
                future.completeExceptionally(new AnticipatedException("no endpoint"));
                return future;
            }
        };

        final EndpointSelectionStrategy strategy = endpointGroup -> nullEndpointSelector;
        final LazyEndpointGroup endpointGroup = new LazyEndpointGroup(strategy);
        // Make non-empty EndpointGroup for case 1)
        endpointGroup.add(Endpoint.of("foo"));

        final TestServiceStub client =
                GrpcClients.builder(SessionProtocol.HTTP, endpointGroup)
                           .build(TestServiceStub.class);

        final AtomicBoolean completed = new AtomicBoolean();
        final AtomicReference<Throwable> causeRef = new AtomicReference<>();

        client.unaryCall(SimpleRequest.getDefaultInstance(),
                         new StreamObserver<SimpleResponse>() {
                             @Override
                             public void onNext(SimpleResponse value) {}

                             @Override
                             public void onError(Throwable t) {
                                 causeRef.set(t);
                                 completed.set(true);
                             }

                             @Override
                             public void onCompleted() {}
                         });

        // A call does not immediately fail.
        await().untilTrue(completed);
        assertThat(causeRef.get()).isInstanceOf(StatusRuntimeException.class)
                                  .hasCauseInstanceOf(UnprocessedRequestException.class)
                                  .hasRootCauseInstanceOf(AnticipatedException.class);
    }
Reproduce a race case about an endpoint selection that occurs if the following two conditions are met.
1) An EndpointGroup resolved and has non-empty endpoints when creating a ArmeriaClientCall.
2) The endpoints in the EndpointGroup become empty when the ArmeriaClientCall initializing context.
grpc/src/test/java/com/linecorp/armeria/client/grpc/LazyDynamicEndpointGroupTest.java