diff --git a/src/main/java/sirius/biz/storage/layer3/VirtualFile.java b/src/main/java/sirius/biz/storage/layer3/VirtualFile.java index b93dde2e4..711b3de04 100644 --- a/src/main/java/sirius/biz/storage/layer3/VirtualFile.java +++ b/src/main/java/sirius/biz/storage/layer3/VirtualFile.java @@ -16,6 +16,7 @@ import sirius.biz.storage.layer2.Blob; import sirius.biz.storage.util.Attempt; import sirius.biz.storage.util.StorageUtils; +import sirius.kernel.Sirius; import sirius.kernel.async.TaskContext; import sirius.kernel.commons.Files; import sirius.kernel.commons.Streams; @@ -82,7 +83,6 @@ public abstract class VirtualFile extends Composable implements Comparable remoteFileResolvers; + @ConfigValue("storage.layer3.retriesForServiceUnavailable") + private static int retriesForServiceUnavailable; + /** * Internal constructor to create the "/" directory. */ @@ -1390,8 +1393,7 @@ public boolean performLoadFromUri(URI uri, FetchFromUrlMode mode) { return false; } - HttpResponse response = - requestFileFromUri(uri, mode, NUMBER_OF_RETRIES_FOR_SERVICE_UNAVAILABLE); + HttpResponse response = requestFileFromUri(uri, mode, retriesForServiceUnavailable); if (response.statusCode() == HttpResponseStatus.NOT_MODIFIED.code()) { tryTouch(); @@ -1431,14 +1433,14 @@ private HttpResponse requestFileFromUri(URI uri, FetchFromUrlMode m if (retries > 0) { // Wait 200ms, 700ms, 1200ms... - Wait.millis(200 + (NUMBER_OF_RETRIES_FOR_SERVICE_UNAVAILABLE - retries) * 500); + Wait.millis(200 + (retriesForServiceUnavailable - retries) * 500); return requestFileFromUri(uri, mode, retries - 1); } throw new IOException(Strings.apply("The server responded with status %s (%s) after %s retries!", HttpResponseStatus.valueOf(response.statusCode()).toString(), response.statusCode(), - NUMBER_OF_RETRIES_FOR_SERVICE_UNAVAILABLE)); + retriesForServiceUnavailable)); } if (response.statusCode() >= 400) { diff --git a/src/main/resources/component-biz.conf b/src/main/resources/component-biz.conf index d543583c2..4a77ca8bb 100644 --- a/src/main/resources/component-biz.conf +++ b/src/main/resources/component-biz.conf @@ -1367,6 +1367,10 @@ storage { # to determine if the file-extension of a file-url contains the effective filename or if the path # is just a script and we need to inspect the ContentDisposition (etc.) to obtain the actual file name serverSidedScriptingExtensions = [ "php", "php3", "php4", "php5", "cgi", "asp", "aspx", "jsp", "jspx", "cfm", "cfml", "xml" ] + + # Defines the number of retries for service unavailable responses (HTTP 503). + # The first retry will wait 200ms with each consequent retry waiting 500ms longer than the previous one. + retriesForServiceUnavailable = 3 } }