Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
burningtnt committed Dec 2, 2023
1 parent ba9dd01 commit bd39178
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import java.lang.reflect.Type;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.SocketTimeoutException;
import java.net.URL;
import java.util.HashMap;
import java.util.HashSet;
Expand Down Expand Up @@ -218,16 +217,21 @@ public static HttpPostRequest POST(String url) throws MalformedURLException {
}

private static String getStringWithRetry(ExceptionalSupplier<String, IOException> supplier, int retryTimes) throws IOException {
SocketTimeoutException exception = null;
Throwable exception = null;
for (int i = 0; i < retryTimes; i++) {
try {
return supplier.get();
} catch (SocketTimeoutException e) {
} catch (Throwable e) {
exception = e;
}
}
if (exception != null)
throw exception;
if (exception != null) {
if (exception instanceof IOException) {
throw (IOException) exception;
} else {
throw new IOException(exception);
}
}
throw new IOException("retry 0");
}

Expand Down

0 comments on commit bd39178

Please sign in to comment.