You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by rm...@apache.org on 2022/10/13 11:21:39 UTC

[lucene] branch main updated: WrapperDownloader: add retries for network blips around connect(), too (#11846)

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

rmuir pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/lucene.git


The following commit(s) were added to refs/heads/main by this push:
     new 83891d9a61c WrapperDownloader: add retries for network blips around connect(), too (#11846)
83891d9a61c is described below

commit 83891d9a61cae052de27f8ec33e2ebe859ed599b
Author: Robert Muir <rm...@apache.org>
AuthorDate: Thu Oct 13 07:21:34 2022 -0400

    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.
---
 .../main/java/org/apache/lucene/gradle/WrapperDownloader.java | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/buildSrc/src/main/java/org/apache/lucene/gradle/WrapperDownloader.java b/buildSrc/src/main/java/org/apache/lucene/gradle/WrapperDownloader.java
index b0734d3db0f..f4c287f32f0 100644
--- a/buildSrc/src/main/java/org/apache/lucene/gradle/WrapperDownloader.java
+++ b/buildSrc/src/main/java/org/apache/lucene/gradle/WrapperDownloader.java
@@ -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: