-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Rollback to official source when any errors occur in the image #6636
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: v3_openjdk
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,7 +21,6 @@ public static void download(String url, OutputStream os) throws IOException { | |
} | ||
|
||
public static void download(URL url, OutputStream os) throws IOException { | ||
InputStream is = null; | ||
try { | ||
// System.out.println("Connecting: " + url.toString()); | ||
HttpURLConnection conn = (HttpURLConnection) url.openConnection(); | ||
|
@@ -30,21 +29,16 @@ public static void download(URL url, OutputStream os) throws IOException { | |
conn.setDoInput(true); | ||
conn.connect(); | ||
if (conn.getResponseCode() != HttpURLConnection.HTTP_OK) { | ||
throw new IOException("Server returned HTTP " + conn.getResponseCode() | ||
// We may be on the mirror, just give it a chance to rollback to official | ||
throw new SocketException("Server returned HTTP " + conn.getResponseCode() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wrong Exception kind, as on a technical level, the communication was executed successfully. Suggestion: Create an alternate Exception type like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Created |
||
+ ": " + conn.getResponseMessage()); | ||
} | ||
is = conn.getInputStream(); | ||
IOUtils.copy(is, os); | ||
} catch (IOException e) { | ||
throw new IOException("Unable to download from " + url, e); | ||
} finally { | ||
if (is != null) { | ||
try { | ||
is.close(); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
try (InputStream is = conn.getInputStream()) { | ||
IOUtils.copy(is, os); | ||
} | ||
} catch (IOException e) { // Here Is Socket Exception | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: remove comment There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. removed comment |
||
Log.w("DownloadUtils", "Unable to download from " + url, e); | ||
throw e; | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment should not be there.
download
is a general purpose function.Suggestion: remove the comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed comment