|
|
|
@ -16,6 +16,7 @@
|
|
|
|
|
|
|
|
|
|
package org.springframework.boot.web.client;
|
|
|
|
|
|
|
|
|
|
import java.lang.reflect.Constructor;
|
|
|
|
|
import java.lang.reflect.Field;
|
|
|
|
|
import java.lang.reflect.Method;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
@ -317,7 +318,19 @@ public class RestTemplateBuilder {
|
|
|
|
|
public RestTemplateBuilder requestFactory(
|
|
|
|
|
Class<? extends ClientHttpRequestFactory> requestFactory) {
|
|
|
|
|
Assert.notNull(requestFactory, "RequestFactory must not be null");
|
|
|
|
|
return requestFactory(BeanUtils.instantiate(requestFactory));
|
|
|
|
|
return requestFactory(createRequestFactory(requestFactory));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private ClientHttpRequestFactory createRequestFactory(
|
|
|
|
|
Class<? extends ClientHttpRequestFactory> requestFactory) {
|
|
|
|
|
try {
|
|
|
|
|
Constructor<?> constructor = requestFactory.getDeclaredConstructor();
|
|
|
|
|
constructor.setAccessible(true);
|
|
|
|
|
return (ClientHttpRequestFactory) constructor.newInstance();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex) {
|
|
|
|
|
throw new IllegalStateException(ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|