Skip to content

Commit c62b599

Browse files
committed
Timeout configuration
This change adds a couple more configuration options for controlling timeouts in the network stack.
1 parent 1132eb5 commit c62b599

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/_DefaultConnectionContext.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@ public HttpClient getHttpClient() {
6363
.rcvbuf(RECEIVE_BUFFER_SIZE);
6464

6565
getProxyConfiguration().ifPresent(c -> options.proxy(ClientOptions.Proxy.HTTP, c.getHost(), c.getPort().orElse(null), c.getUsername().orElse(null), u -> c.getPassword().orElse(null)));
66+
getSocketTimeout().ifPresent(options::timeout);
6667
getSslCertificateTruster().ifPresent(trustManager -> options.ssl().trustManager(new StaticTrustManagerFactory(trustManager)));
68+
getSslHandshakeTimeout().ifPresent(options::sslHandshakeTimeout);
6769

6870
return HttpClient.create(options);
6971
}
@@ -144,6 +146,11 @@ Mono<Map<String, String>> getInfo() {
144146
*/
145147
abstract Optional<Boolean> getSkipSslValidation();
146148

149+
/**
150+
* The {@code SO_TIMEOUT} value
151+
*/
152+
abstract Optional<Duration> getSocketTimeout();
153+
147154
@Value.Derived
148155
Optional<SslCertificateTruster> getSslCertificateTruster() {
149156
if (getSkipSslValidation().orElse(false)) {
@@ -153,6 +160,11 @@ Optional<SslCertificateTruster> getSslCertificateTruster() {
153160
}
154161
}
155162

163+
/**
164+
* The timeout for the SSL handshake negotiation
165+
*/
166+
abstract Optional<Duration> getSslHandshakeTimeout();
167+
156168
private static UriComponents normalize(UriComponentsBuilder builder) {
157169
UriComponents components = builder.build();
158170

integration-test/src/test/java/org/cloudfoundry/IntegrationTestConfiguration.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
import reactor.core.publisher.Mono;
4747

4848
import java.security.SecureRandom;
49+
import java.time.Duration;
4950
import java.util.Random;
5051

5152
@Configuration
@@ -89,7 +90,8 @@ DefaultConnectionContext connectionContext(@Value("${test.apiHost}") String apiH
8990
DefaultConnectionContext.Builder connectionContext = DefaultConnectionContext.builder()
9091
.apiHost(apiHost)
9192
.problemHandler(new FailingDeserializationProblemHandler()) // Test-only problem handler
92-
.skipSslValidation(skipSslValidation);
93+
.skipSslValidation(skipSslValidation)
94+
.sslHandshakeTimeout(Duration.ofSeconds(30));
9395

9496
if (StringUtils.hasText(proxyHost)) {
9597
ProxyConfiguration.Builder proxyConfiguration = ProxyConfiguration.builder()

0 commit comments

Comments
 (0)