Add test verifying newClient() rebuilds after shutdown

Signed-off-by: Prahlad Bhakat <prahladbhakat05@gmail.com>
This commit is contained in:
Prahlad Bhakat
2026-09-10 18:37:02 +05:30
parent cc51cd8735
commit 6cc39452dc
@@ -92,4 +92,20 @@ class RestClientTransportClientFactoryShutdownTests {
return ((HttpComponentsClientHttpRequestFactory) requestFactory).getHttpClient();
}
@Test
void newClientAfterShutdownShouldCreateANewCachedRequestFactory() {
factory.newClient(endpoint());
Object httpClientBeforeShutdown = cachedHttpClient(factory);
factory.shutdown();
factory.newClient(endpoint());
Object httpClientAfterShutdown = cachedHttpClient(factory);
// shutdown() clears the cached request factory, so a subsequent newClient()
// call must lazily build a fresh one rather than reusing the client that was
// just closed.
assertThat(httpClientAfterShutdown).isNotSameAs(httpClientBeforeShutdown);
}
}