File tree 2 files changed +23
-15
lines changed
spring-web/src/main/java/org/springframework/web
2 files changed +23
-15
lines changed Original file line number Diff line number Diff line change @@ -195,7 +195,7 @@ private static UriBuilderFactory getUriBuilderFactory(RestTemplate restTemplate)
195
195
UriTemplateHandler uriTemplateHandler = restTemplate .getUriTemplateHandler ();
196
196
if (uriTemplateHandler instanceof DefaultUriBuilderFactory builderFactory ) {
197
197
// only reuse the DefaultUriBuilderFactory if it has been customized
198
- if (builderFactory . hasRestTemplateDefaults ()) {
198
+ if (hasRestTemplateDefaults (builderFactory )) {
199
199
return null ;
200
200
}
201
201
else {
@@ -210,6 +210,19 @@ else if (uriTemplateHandler instanceof UriBuilderFactory builderFactory) {
210
210
}
211
211
}
212
212
213
+
214
+ /**
215
+ * Indicate whether this {@code DefaultUriBuilderFactory} uses the default
216
+ * {@link org.springframework.web.client.RestTemplate RestTemplate} settings.
217
+ */
218
+ private static boolean hasRestTemplateDefaults (DefaultUriBuilderFactory factory ) {
219
+ // see RestTemplate::initUriTemplateHandler
220
+ return (!factory .hasBaseUri () &&
221
+ factory .getEncodingMode () == DefaultUriBuilderFactory .EncodingMode .URI_COMPONENT &&
222
+ CollectionUtils .isEmpty (factory .getDefaultUriVariables ()) &&
223
+ factory .shouldParsePath ());
224
+ }
225
+
213
226
private static ClientHttpRequestFactory getRequestFactory (RestTemplate restTemplate ) {
214
227
ClientHttpRequestFactory requestFactory = restTemplate .getRequestFactory ();
215
228
if (requestFactory instanceof InterceptingClientHttpRequestFactory interceptingClientHttpRequestFactory ) {
Original file line number Diff line number Diff line change @@ -83,6 +83,15 @@ public DefaultUriBuilderFactory(UriComponentsBuilder baseUri) {
83
83
}
84
84
85
85
86
+ /**
87
+ * Determine whether this factory has been configured with a base URI.
88
+ * @since 6.1.4
89
+ * @see #DefaultUriBuilderFactory()
90
+ */
91
+ public final boolean hasBaseUri () {
92
+ return (this .baseUri != null );
93
+ }
94
+
86
95
/**
87
96
* Set the {@link EncodingMode encoding mode} to use.
88
97
* <p>By default this is set to {@link EncodingMode#TEMPLATE_AND_VALUES
@@ -157,20 +166,6 @@ public boolean shouldParsePath() {
157
166
return this .parsePath ;
158
167
}
159
168
160
- /**
161
- * Indicates whether this {@code DefaultUriBuilderFactory} uses the default
162
- * {@link org.springframework.web.client.RestTemplate RestTemplate}
163
- * settings.
164
- * @since 6.1.4
165
- */
166
- public boolean hasRestTemplateDefaults () {
167
- // see RestTemplate::initUriTemplateHandler
168
- return this .baseUri == null &&
169
- this .encodingMode == EncodingMode .URI_COMPONENT &&
170
- CollectionUtils .isEmpty (this .defaultUriVariables ) &&
171
- this .parsePath ;
172
- }
173
-
174
169
175
170
// UriTemplateHandler
176
171
You can’t perform that action at this time.
0 commit comments