Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed bug where a null endpoint is returned (#5281)
Motivation: While fixing #5163, I made a bug that `EndpointSelector` returns a null endpoint due to a race condition between an EndpointGroup initialization event and `EndpointSelector.select()`. ``` Caused by: com.linecorp.armeria.client.endpoint.EndpointSelectionTimeoutException: Failed to select within 3200 ms an endpoint from: HealthCheckedEndpointGroup{endpoints=[Endpoint{127.0.0.1:46843, weight=1000}], numEndpoints=1, candidates=[Endpoint{127.0.0.1:46843, weight=1000}], numCandidates=1, selectionStrategy=class com.linecorp.armeria.client.endpoint.WeightedRoundRobinStrategy, initialized=true, initialSelectionTimeoutMillis=15000, selectionTimeoutMillis=3200, contextGroupChain=[HealthCheckContextGroup{contexts={Endpoint{127.0.0.1:46843, weight=1000}=DefaultHealthCheckerContext{originalEndpoint=Endpoint{127.0.0.1:46843, weight=1000}, endpoint=Endpoint{127.0.0.1:46843, weight=1000}, initializationStarted=true, initialized=true, destroyed=false, refCnt=1}}, candidates=[Endpoint{127.0.0.1:46843, weight=1000}], initialized=true}]} at app//com.linecorp.armeria.client.endpoint.EndpointSelectionTimeoutException.get(EndpointSelectionTimeoutException.java:48) at app//com.linecorp.armeria.client.endpoint.AbstractEndpointSelector.lambda$select$0(AbstractEndpointSelector.java:105) ``` If a `ListeningFuture` is added to `pendingFutures` after an `EndpointGroup` update event is delivered, `listeningFuture` may not be completed within a selection timeout. Modifications: - Check if an `EndpointGroup` completes after adding `ListeningFuture` to `pendingFutures`. Result: You no longer see `EndpointSelectionTimeoutException` when selecting an `Endpoint` from an `EndpointGroup`.
- Loading branch information