summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Lenz <thomas.lenz@egiz.gv.at>2020-05-29 14:41:19 +0200
committerThomas Lenz <thomas.lenz@egiz.gv.at>2020-05-29 14:41:19 +0200
commit7126ed717d01abad07e86150665f00154db27770 (patch)
tree2b083164bdbea2a4bae61174bae17d9892e687a5
parent9b6167a5f1fd3385b344b3a8c3b5d27d033d99d4 (diff)
downloadEAAF-Components-7126ed717d01abad07e86150665f00154db27770.tar.gz
EAAF-Components-7126ed717d01abad07e86150665f00154db27770.tar.bz2
EAAF-Components-7126ed717d01abad07e86150665f00154db27770.zip
update HttpClientBuilder factory to add 'ServiceUnavailableRetryStrategy' injection
fix broken jUnit test
-rw-r--r--eaaf_core_utils/src/main/java/at/gv/egiz/eaaf/core/impl/http/HttpClientConfiguration.java6
-rw-r--r--eaaf_core_utils/src/main/java/at/gv/egiz/eaaf/core/impl/http/HttpClientFactory.java7
-rw-r--r--eaaf_core_utils/src/test/java/at/gv/egiz/eaaf/core/test/http/HttpClientFactoryTest.java5
-rw-r--r--eaaf_core_utils/src/test/resources/data/config1.properties6
-rw-r--r--lombok.config1
5 files changed, 20 insertions, 5 deletions
diff --git a/eaaf_core_utils/src/main/java/at/gv/egiz/eaaf/core/impl/http/HttpClientConfiguration.java b/eaaf_core_utils/src/main/java/at/gv/egiz/eaaf/core/impl/http/HttpClientConfiguration.java
index ec7d115a..9239d0c5 100644
--- a/eaaf_core_utils/src/main/java/at/gv/egiz/eaaf/core/impl/http/HttpClientConfiguration.java
+++ b/eaaf_core_utils/src/main/java/at/gv/egiz/eaaf/core/impl/http/HttpClientConfiguration.java
@@ -6,6 +6,7 @@ import java.util.UUID;
import javax.annotation.Nonnull;
import org.apache.commons.lang3.StringUtils;
+import org.apache.http.client.ServiceUnavailableRetryStrategy;
import at.gv.egiz.eaaf.core.exceptions.EaafConfigurationException;
import at.gv.egiz.eaaf.core.impl.credential.KeyStoreConfiguration;
@@ -62,7 +63,11 @@ public class HttpClientConfiguration {
@Setter
private boolean httpErrorRetryPost = false;
+
+ @Setter
+ private ServiceUnavailableRetryStrategy serviceUnavailStrategy = null;
+
/**
* Get a new HTTP-client configuration object.
*
@@ -195,5 +200,4 @@ public class HttpClientConfiguration {
}
}
-
}
diff --git a/eaaf_core_utils/src/main/java/at/gv/egiz/eaaf/core/impl/http/HttpClientFactory.java b/eaaf_core_utils/src/main/java/at/gv/egiz/eaaf/core/impl/http/HttpClientFactory.java
index b53226ce..647c0636 100644
--- a/eaaf_core_utils/src/main/java/at/gv/egiz/eaaf/core/impl/http/HttpClientFactory.java
+++ b/eaaf_core_utils/src/main/java/at/gv/egiz/eaaf/core/impl/http/HttpClientFactory.java
@@ -164,6 +164,13 @@ public class HttpClientFactory implements IHttpClientFactory {
config.getHttpErrorRetryCount(),
config.isHttpErrorRetryPost()));
+ if (config.getServiceUnavailStrategy() != null) {
+ log.debug("HttpClient configuration: {} set custom ServiceUnavailableRetryStrategy: {}",
+ config.getFriendlyName(), config.getServiceUnavailStrategy().getClass().getName());
+ builder.setServiceUnavailableRetryStrategy(config.getServiceUnavailStrategy());
+
+ }
+
} else {
log.info("Disable HTTP error-retry for http-client: {}", config.getFriendlyName());
builder.disableAutomaticRetries();
diff --git a/eaaf_core_utils/src/test/java/at/gv/egiz/eaaf/core/test/http/HttpClientFactoryTest.java b/eaaf_core_utils/src/test/java/at/gv/egiz/eaaf/core/test/http/HttpClientFactoryTest.java
index 63ac38a3..c35ef604 100644
--- a/eaaf_core_utils/src/test/java/at/gv/egiz/eaaf/core/test/http/HttpClientFactoryTest.java
+++ b/eaaf_core_utils/src/test/java/at/gv/egiz/eaaf/core/test/http/HttpClientFactoryTest.java
@@ -553,13 +553,16 @@ public class HttpClientFactoryTest {
keyStoreFactory.buildNewKeyStore(clientConfig.getKeyStoreConfig());
X509Certificate clientRootCert = (X509Certificate) sslClientKeyStore.getFirst()
.getCertificateChain(clientConfig.getSslKeyAlias())[1];
-
+ X509Certificate clientEeCert = (X509Certificate) sslClientKeyStore.getFirst()
+ .getCertificateChain(clientConfig.getSslKeyAlias())[0];
+
final String localhost = InetAddress.getByName("localhost").getCanonicalHostName();
final HeldCertificate localhostCertificate = new HeldCertificate.Builder()
.addSubjectAlternativeName(localhost)
.build();
final HandshakeCertificates serverCertificates = new HandshakeCertificates.Builder()
.addTrustedCertificate(clientRootCert)
+ .addTrustedCertificate(clientEeCert)
.heldCertificate(localhostCertificate)
.build();
mockWebServer = new MockWebServer();
diff --git a/eaaf_core_utils/src/test/resources/data/config1.properties b/eaaf_core_utils/src/test/resources/data/config1.properties
index 93729b15..6192002e 100644
--- a/eaaf_core_utils/src/test/resources/data/config1.properties
+++ b/eaaf_core_utils/src/test/resources/data/config1.properties
@@ -4,6 +4,6 @@ security.hsmfacade.trustedsslcert=src/test/resources/data/hsm_facade_trust_root.
security.hsmfacade.username=authhandler-junit
security.hsmfacade.password=supersecret123
-client.http.connection.timeout.socket=1
-client.http.connection.timeout.connection=1
-client.http.connection.timeout.request=1 \ No newline at end of file
+client.http.connection.timeout.socket=2
+client.http.connection.timeout.connection=2
+client.http.connection.timeout.request=2 \ No newline at end of file
diff --git a/lombok.config b/lombok.config
new file mode 100644
index 00000000..7a21e880
--- /dev/null
+++ b/lombok.config
@@ -0,0 +1 @@
+lombok.addLombokGeneratedAnnotation = true