@@ -361,18 +361,22 @@ void testInvalidatePrincipalCacheEntriesWithUserTokenExchangeDestination()
361361
362362 @ SneakyThrows
363363 @ Test
364- void testHttpClientWrapperWithDestinationIsCalledWhenDestinationIsProvided ()
364+ void testHttpClientWrapperOutlivesGarbageCollector ()
365365 {
366366 final DefaultHttpDestination destination1 = DefaultHttpDestination .builder ("http://foo.com" ).build ();
367367 final HttpClient client1 = sut .tryGetHttpClient (destination1 , FACTORY ).get ();
368368 assertThat (((HttpClientWrapper ) client1 ).getDestination ()).isSameAs (destination1 );
369369
370- final DefaultHttpDestination destination2 = DefaultHttpDestination .builder ("http://foo.com" ).build ();
370+ final DefaultHttpDestination destination2 =
371+ DefaultHttpDestination
372+ .builder ("http://foo.com" )
373+ .headerProviders (c -> List .of (new Header ("Authorization" , "Bearer foo" )))
374+ .build ();
371375 final HttpClient client2 = sut .tryGetHttpClient (destination2 , FACTORY ).get ();
372376 assertThat (((HttpClientWrapper ) client2 ).getDestination ()).isSameAs (destination2 );
373377
374378 // Verify the destinations are equal but not the same reference
375- assertThat (destination1 ).isEqualTo (destination2 );
379+ assertThat (destination1 ).isEqualTo (destination2 ); // header providers are not part of the equality check
376380 assertThat (destination1 ).isNotSameAs (destination2 );
377381
378382 // Http clients are distinct instances, since the cache key contains the destination reference and not its content
@@ -383,7 +387,7 @@ void testHttpClientWrapperWithDestinationIsCalledWhenDestinationIsProvided()
383387 assertThat (client1Again ).isSameAs (client1 );
384388 assertThat (((HttpClientWrapper ) client1Again ).getDestination ()).isSameAs (destination1 );
385389
386- // simulate garbage collection
390+ // simulate garbage collection on client1
387391 ((HttpClientWrapper ) client1 ).close ();
388392
389393 // since client1 inherited client2 connection manager, client2 is shut down as well
0 commit comments