mirror of https://github.com/apache/lucene.git
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:
parent
5e26b36ac8
commit
83891d9a61
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue