pull/13351/merge
Stephane Nicoll 7 years ago
parent b38f60a631
commit 93396aef51

@ -7428,7 +7428,7 @@ can also customize read and connection timeouts as follows:
@Bean
public WebServiceTemplate webServiceTemplate(WebServiceTemplateBuilder builder) {
return builder.messageSenders(new HttpWebServiceMessageSenderBuilder()
.setReadTimeout(5000).setConnectionTimeout(2000).build()).build();
.setConnectTimeout(5000).setReadTimeout(2000).build()).build();
}
----

@ -451,9 +451,9 @@ public class RestTemplateBuilder {
}
/**
* Sets the connect timeout in milliseconds on the underlying
* Sets the connection timeout in milliseconds on the underlying
* {@link ClientHttpRequestFactory}.
* @param connectTimeout the connect timeout in milliseconds
* @param connectTimeout the connection timeout in milliseconds
* @return a new builder instance.
*/
public RestTemplateBuilder setConnectTimeout(int connectTimeout) {
@ -641,7 +641,7 @@ public class RestTemplateBuilder {
}
/**
* {@link RequestFactoryCustomizer} to set the connect timeout.
* {@link RequestFactoryCustomizer} to set the connection timeout.
*/
private static class ConnectTimeoutRequestFactoryCustomizer
extends TimeoutRequestFactoryCustomizer {

@ -35,7 +35,7 @@ import org.springframework.ws.transport.http.ClientHttpRequestMessageSender;
*/
public class HttpWebServiceMessageSenderBuilder {
private Integer connectionTimeout;
private Integer connectTimeout;
private Integer readTimeout;
@ -43,12 +43,11 @@ public class HttpWebServiceMessageSenderBuilder {
/**
* Set the connection timeout in milliseconds.
* @param connectionTimeout the connection timeout in milliseconds
* @param connectTimeout the connection timeout in milliseconds
* @return a new builder instance
*/
public HttpWebServiceMessageSenderBuilder setConnectionTimeout(
int connectionTimeout) {
this.connectionTimeout = connectionTimeout;
public HttpWebServiceMessageSenderBuilder setConnectTimeout(int connectTimeout) {
this.connectTimeout = connectTimeout;
return this;
}
@ -80,9 +79,9 @@ public class HttpWebServiceMessageSenderBuilder {
ClientHttpRequestFactory requestFactory = (this.requestFactorySupplier != null
? this.requestFactorySupplier.get()
: new ClientHttpRequestFactorySupplier().get());
if (this.connectionTimeout != null) {
new TimeoutRequestFactoryCustomizer(this.connectionTimeout,
"setConnectTimeout").customize(requestFactory);
if (this.connectTimeout != null) {
new TimeoutRequestFactoryCustomizer(this.connectTimeout, "setConnectTimeout")
.customize(requestFactory);
}
if (this.readTimeout != null) {
new TimeoutRequestFactoryCustomizer(this.readTimeout, "setReadTimeout")

@ -50,7 +50,7 @@ public class HttpWebServiceMessageSenderBuilderOkHttp3IntegrationTests {
@Test
public void buildWithCustomTimeouts() {
WebServiceMessageSender messageSender = this.builder.setConnectionTimeout(5000)
WebServiceMessageSender messageSender = this.builder.setConnectTimeout(5000)
.setReadTimeout(2000).build();
OkHttp3ClientHttpRequestFactory factory = assertOkHttp3RequestFactory(
messageSender);

@ -49,7 +49,7 @@ public class HttpWebServiceMessageSenderBuilderSimpleIntegrationTests {
@Test
public void buildWithCustomTimeouts() {
WebServiceMessageSender messageSender = this.builder.setConnectionTimeout(5000)
WebServiceMessageSender messageSender = this.builder.setConnectTimeout(5000)
.setReadTimeout(2000).build();
SimpleClientHttpRequestFactory requestFactory = assertSimpleClientRequestFactory(
messageSender);

@ -50,7 +50,7 @@ public class HttpWebServiceMessageSenderBuilderTests {
ClientHttpRequestMessageSender messageSender = build(
new HttpWebServiceMessageSenderBuilder()
.requestFactory(SimpleClientHttpRequestFactory::new)
.setConnectionTimeout(5000).setReadTimeout(2000));
.setConnectTimeout(5000).setReadTimeout(2000));
SimpleClientHttpRequestFactory requestFactory = (SimpleClientHttpRequestFactory) messageSender
.getRequestFactory();
assertThat(ReflectionTestUtils.getField(requestFactory, "connectTimeout"))
@ -60,9 +60,9 @@ public class HttpWebServiceMessageSenderBuilderTests {
}
@Test
public void buildUsesHttpComponentsBydefault() {
public void buildUsesHttpComponentsByDefault() {
ClientHttpRequestMessageSender messageSender = build(
new HttpWebServiceMessageSenderBuilder().setConnectionTimeout(5000)
new HttpWebServiceMessageSenderBuilder().setConnectTimeout(5000)
.setReadTimeout(2000));
ClientHttpRequestFactory requestFactory = messageSender.getRequestFactory();
assertThat(requestFactory)

Loading…
Cancel
Save