Skip to content

Commit 966d425

Browse files
committed
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
1 parent a4134b8 commit 966d425

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

spring-boot/src/main/java/org/springframework/boot/web/client/RestTemplateBuilder.java

+2
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,8 @@ private ClientHttpRequestFactory createRequestFactory(
337337
/**
338338
* Set the {@link ClientHttpRequestFactory} that should be used with the
339339
* {@link RestTemplate}.
340+
* <p>Note that this request factory will be shared with all builder instances
341+
* derived from that point.
340342
* @param requestFactory the request factory to use
341343
* @return a new builder instance
342344
*/

0 commit comments

Comments
 (0)