Search in sources :

Example 1 with AbstractClientHttpRequestFactoryWrapper

use of org.springframework.http.client.AbstractClientHttpRequestFactoryWrapper in project spring-boot by spring-projects.

the class RestTemplateBuilder method unwrapRequestFactoryIfNecessary.

private ClientHttpRequestFactory unwrapRequestFactoryIfNecessary(ClientHttpRequestFactory requestFactory) {
    if (!(requestFactory instanceof AbstractClientHttpRequestFactoryWrapper)) {
        return requestFactory;
    }
    ClientHttpRequestFactory unwrappedRequestFactory = requestFactory;
    Field field = ReflectionUtils.findField(AbstractClientHttpRequestFactoryWrapper.class, "requestFactory");
    ReflectionUtils.makeAccessible(field);
    do {
        unwrappedRequestFactory = (ClientHttpRequestFactory) ReflectionUtils.getField(field, unwrappedRequestFactory);
    } while (unwrappedRequestFactory instanceof AbstractClientHttpRequestFactoryWrapper);
    return unwrappedRequestFactory;
}
Also used : Field(java.lang.reflect.Field) ClientHttpRequestFactory(org.springframework.http.client.ClientHttpRequestFactory) SimpleClientHttpRequestFactory(org.springframework.http.client.SimpleClientHttpRequestFactory) AbstractClientHttpRequestFactoryWrapper(org.springframework.http.client.AbstractClientHttpRequestFactoryWrapper)

Aggregations

Field (java.lang.reflect.Field)1 AbstractClientHttpRequestFactoryWrapper (org.springframework.http.client.AbstractClientHttpRequestFactoryWrapper)1 ClientHttpRequestFactory (org.springframework.http.client.ClientHttpRequestFactory)1 SimpleClientHttpRequestFactory (org.springframework.http.client.SimpleClientHttpRequestFactory)1