From 83f76675deb24d83a7edea501c8d812950b6d8d9 Mon Sep 17 00:00:00 2001 From: Alessandro Masci Date: Wed, 4 Dec 2024 12:38:25 +0100 Subject: [PATCH] PN-9088: add connection and read timeout for assertion and IDP client --- .../client/simple/AssertionSimpleClientConfig.java | 7 ++++++- .../assertion/client/simple/internal/ApiClient.java | 6 +++--- build.gradle | 2 +- .../idp/client/simple/IdpCertSimpleClientConfig.java | 7 ++++++- .../consumer/idp/client/simple/internal/ApiClient.java | 6 +++--- 5 files changed, 19 insertions(+), 9 deletions(-) diff --git a/assertion-rest-client-native/src/main/java/it/pagopa/tech/lollipop/consumer/assertion/client/simple/AssertionSimpleClientConfig.java b/assertion-rest-client-native/src/main/java/it/pagopa/tech/lollipop/consumer/assertion/client/simple/AssertionSimpleClientConfig.java index 2b823d2b..4a9c2bcd 100644 --- a/assertion-rest-client-native/src/main/java/it/pagopa/tech/lollipop/consumer/assertion/client/simple/AssertionSimpleClientConfig.java +++ b/assertion-rest-client-native/src/main/java/it/pagopa/tech/lollipop/consumer/assertion/client/simple/AssertionSimpleClientConfig.java @@ -1,6 +1,7 @@ -/* (C)2023 */ +/* (C)2024 */ package it.pagopa.tech.lollipop.consumer.assertion.client.simple; +import java.time.Duration; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; @@ -17,4 +18,8 @@ public class AssertionSimpleClientConfig { @Builder.Default private String assertionRequestEndpoint = "/assertions"; @Builder.Default private String subscriptionKey = "FakeSubscriptionKey"; + + private Duration readTimeout; + + private Duration connectionTimeout; } diff --git a/assertion-rest-client-native/src/main/java/it/pagopa/tech/lollipop/consumer/assertion/client/simple/internal/ApiClient.java b/assertion-rest-client-native/src/main/java/it/pagopa/tech/lollipop/consumer/assertion/client/simple/internal/ApiClient.java index 610d7804..e1db5b8a 100644 --- a/assertion-rest-client-native/src/main/java/it/pagopa/tech/lollipop/consumer/assertion/client/simple/internal/ApiClient.java +++ b/assertion-rest-client-native/src/main/java/it/pagopa/tech/lollipop/consumer/assertion/client/simple/internal/ApiClient.java @@ -1,4 +1,4 @@ -/* (C)2023 */ +/* (C)2024 */ package it.pagopa.tech.lollipop.consumer.assertion.client.simple.internal; import static java.nio.charset.StandardCharsets.UTF_8; @@ -68,8 +68,8 @@ public ApiClient(AssertionSimpleClientConfig config) { this.mapper = createDefaultObjectMapper(); updateBaseUri(config.getBaseUri()); interceptor = t -> t.header("Ocp-Apim-Subscription-Key", config.getSubscriptionKey()); - readTimeout = null; - connectTimeout = null; + readTimeout = config.getReadTimeout(); + connectTimeout = config.getConnectionTimeout(); responseInterceptor = null; asyncResponseInterceptor = null; this.assertionRequestEndpoint = config.getAssertionRequestEndpoint(); diff --git a/build.gradle b/build.gradle index f74cfbf5..8217976c 100644 --- a/build.gradle +++ b/build.gradle @@ -22,7 +22,7 @@ repositories { } allprojects { - version = '1.0.0-RC5' + version = '1.0.0-RC6' group = 'it.pagopa.tech.lollipop-consumer-java-sdk' sourceCompatibility = '11' targetCompatibility = '11' diff --git a/identity-service-rest-client-native/src/main/java/it/pagopa/tech/lollipop/consumer/idp/client/simple/IdpCertSimpleClientConfig.java b/identity-service-rest-client-native/src/main/java/it/pagopa/tech/lollipop/consumer/idp/client/simple/IdpCertSimpleClientConfig.java index 122984ef..d362c1d2 100644 --- a/identity-service-rest-client-native/src/main/java/it/pagopa/tech/lollipop/consumer/idp/client/simple/IdpCertSimpleClientConfig.java +++ b/identity-service-rest-client-native/src/main/java/it/pagopa/tech/lollipop/consumer/idp/client/simple/IdpCertSimpleClientConfig.java @@ -1,6 +1,7 @@ -/* (C)2023 */ +/* (C)2024 */ package it.pagopa.tech.lollipop.consumer.idp.client.simple; +import java.time.Duration; import java.util.List; import lombok.AllArgsConstructor; import lombok.Builder; @@ -22,4 +23,8 @@ public class IdpCertSimpleClientConfig { @Builder.Default private String idpKeysCieEndpoint = "/idp-keys/cie"; @Builder.Default private String idpKeysSpidEndpoint = "/idp-keys/spid"; + + private Duration readTimeout; + + private Duration connectionTimeout; } diff --git a/identity-service-rest-client-native/src/main/java/it/pagopa/tech/lollipop/consumer/idp/client/simple/internal/ApiClient.java b/identity-service-rest-client-native/src/main/java/it/pagopa/tech/lollipop/consumer/idp/client/simple/internal/ApiClient.java index b1c57be6..1c0021d3 100644 --- a/identity-service-rest-client-native/src/main/java/it/pagopa/tech/lollipop/consumer/idp/client/simple/internal/ApiClient.java +++ b/identity-service-rest-client-native/src/main/java/it/pagopa/tech/lollipop/consumer/idp/client/simple/internal/ApiClient.java @@ -1,4 +1,4 @@ -/* (C)2022-2023 */ +/* (C)2024 */ package it.pagopa.tech.lollipop.consumer.idp.client.simple.internal; import static java.nio.charset.StandardCharsets.UTF_8; @@ -72,8 +72,8 @@ public ApiClient(IdpCertSimpleClientConfig config) { this.xmlMapper = createDefaultXmlMapper(); updateBaseUri(config.getBaseUri()); interceptor = null; - readTimeout = null; - connectTimeout = null; + readTimeout = config.getReadTimeout(); + connectTimeout = config.getConnectionTimeout(); responseInterceptor = null; asyncResponseInterceptor = null; this.idpKeysCieEndpoint = config.getIdpKeysCieEndpoint();