You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by du...@apache.org on 2020/04/06 12:43:17 UTC

[sling-org-apache-sling-testing-clients] branch master updated: SLING-9334 Refactor configurable retries mechanism to make them consistent

This is an automated email from the ASF dual-hosted git repository.

dulvac pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-clients.git


The following commit(s) were added to refs/heads/master by this push:
     new e75f544  SLING-9334 Refactor configurable retries mechanism to make them consistent
e75f544 is described below

commit e75f544bf811f26ba88c608bf5f2d1e0ffb5d5db
Author: Andrei Dulvac <ad...@adobe.com>
AuthorDate: Mon Apr 6 14:42:44 2020 +0200

    SLING-9334 Refactor configurable retries mechanism to make them consistent
---
 .../java/org/apache/sling/testing/Constants.java   |  35 ++++++
 .../apache/sling/testing/clients/Constants.java    | 132 ---------------------
 .../apache/sling/testing/clients/SlingClient.java  |  11 +-
 .../testing/clients/SystemPropertiesConfig.java    | 130 ++++++++++++++++++++
 .../testing/clients/instance/InstanceSetup.java    |  12 +-
 .../interceptors/FormBasedAuthInterceptor.java     |   9 +-
 .../clients/interceptors/StickyCookieHolder.java   |   4 +-
 .../apache/sling/testing/clients/package-info.java |   2 +-
 .../clients/util/ServerErrorRetryStrategy.java     |  54 ++-------
 .../sling/testing/clients/util/package-info.java   |   2 +-
 .../clients/SlingClientRetryStrategyTest.java      |  22 +++-
 .../testing/clients/SlingClientWaitExistsTest.java |   2 +-
 12 files changed, 205 insertions(+), 210 deletions(-)

diff --git a/src/main/java/org/apache/sling/testing/Constants.java b/src/main/java/org/apache/sling/testing/Constants.java
new file mode 100644
index 0000000..37e2aee
--- /dev/null
+++ b/src/main/java/org/apache/sling/testing/Constants.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.sling.testing;
+
+public class Constants {
+
+    public static final String DEFAULT_URL = "http://localhost:8080/";
+    public static final String DEFAULT_USERNAME = "admin";
+    public static final String DEFAULT_PASSWORD = "admin";
+
+    /**
+     * Handle to OSGI console
+     */
+    public static final String OSGI_CONSOLE = "/system/console";
+
+    /**
+     * General parameters and values
+     */
+    public static final String PARAMETER_CHARSET = "_charset_";
+    public static final String CHARSET_UTF8 = "utf-8";
+}
diff --git a/src/main/java/org/apache/sling/testing/clients/Constants.java b/src/main/java/org/apache/sling/testing/clients/Constants.java
deleted file mode 100644
index c9c1488..0000000
--- a/src/main/java/org/apache/sling/testing/clients/Constants.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership. The ASF
- * licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package org.apache.sling.testing.clients;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-public class Constants {
-
-    /**
-     * Prefix for IT-specific system properties
-     */
-    public static final String CONFIG_PROP_PREFIX = "sling.it.";
-    public static final String DEFAULT_URL = "http://localhost:8080/";
-    public static final String DEFAULT_USERNAME = "admin";
-    public static final String DEFAULT_PASSWORD = "admin";
-
-    // Custom delay for requests
-    private static long delay;
-
-    // Custom number of retries for failing requests
-    private static int retries;
-
-    // Custom delay between retries in millisec
-    private static int retriesDelay;
-
-    // Custom log retries
-    private static boolean logRetries;
-
-    // CSV list of error codes to retry requests for
-    private static String retryCodes = "";
-
-    /**
-     * System property for {@link Constants#HTTP_DELAY}
-     * Prefixed by {@link Constants#CONFIG_PROP_PREFIX}
-     */
-    public static final String HTTP_DELAY_PROP = "http.delay";
-
-    /**
-     * System property for {@link Constants#HTTP_RETRIES}
-     * Prefixed by {@link Constants#CONFIG_PROP_PREFIX}
-     */
-    public static final String HTTP_RETRIES_PROP = "http.retries";
-
-    /**
-     * System property for {@link Constants#HTTP_RETRIES_DELAY}
-     * Prefixed by {@link Constants#CONFIG_PROP_PREFIX}
-     */
-    public static final String HTTP_RETRIES_DELAY_PROP = "http.retriesDelay";
-
-    /**
-     * System property for {@link Constants#HTTP_LOG_RETRIES}
-     * Prefixed by {@link Constants#CONFIG_PROP_PREFIX}
-     */
-    public static final String HTTP_LOG_RETRIES_PROP = "http.logRetries";
-
-    /**
-     * System property for {@link Constants#HTTP_RETRIES_ERROR_CODES}
-     * Prefixed by {@link Constants#CONFIG_PROP_PREFIX}
-     */
-    public static final String HTTP_RETRIES_ERROR_CODES_PROP = "http.retriesErrorCodes";
-
-    static {
-        try {
-            Constants.delay = Long.getLong(Constants.CONFIG_PROP_PREFIX + HTTP_DELAY_PROP, 0);
-            Constants.retries = Integer.getInteger(Constants.CONFIG_PROP_PREFIX + HTTP_RETRIES_PROP, 10);
-            Constants.retriesDelay = Integer.getInteger(Constants.CONFIG_PROP_PREFIX + HTTP_RETRIES_DELAY_PROP, 1000);
-            Constants.logRetries = Boolean.getBoolean(Constants.CONFIG_PROP_PREFIX + HTTP_LOG_RETRIES_PROP);
-            Constants.retryCodes = System.getProperty(Constants.CONFIG_PROP_PREFIX + HTTP_RETRIES_ERROR_CODES_PROP, "");
-        } catch (NumberFormatException e) {
-            Constants.delay = 0;
-            Constants.retries = 5;
-            Constants.retriesDelay = 1000;
-            Constants.logRetries = false;
-        }
-    }
-
-    /**
-     * Custom delay in milliseconds before an HTTP request goes through.
-     * Used by {@link org.apache.sling.testing.clients.interceptors.DelayRequestInterceptor}
-     */
-    public static final long HTTP_DELAY = delay;
-
-    /**
-     * Number of http call retries in case of a 5XX response code
-     */
-    public static final int HTTP_RETRIES = retries;
-
-    /**
-     * The delay in milliseconds between http retries
-     */
-    public static final int HTTP_RETRIES_DELAY = retriesDelay;
-
-    /**
-     * Whether to log or not http request retries
-     */
-    public static final boolean HTTP_LOG_RETRIES = logRetries;
-
-    /**
-     * Comma-separated list of http response codes for which to retry the request
-     * If empty, all 5XX error codes will be retried
-     */
-    public static final String HTTP_RETRIES_ERROR_CODES = retryCodes;
-
-
-
-    /**
-     * Handle to OSGI console
-     */
-    public static final String OSGI_CONSOLE = "/system/console";
-
-    /**
-     * General parameters and values
-     */
-    public static final String PARAMETER_CHARSET = "_charset_";
-    public static final String CHARSET_UTF8 = "utf-8";
-}
diff --git a/src/main/java/org/apache/sling/testing/clients/SlingClient.java b/src/main/java/org/apache/sling/testing/clients/SlingClient.java
index fd5015c..58c4ef3 100644
--- a/src/main/java/org/apache/sling/testing/clients/SlingClient.java
+++ b/src/main/java/org/apache/sling/testing/clients/SlingClient.java
@@ -25,12 +25,10 @@ import org.apache.http.annotation.Immutable;
 import org.apache.http.client.CookieStore;
 import org.apache.http.client.CredentialsProvider;
 import org.apache.http.client.RedirectStrategy;
-import org.apache.http.client.ServiceUnavailableRetryStrategy;
 import org.apache.http.client.entity.UrlEncodedFormEntity;
 import org.apache.http.entity.ContentType;
 import org.apache.http.entity.mime.MultipartEntityBuilder;
 import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.DefaultServiceUnavailableRetryStrategy;
 import org.apache.http.impl.client.HttpClientBuilder;
 import org.apache.sling.testing.clients.interceptors.DelayRequestInterceptor;
 import org.apache.sling.testing.clients.interceptors.TestDescriptionInterceptor;
@@ -689,15 +687,10 @@ public class SlingClient extends AbstractSlingClient {
             httpClientBuilder.setMaxConnTotal(100);
             // Interceptors
             httpClientBuilder.addInterceptorLast(new TestDescriptionInterceptor());
-            httpClientBuilder.addInterceptorLast(new DelayRequestInterceptor(Constants.HTTP_DELAY));
+            httpClientBuilder.addInterceptorLast(new DelayRequestInterceptor(SystemPropertiesConfig.getHttpDelay()));
 
             // HTTP request strategy
-            httpClientBuilder.setServiceUnavailableRetryStrategy(new ServerErrorRetryStrategy(
-                    Constants.HTTP_RETRIES,
-                    Constants.HTTP_RETRIES_DELAY,
-                    Constants.HTTP_LOG_RETRIES,
-                    Constants.HTTP_RETRIES_ERROR_CODES)
-            );
+            httpClientBuilder.setServiceUnavailableRetryStrategy(new ServerErrorRetryStrategy());
 
             return this;
         }
diff --git a/src/main/java/org/apache/sling/testing/clients/SystemPropertiesConfig.java b/src/main/java/org/apache/sling/testing/clients/SystemPropertiesConfig.java
new file mode 100644
index 0000000..a1f6d09
--- /dev/null
+++ b/src/main/java/org/apache/sling/testing/clients/SystemPropertiesConfig.java
@@ -0,0 +1,130 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.sling.testing.clients;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Objects;
+import java.util.stream.Collectors;
+
+public class SystemPropertiesConfig {
+
+    /**
+     * Prefix for IT-specific system properties
+     */
+    public static final String CONFIG_PROP_PREFIX = "sling.it.";
+
+    /**
+     * System property for {@link SystemPropertiesConfig#getHttpDelay()}
+     * Prefixed by {@link SystemPropertiesConfig#CONFIG_PROP_PREFIX}
+     */
+    public static final String HTTP_DELAY_PROP = "http.delay";
+
+    /**
+     * System property for {@link SystemPropertiesConfig#getHttpRetries()}
+     * Prefixed by {@link SystemPropertiesConfig#CONFIG_PROP_PREFIX}
+     */
+    public static final String HTTP_RETRIES_PROP = "http.retries";
+
+    /**
+     * System property for {@link SystemPropertiesConfig#getHttpRetriesDelay()}
+     * Prefixed by {@link SystemPropertiesConfig#CONFIG_PROP_PREFIX}
+     */
+    public static final String HTTP_RETRIES_DELAY_PROP = "http.retriesDelay";
+
+    /**
+     * System property for {@link SystemPropertiesConfig#isHttpLogRetries()}
+     * Prefixed by {@link SystemPropertiesConfig#CONFIG_PROP_PREFIX}
+     */
+    public static final String HTTP_LOG_RETRIES_PROP = "http.logRetries";
+
+    /**
+     * System property for {@link SystemPropertiesConfig#getHttpRetriesErrorCodes()}
+     * Prefixed by {@link SystemPropertiesConfig#CONFIG_PROP_PREFIX}
+     */
+    public static final String HTTP_RETRIES_ERROR_CODES_PROP = "http.retriesErrorCodes";
+
+    public static String getPrefixedPropertyName(String prop) {
+        return SystemPropertiesConfig.CONFIG_PROP_PREFIX + prop;
+    }
+
+    /**
+     * Custom delay in milliseconds before an HTTP request goes through.
+     * Used by {@link org.apache.sling.testing.clients.interceptors.DelayRequestInterceptor}
+     */
+    public static long getHttpDelay() {
+        try {
+            return Long.getLong(getPrefixedPropertyName(HTTP_DELAY_PROP), 0);
+        } catch (Exception e) {
+            return 0;
+        }
+    }
+
+    /**
+     * Number of http call retries in case of a 5XX response code
+     */
+    public static int getHttpRetries() {
+        try {
+            return Integer.getInteger(getPrefixedPropertyName(HTTP_RETRIES_PROP), 10);
+        } catch (Exception e) {
+            return 0;
+        }
+    }
+
+    /**
+     * The delay in milliseconds between http retries
+     */
+    public static int getHttpRetriesDelay() {
+        try {
+            return Integer.getInteger(getPrefixedPropertyName(HTTP_RETRIES_DELAY_PROP), 1000);
+        } catch (Exception e) {
+            return 0;
+        }
+    }
+
+    /**
+     * Whether to log or not http request retries
+     */
+    public static boolean isHttpLogRetries() {
+        try {
+            return Boolean.getBoolean(getPrefixedPropertyName(HTTP_LOG_RETRIES_PROP));
+        } catch (Exception e) {
+            return false;
+        }
+    }
+
+    /**
+     * Comma-separated list of http response codes for which to retry the request
+     * If empty, all 5XX error codes will be retried
+     */
+    public static Collection<Integer> getHttpRetriesErrorCodes() {
+        try {
+            final String errorCodes = System.getProperty(getPrefixedPropertyName(HTTP_RETRIES_ERROR_CODES_PROP), "");
+            return Arrays.asList(errorCodes.split(",")).stream().map(s -> {
+                try {
+                    return Integer.valueOf(s);
+                } catch (NumberFormatException e) {
+                    return null;
+                }
+            }).filter(Objects::nonNull).collect(Collectors.toList());
+        } catch (Exception e) {
+            return Collections.emptyList();
+        }
+    }
+
+}
diff --git a/src/main/java/org/apache/sling/testing/clients/instance/InstanceSetup.java b/src/main/java/org/apache/sling/testing/clients/instance/InstanceSetup.java
index 051b4c9..ad89551 100644
--- a/src/main/java/org/apache/sling/testing/clients/instance/InstanceSetup.java
+++ b/src/main/java/org/apache/sling/testing/clients/instance/InstanceSetup.java
@@ -16,7 +16,7 @@
  */
 package org.apache.sling.testing.clients.instance;
 
-import org.apache.sling.testing.clients.Constants;
+import org.apache.sling.testing.clients.SystemPropertiesConfig;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -33,11 +33,11 @@ public final class InstanceSetup {
     private static InstanceSetup SINGLETON;
 
     // TODO: JAVADOC
-    public static final String INSTANCE_CONFIG_INSTANCES = Constants.CONFIG_PROP_PREFIX + "instances";
-    public static final String INSTANCE_CONFIG_URL = Constants.CONFIG_PROP_PREFIX + "instance.url.";
-    public static final String INSTANCE_CONFIG_RUNMODE = Constants.CONFIG_PROP_PREFIX + "instance.runmode.";
-    public static final String INSTANCE_CONFIG_ADMINUSER = Constants.CONFIG_PROP_PREFIX + "instance.adminUser.";
-    public static final String INSTANCE_CONFIG_ADMINPASSWORD = Constants.CONFIG_PROP_PREFIX + "instance.adminPassword.";
+    public static final String INSTANCE_CONFIG_INSTANCES = SystemPropertiesConfig.CONFIG_PROP_PREFIX + "instances";
+    public static final String INSTANCE_CONFIG_URL = SystemPropertiesConfig.CONFIG_PROP_PREFIX + "instance.url.";
+    public static final String INSTANCE_CONFIG_RUNMODE = SystemPropertiesConfig.CONFIG_PROP_PREFIX + "instance.runmode.";
+    public static final String INSTANCE_CONFIG_ADMINUSER = SystemPropertiesConfig.CONFIG_PROP_PREFIX + "instance.adminUser.";
+    public static final String INSTANCE_CONFIG_ADMINPASSWORD = SystemPropertiesConfig.CONFIG_PROP_PREFIX + "instance.adminPassword.";
 
     /**
      * @return  the current setup object.
diff --git a/src/main/java/org/apache/sling/testing/clients/interceptors/FormBasedAuthInterceptor.java b/src/main/java/org/apache/sling/testing/clients/interceptors/FormBasedAuthInterceptor.java
index a8bba17..962b2c3 100644
--- a/src/main/java/org/apache/sling/testing/clients/interceptors/FormBasedAuthInterceptor.java
+++ b/src/main/java/org/apache/sling/testing/clients/interceptors/FormBasedAuthInterceptor.java
@@ -24,7 +24,6 @@ import org.apache.http.HttpRequestInterceptor;
 import org.apache.http.NameValuePair;
 import org.apache.http.auth.AuthScope;
 import org.apache.http.client.CredentialsProvider;
-import org.apache.http.client.ServiceUnavailableRetryStrategy;
 import org.apache.http.client.entity.UrlEncodedFormEntity;
 import org.apache.http.client.methods.HttpPost;
 import org.apache.http.client.protocol.HttpClientContext;
@@ -39,12 +38,8 @@ import org.slf4j.LoggerFactory;
 
 import java.io.IOException;
 import java.net.URI;
-import java.util.Arrays;
 import java.util.LinkedList;
 import java.util.List;
-import java.util.stream.Collectors;
-
-import static org.apache.sling.testing.clients.Constants.*;
 
 public class FormBasedAuthInterceptor implements HttpRequestInterceptor {
     static final Logger LOG = LoggerFactory.getLogger(FormBasedAuthInterceptor.class);
@@ -87,10 +82,8 @@ public class FormBasedAuthInterceptor implements HttpRequestInterceptor {
         HttpPost loginPost = new HttpPost(URI.create(request.getRequestLine().getUri()).resolve(loginPath));
         loginPost.setEntity(httpEntity);
 
-        ServiceUnavailableRetryStrategy retryStrategy = new ServerErrorRetryStrategy(
-                HTTP_RETRIES, HTTP_RETRIES_DELAY, HTTP_LOG_RETRIES, HTTP_RETRIES_ERROR_CODES);
         final CloseableHttpClient client = HttpClientBuilder.create()
-                .setServiceUnavailableRetryStrategy(retryStrategy)
+                .setServiceUnavailableRetryStrategy(new ServerErrorRetryStrategy())
                 .disableRedirectHandling()
                 .build();
 
diff --git a/src/main/java/org/apache/sling/testing/clients/interceptors/StickyCookieHolder.java b/src/main/java/org/apache/sling/testing/clients/interceptors/StickyCookieHolder.java
index c2b70a9..02daffb 100644
--- a/src/main/java/org/apache/sling/testing/clients/interceptors/StickyCookieHolder.java
+++ b/src/main/java/org/apache/sling/testing/clients/interceptors/StickyCookieHolder.java
@@ -19,12 +19,12 @@
 package org.apache.sling.testing.clients.interceptors;
 
 import org.apache.http.cookie.Cookie;
-import org.apache.sling.testing.clients.Constants;
+import org.apache.sling.testing.clients.SystemPropertiesConfig;
 
 public class StickyCookieHolder {
 
     private static final ThreadLocal<Cookie> testStickySessionCookie = new ThreadLocal<Cookie>();
-    public static final String COOKIE_NAME = System.getProperty(Constants.CONFIG_PROP_PREFIX + "session.cookie.name", "test_session_id");
+    public static final String COOKIE_NAME = System.getProperty(SystemPropertiesConfig.CONFIG_PROP_PREFIX + "session.cookie.name", "test_session_id");
 
     public static Cookie getTestStickySessionCookie() {
         return testStickySessionCookie.get();
diff --git a/src/main/java/org/apache/sling/testing/clients/package-info.java b/src/main/java/org/apache/sling/testing/clients/package-info.java
index 8ace300..cd9b0bd 100644
--- a/src/main/java/org/apache/sling/testing/clients/package-info.java
+++ b/src/main/java/org/apache/sling/testing/clients/package-info.java
@@ -17,7 +17,7 @@
  * under the License.
  */
 
-@Version("1.7.0")
+@Version("2.0.0")
 package org.apache.sling.testing.clients;
 
 import org.osgi.annotation.versioning.Version;
diff --git a/src/main/java/org/apache/sling/testing/clients/util/ServerErrorRetryStrategy.java b/src/main/java/org/apache/sling/testing/clients/util/ServerErrorRetryStrategy.java
index 0e3d770..0ba972e 100644
--- a/src/main/java/org/apache/sling/testing/clients/util/ServerErrorRetryStrategy.java
+++ b/src/main/java/org/apache/sling/testing/clients/util/ServerErrorRetryStrategy.java
@@ -17,23 +17,18 @@
 package org.apache.sling.testing.clients.util;
 
 import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
 import org.apache.http.client.ServiceUnavailableRetryStrategy;
 import org.apache.http.protocol.HttpContext;
-import org.apache.http.util.Args;
 import org.apache.http.util.EntityUtils;
+import org.apache.sling.testing.clients.SystemPropertiesConfig;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import java.io.IOException;
 import java.util.Arrays;
 import java.util.Collection;
-import java.util.Collections;
-import java.util.Objects;
-import java.util.stream.Collectors;
 
 import static org.apache.http.HttpStatus.*;
-import static org.apache.sling.testing.clients.Constants.HTTP_RETRIES_ERROR_CODES;
 
 /**
  * {code ServiceUnavailableRetryStrategy} strategy for retrying request in case of a 5XX response code
@@ -42,49 +37,15 @@ public class ServerErrorRetryStrategy implements ServiceUnavailableRetryStrategy
 
     private static final Logger LOG = LoggerFactory.getLogger(ServerErrorRetryStrategy.class);
 
-    private final int maxRetries;
-    private final int retryInterval;
-    private final boolean logRetries;
-    private Collection<Integer> retryErrorCodes;
-
-    public ServerErrorRetryStrategy(final int maxRetries, final int retryInterval, final boolean logRetries,
-                                    String retryErrorCodes) {
-        super();
-        Args.positive(maxRetries, "Max retries");
-        Args.positive(retryInterval, "Retry interval");
-        this.maxRetries = maxRetries;
-        this.retryInterval = retryInterval;
-        this.logRetries = logRetries;
-        if (retryErrorCodes == null) {
-            retryErrorCodes = "";
-        }
-        this.retryErrorCodes = Arrays.asList(retryErrorCodes.split(","))
-                .stream().map(s -> {
-                    try {
-                        return Integer.valueOf(s);
-                    } catch (NumberFormatException e) {
-                        return null;
-                    }
-                }).filter(Objects::nonNull).collect(Collectors.toList());
-    }
-
-    public ServerErrorRetryStrategy(final int maxRetries, final int retryInterval, final boolean logRetries) {
-       this(maxRetries, retryInterval, logRetries, "");
-    }
-
-    public ServerErrorRetryStrategy(int maxRetries, int retryInterval) {
-        this (1, 1000, true);
-    }
-
     public ServerErrorRetryStrategy() {
-        this(1, 1000);
+        super();
     }
 
     @Override
     public boolean retryRequest(final HttpResponse response, final int executionCount, final HttpContext context) {
-        boolean needsRetry = executionCount <= this.maxRetries && responseRetryCondition(response);
+        boolean needsRetry = executionCount <= SystemPropertiesConfig.getHttpRetries() && responseRetryCondition(response);
 
-        if (this.logRetries && needsRetry && LOG.isWarnEnabled()) {
+        if (SystemPropertiesConfig.isHttpLogRetries() && needsRetry && LOG.isWarnEnabled()) {
             LOG.warn("Request retry needed due to service unavailable response");
             LOG.warn("Response headers contained:");
             Arrays.stream(response.getAllHeaders()).forEach(h -> LOG.warn("Header {}:{}", h.getName(), h.getValue()));
@@ -100,13 +61,14 @@ public class ServerErrorRetryStrategy implements ServiceUnavailableRetryStrategy
 
     @Override
     public long getRetryInterval() {
-        return retryInterval;
+        return SystemPropertiesConfig.getHttpRetriesDelay();
     }
 
     private boolean responseRetryCondition(final HttpResponse response) {
         final Integer statusCode = response.getStatusLine().getStatusCode();
-        if (retryErrorCodes != null && !retryErrorCodes.isEmpty()) {
-            return retryErrorCodes.contains(statusCode);
+        final Collection<Integer> errorCodes = SystemPropertiesConfig.getHttpRetriesErrorCodes();
+        if (errorCodes != null && !errorCodes.isEmpty()) {
+            return errorCodes.contains(statusCode);
         } else {
             return statusCode >= SC_INTERNAL_SERVER_ERROR &&
                     statusCode < SC_INTERNAL_SERVER_ERROR + 100;
diff --git a/src/main/java/org/apache/sling/testing/clients/util/package-info.java b/src/main/java/org/apache/sling/testing/clients/util/package-info.java
index d497a5a..1b6436d 100644
--- a/src/main/java/org/apache/sling/testing/clients/util/package-info.java
+++ b/src/main/java/org/apache/sling/testing/clients/util/package-info.java
@@ -17,7 +17,7 @@
  * under the License.
  */
 
-@Version("1.2.0")
+@Version("2.0.0")
 package org.apache.sling.testing.clients.util;
 
 import org.osgi.annotation.versioning.Version;
diff --git a/src/test/java/org/apache/sling/testing/clients/SlingClientRetryStrategyTest.java b/src/test/java/org/apache/sling/testing/clients/SlingClientRetryStrategyTest.java
index 60d782e..b653e1c 100644
--- a/src/test/java/org/apache/sling/testing/clients/SlingClientRetryStrategyTest.java
+++ b/src/test/java/org/apache/sling/testing/clients/SlingClientRetryStrategyTest.java
@@ -22,6 +22,8 @@ import org.junit.Test;
 
 import java.io.IOException;
 
+import static org.apache.sling.testing.clients.SystemPropertiesConfig.CONFIG_PROP_PREFIX;
+import static org.apache.sling.testing.clients.SystemPropertiesConfig.HTTP_RETRIES_ERROR_CODES_PROP;
 import static org.junit.Assert.assertEquals;
 
 public class SlingClientRetryStrategyTest {
@@ -38,10 +40,10 @@ public class SlingClientRetryStrategyTest {
     private static int availableAtRequestCount = Integer.MAX_VALUE;
 
     static {
-        System.setProperty(Constants.CONFIG_PROP_PREFIX + Constants.HTTP_LOG_RETRIES_PROP, "true");
-        System.setProperty(Constants.CONFIG_PROP_PREFIX + Constants.HTTP_DELAY_PROP, "50");
-        System.setProperty(Constants.CONFIG_PROP_PREFIX + Constants.HTTP_RETRIES_PROP, "4");
-        System.setProperty(Constants.CONFIG_PROP_PREFIX + Constants.HTTP_RETRIES_ERROR_CODES_PROP, "500,503");
+        System.setProperty(CONFIG_PROP_PREFIX + SystemPropertiesConfig.HTTP_LOG_RETRIES_PROP, "true");
+        System.setProperty(CONFIG_PROP_PREFIX + SystemPropertiesConfig.HTTP_DELAY_PROP, "50");
+        System.setProperty(CONFIG_PROP_PREFIX + SystemPropertiesConfig.HTTP_RETRIES_PROP, "4");
+        System.setProperty(CONFIG_PROP_PREFIX + HTTP_RETRIES_ERROR_CODES_PROP, "500,503");
     }
 
     @ClassRule
@@ -111,6 +113,7 @@ public class SlingClientRetryStrategyTest {
 
     @Test
     public void test505ShouldNotRetry() throws Exception {
+        System.setProperty(CONFIG_PROP_PREFIX + HTTP_RETRIES_ERROR_CODES_PROP, "500,503");
         requestCount = 0;
         availableAtRequestCount = Integer.MAX_VALUE; // never 200
         SlingClient c = new SlingClient(httpServer.getURI(), "user", "pass");
@@ -120,6 +123,17 @@ public class SlingClientRetryStrategyTest {
     }
 
     @Test
+    public void test505ShouldRetry() throws Exception {
+        System.setProperty(CONFIG_PROP_PREFIX + HTTP_RETRIES_ERROR_CODES_PROP, "500,503,505");
+        requestCount = 0;
+        availableAtRequestCount = 3;
+        SlingClient c = new SlingClient(httpServer.getURI(), "user", "pass");
+        SlingHttpResponse slingHttpResponse = c.doGet(GET_505_PATH, 200);
+        assertEquals(availableAtRequestCount, requestCount);
+        assertEquals(OK_RESPONSE, slingHttpResponse.getContent());
+    }
+
+    @Test
     public void testRetryInexistent() throws Exception {
         requestCount = 0;
         availableAtRequestCount = Integer.MAX_VALUE; // never available
diff --git a/src/test/java/org/apache/sling/testing/clients/SlingClientWaitExistsTest.java b/src/test/java/org/apache/sling/testing/clients/SlingClientWaitExistsTest.java
index 31b67bf..05c1908 100644
--- a/src/test/java/org/apache/sling/testing/clients/SlingClientWaitExistsTest.java
+++ b/src/test/java/org/apache/sling/testing/clients/SlingClientWaitExistsTest.java
@@ -73,7 +73,7 @@ public class SlingClientWaitExistsTest {
         waitCount = 40;  // to be sure we reach timeout
         SlingClient c = new SlingClient(httpServer.getURI(), "user", "pass");
         try {
-            c.waitExists(GET_WAIT_PATH, 200, 10);
+            c.waitExists(GET_WAIT_PATH, 1000, 10);
         } catch (TimeoutException e ) {
             assertTrue("call was executed only " + callCount + " times", callCount > 3);
             return;