Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.net.UnknownHostException;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
Expand Down Expand Up @@ -381,7 +382,9 @@ private boolean shouldRetryDownload(IOException e, int attempt) {
}

private boolean isRetryableException(Throwable e) {
return e instanceof ContentLengthMismatchException || e instanceof SocketException;
return e instanceof ContentLengthMismatchException
|| e instanceof SocketException
|| e instanceof UnknownHostException;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,9 @@ URLConnection connect(
} catch (UnknownHostException e) {
String message = "Unknown host: " + e.getMessage();
eventHandler.handle(Event.progress(message));
throw new UnrecoverableHttpException(message);
IOException httpException = new UnrecoverableHttpException(message);
httpException.addSuppressed(e);
throw httpException;
Comment on lines +163 to +165

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

This change wraps UnknownHostException in an UnrecoverableHttpException. However, the PR description states that UnknownHostException should trigger retry logic, and DownloadManager.java has been updated to consider UnknownHostException as retryable. By wrapping it in UnrecoverableHttpException, the DownloadManager will not retry, as UnrecoverableHttpException is not listed as a retryable exception. This contradicts the stated goal of the pull request. To enable retries for UnknownHostException, it should either be re-thrown directly or wrapped in an exception that DownloadManager recognizes as retryable.

Suggested change
IOException httpException = new UnrecoverableHttpException(message);
httpException.addSuppressed(e);
throw httpException;
throw e;

} catch (IllegalArgumentException e) {
// This will happen if the user does something like specify a port greater than 2^16-1.
throw new UnrecoverableHttpException(e.getMessage());
Expand Down
Loading