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:
Brian Clozel
2018-01-05 16:24:34 +01:00
parent a4134b8491
commit 966d4251a4

View File

@@ -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
*/