Warn against custom request factories in RestTemplateBuilder
This commit adds a javadoc note about a usability issue described in gh-11255. While `RestTemplateBuilder` is an immutable class, providing a custom instance of request factory and deriving several builders/templates from that point may have some unexpected behavior, since that instance is shared amongst builders instances. This issue is fixed in Spring Boot 2.0 with a replacement method that leverages a `Supplier<ClientHttpRequestFactory>` instead. See gh-11255
This commit is contained in:
@@ -337,6 +337,8 @@ public class RestTemplateBuilder {
|
||||
/**
|
||||
* Set the {@link ClientHttpRequestFactory} that should be used with the
|
||||
* {@link RestTemplate}.
|
||||
* <p>Note that this request factory will be shared with all builder instances
|
||||
* derived from that point.
|
||||
* @param requestFactory the request factory to use
|
||||
* @return a new builder instance
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user