Use DefaultUriBuilderFactory instead of DefaultUriTemplateHandler
Closes gh-8247
This commit is contained in:
parent
16b7bf7f73
commit
13791cad53
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -20,7 +20,7 @@ import org.springframework.boot.bind.RelaxedPropertyResolver;
|
|||
import org.springframework.boot.web.client.RootUriTemplateHandler;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.web.util.DefaultUriTemplateHandler;
|
||||
import org.springframework.web.util.DefaultUriBuilderFactory;
|
||||
import org.springframework.web.util.UriTemplateHandler;
|
||||
|
||||
/**
|
||||
|
@ -58,12 +58,13 @@ public class LocalHostUriTemplateHandler extends RootUriTemplateHandler {
|
|||
* @since 1.4.1
|
||||
*/
|
||||
public LocalHostUriTemplateHandler(Environment environment, String scheme) {
|
||||
super(new DefaultUriTemplateHandler());
|
||||
super(new DefaultUriBuilderFactory());
|
||||
Assert.notNull(environment, "Environment must not be null");
|
||||
Assert.notNull(scheme, "Scheme must not be null");
|
||||
this.environment = environment;
|
||||
this.scheme = scheme;
|
||||
this.servletPropertyResolver = new RelaxedPropertyResolver(environment, "server.servlet.");
|
||||
this.servletPropertyResolver = new RelaxedPropertyResolver(environment,
|
||||
"server.servlet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -57,7 +57,7 @@ import org.springframework.web.client.RequestCallback;
|
|||
import org.springframework.web.client.ResponseExtractor;
|
||||
import org.springframework.web.client.RestClientException;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
import org.springframework.web.util.DefaultUriTemplateHandler;
|
||||
import org.springframework.web.util.DefaultUriBuilderFactory;
|
||||
import org.springframework.web.util.UriTemplateHandler;
|
||||
|
||||
/**
|
||||
|
@ -161,7 +161,7 @@ public class TestRestTemplate {
|
|||
|
||||
/**
|
||||
* Configure the {@link UriTemplateHandler} to use to expand URI templates. By default
|
||||
* the {@link DefaultUriTemplateHandler} is used which relies on Spring's URI template
|
||||
* the {@link DefaultUriBuilderFactory} is used which relies on Spring's URI template
|
||||
* support and exposes several useful properties that customize its behavior for
|
||||
* encoding and for prepending a common base URL. An alternative implementation may be
|
||||
* used to plug an external URI template library.
|
||||
|
|
|
@ -47,12 +47,12 @@ import org.springframework.util.ReflectionUtils.MethodCallback;
|
|||
import org.springframework.web.client.ResponseErrorHandler;
|
||||
import org.springframework.web.client.RestOperations;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
import org.springframework.web.util.DefaultUriTemplateHandler;
|
||||
import org.springframework.web.util.DefaultUriBuilderFactory;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
|
@ -102,7 +102,7 @@ public class TestRestTemplateTests {
|
|||
public void restOperationsAreAvailable() throws Exception {
|
||||
RestTemplate delegate = mock(RestTemplate.class);
|
||||
given(delegate.getUriTemplateHandler())
|
||||
.willReturn(new DefaultUriTemplateHandler());
|
||||
.willReturn(new DefaultUriBuilderFactory());
|
||||
final TestRestTemplate restTemplate = new TestRestTemplate(delegate);
|
||||
ReflectionUtils.doWithMethods(RestOperations.class, new MethodCallback() {
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -22,7 +22,7 @@ import java.util.Map;
|
|||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
import org.springframework.web.util.DefaultUriTemplateHandler;
|
||||
import org.springframework.web.util.DefaultUriBuilderFactory;
|
||||
import org.springframework.web.util.UriTemplateHandler;
|
||||
|
||||
/**
|
||||
|
@ -47,7 +47,7 @@ public class RootUriTemplateHandler implements UriTemplateHandler {
|
|||
* @param rootUri the root URI to be used to prefix relative URLs
|
||||
*/
|
||||
public RootUriTemplateHandler(String rootUri) {
|
||||
this(rootUri, new DefaultUriTemplateHandler());
|
||||
this(rootUri, new DefaultUriBuilderFactory());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue