Replace public hasRestTemplateDefaults() method with hasBaseUri()
See gh-32180
This commit is contained in:
parent
d8c4a33bea
commit
81c156eefb
|
@ -195,7 +195,7 @@ final class DefaultRestClientBuilder implements RestClient.Builder {
|
|||
UriTemplateHandler uriTemplateHandler = restTemplate.getUriTemplateHandler();
|
||||
if (uriTemplateHandler instanceof DefaultUriBuilderFactory builderFactory) {
|
||||
// only reuse the DefaultUriBuilderFactory if it has been customized
|
||||
if (builderFactory.hasRestTemplateDefaults()) {
|
||||
if (hasRestTemplateDefaults(builderFactory)) {
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
|
@ -210,6 +210,19 @@ final class DefaultRestClientBuilder implements RestClient.Builder {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Indicate whether this {@code DefaultUriBuilderFactory} uses the default
|
||||
* {@link org.springframework.web.client.RestTemplate RestTemplate} settings.
|
||||
*/
|
||||
private static boolean hasRestTemplateDefaults(DefaultUriBuilderFactory factory) {
|
||||
// see RestTemplate::initUriTemplateHandler
|
||||
return (!factory.hasBaseUri() &&
|
||||
factory.getEncodingMode() == DefaultUriBuilderFactory.EncodingMode.URI_COMPONENT &&
|
||||
CollectionUtils.isEmpty(factory.getDefaultUriVariables()) &&
|
||||
factory.shouldParsePath());
|
||||
}
|
||||
|
||||
private static ClientHttpRequestFactory getRequestFactory(RestTemplate restTemplate) {
|
||||
ClientHttpRequestFactory requestFactory = restTemplate.getRequestFactory();
|
||||
if (requestFactory instanceof InterceptingClientHttpRequestFactory interceptingClientHttpRequestFactory) {
|
||||
|
|
|
@ -83,6 +83,15 @@ public class DefaultUriBuilderFactory implements UriBuilderFactory {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Determine whether this factory has been configured with a base URI.
|
||||
* @since 6.1.4
|
||||
* @see #DefaultUriBuilderFactory()
|
||||
*/
|
||||
public final boolean hasBaseUri() {
|
||||
return (this.baseUri != null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the {@link EncodingMode encoding mode} to use.
|
||||
* <p>By default this is set to {@link EncodingMode#TEMPLATE_AND_VALUES
|
||||
|
@ -157,20 +166,6 @@ public class DefaultUriBuilderFactory implements UriBuilderFactory {
|
|||
return this.parsePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether this {@code DefaultUriBuilderFactory} uses the default
|
||||
* {@link org.springframework.web.client.RestTemplate RestTemplate}
|
||||
* settings.
|
||||
* @since 6.1.4
|
||||
*/
|
||||
public boolean hasRestTemplateDefaults() {
|
||||
// see RestTemplate::initUriTemplateHandler
|
||||
return this.baseUri == null &&
|
||||
this.encodingMode == EncodingMode.URI_COMPONENT &&
|
||||
CollectionUtils.isEmpty(this.defaultUriVariables) &&
|
||||
this.parsePath;
|
||||
}
|
||||
|
||||
|
||||
// UriTemplateHandler
|
||||
|
||||
|
|
Loading…
Reference in New Issue