WrapperDownloader: add retries for network blips around connect(), too (#11846)

Add retries for common issues such as connect timeout, etc.

This won't solve the problem of read-timeouts happening around the actual
transferTo, but it is an easy incremental improvement.
This commit is contained in:
Robert Muir 2022-10-13 07:21:34 -04:00 committed by GitHub
parent 5e26b36ac8
commit 83891d9a61
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 1 deletions

View File

@ -103,7 +103,16 @@ public class WrapperDownloader {
HttpURLConnection connection;
while (true) {
connection = (HttpURLConnection) url.openConnection();
connection.connect();
try {
connection.connect();
} catch (IOException e) {
if (retries-- > 0) {
// Retry after a short delay
System.err.println("Error connecting to server: " + e + ", will retry in " + retryDelay + " seconds.");
Thread.sleep(TimeUnit.SECONDS.toMillis(retryDelay));
continue;
}
}
switch (connection.getResponseCode()) {
case HttpURLConnection.HTTP_INTERNAL_ERROR: