diff --git a/orca-webhook/orca-webhook.gradle b/orca-webhook/orca-webhook.gradle index 3bb4a92501..323a66f8c4 100644 --- a/orca-webhook/orca-webhook.gradle +++ b/orca-webhook/orca-webhook.gradle @@ -20,6 +20,7 @@ apply from: "$rootDir/gradle/groovy.gradle" dependencies { compile project(':orca-core') compile spinnaker.dependency('kork') + compile spinnaker.dependency('korkWeb') compile spinnaker.dependency('bootAutoConfigure') compile spinnaker.dependency('lombok') compile('com.jayway.jsonpath:json-path:2.2.0') diff --git a/orca-webhook/src/main/java/com/netflix/spinnaker/orca/webhook/config/WebhookConfiguration.java b/orca-webhook/src/main/java/com/netflix/spinnaker/orca/webhook/config/WebhookConfiguration.java index 41bb8a6648..d35f0bd543 100644 --- a/orca-webhook/src/main/java/com/netflix/spinnaker/orca/webhook/config/WebhookConfiguration.java +++ b/orca-webhook/src/main/java/com/netflix/spinnaker/orca/webhook/config/WebhookConfiguration.java @@ -17,6 +17,7 @@ package com.netflix.spinnaker.orca.webhook.config; +import com.netflix.spinnaker.okhttp.OkHttpClientConfigurationProperties; import com.netflix.spinnaker.orca.webhook.util.UnionX509TrustManager; import okhttp3.OkHttpClient; import org.apache.commons.lang3.StringUtils; @@ -70,11 +71,16 @@ public RestTemplate restTemplate(ClientHttpRequestFactory webhookRequestFactory) } @Bean - public ClientHttpRequestFactory webhookRequestFactory() { + public ClientHttpRequestFactory webhookRequestFactory( + OkHttpClientConfigurationProperties okHttpClientConfigurationProperties + ) { X509TrustManager trustManager = webhookX509TrustManager(); SSLSocketFactory sslSocketFactory = getSSLSocketFactory(trustManager); OkHttpClient client = new OkHttpClient.Builder().sslSocketFactory(sslSocketFactory, trustManager).build(); - return new OkHttp3ClientHttpRequestFactory(client); + OkHttp3ClientHttpRequestFactory requestFactory = new OkHttp3ClientHttpRequestFactory(client); + requestFactory.setReadTimeout(Math.toIntExact(okHttpClientConfigurationProperties.getReadTimeoutMs())); + requestFactory.setConnectTimeout(Math.toIntExact(okHttpClientConfigurationProperties.getConnectTimeoutMs())); + return requestFactory; } private X509TrustManager webhookX509TrustManager() { diff --git a/orca-webhook/src/test/groovy/com/netflix/spinnaker/orca/webhook/service/WebhookServiceSpec.groovy b/orca-webhook/src/test/groovy/com/netflix/spinnaker/orca/webhook/service/WebhookServiceSpec.groovy index 0a778fe450..76800cef05 100644 --- a/orca-webhook/src/test/groovy/com/netflix/spinnaker/orca/webhook/service/WebhookServiceSpec.groovy +++ b/orca-webhook/src/test/groovy/com/netflix/spinnaker/orca/webhook/service/WebhookServiceSpec.groovy @@ -17,6 +17,7 @@ package com.netflix.spinnaker.orca.webhook.service +import com.netflix.spinnaker.okhttp.OkHttpClientConfigurationProperties import com.netflix.spinnaker.orca.config.UserConfiguredUrlRestrictions import com.netflix.spinnaker.orca.webhook.config.WebhookProperties import com.netflix.spinnaker.orca.webhook.config.WebhookConfiguration @@ -41,11 +42,14 @@ class WebhookServiceSpec extends Specification { @Shared def webhookProperties = new WebhookProperties() + @Shared + def okHttpClientConfigurationProperties = new OkHttpClientConfigurationProperties() + @Shared def webhookConfiguration = new WebhookConfiguration(webhookProperties) @Shared - def requestFactory = webhookConfiguration.webhookRequestFactory() + def requestFactory = webhookConfiguration.webhookRequestFactory(okHttpClientConfigurationProperties) @Shared def restTemplate = webhookConfiguration.restTemplate(requestFactory)