ffang opened a new pull request, #3656: URL: https://github.com/apache/cxf/pull/3656
The JAX-RS failover systests (`CircuitBreakerFailoverTest`, `FailoverTest`, `LoadDistributorTest`) fail intermittently, most often when the whole `failover` package runs. The failures look like this: - `ProcessingException: IOException invoking http://localhost:.../rest/bookstore/books/json/echo: shutdownNow` - `ComparisonFailure: expected:<http://localhost:...3/rest> but was:<http://localhost:...4/work/rest>` #### Cause `AbstractFailoverTest.strategyTest()` and `strategyTestWebClient()` create 20 clients from one `FailoverFeature` and never close them. A `FailoverFeature` gives the same target selector to every client it is applied to. So when the garbage collector finalizes one of the earlier clients, `AbstractClient.close()` closes that shared selector, and with it the conduit the current client is using: ``` Finalizer → AbstractClient.finalize() → AbstractConduitSelector.close() → HttpClientHTTPConduit.close() → shared HttpClient released → shutdownNow() ``` The request in flight then fails with `shutdownNow`, or the failover strategy treats it as a failed server and moves on to another address. Whether it → HttpClientHTTPConduit.close() → shared HttpClient released → shutdownNow() ``` The request in flight then fails with `shutdownNow`, or the failover strategy treats it as a failed server and moves on to another address. Whether it happens depends on when the garbage collector runs, which is why the tests are flaky. #### Fix Close the previous client before creating the next one, so that no client is left for the finalizer to close. The change is test-only. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
