diff --git a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/web/client/TestRestTemplate.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/web/client/TestRestTemplate.java index cf8368bf4f..4c9e845d2e 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/web/client/TestRestTemplate.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/web/client/TestRestTemplate.java @@ -138,8 +138,8 @@ public class TestRestTemplate { HttpClientOption... httpClientOptions) { Assert.notNull(restTemplate, "RestTemplate must not be null"); this.httpClientOptions = httpClientOptions; - if (getRequestFactoryClass(restTemplate).getName().equals( - "org.springframework.http.client.HttpComponentsClientHttpRequestFactory")) { + if (getRequestFactoryClass(restTemplate).isAssignableFrom( + HttpComponentsClientHttpRequestFactory.class)) { restTemplate.setRequestFactory( new CustomHttpComponentsClientHttpRequestFactory(httpClientOptions)); }