-
Notifications
You must be signed in to change notification settings - Fork 814
优化下载SSL异常处理 #5168
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
优化下载SSL异常处理 #5168
Changes from all 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 | ||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -134,7 +134,10 @@ public static String localizeErrorMessage(Throwable exception) { | |||||||||||||||||||||||||||||||||||||||||
| return i18n("install.failed.downloading.detail", uri) + "\n" + i18n("exception.access_denied", ((AccessDeniedException) exception.getCause()).getFile()); | ||||||||||||||||||||||||||||||||||||||||||
| } else if (exception.getCause() instanceof ArtifactMalformedException) { | ||||||||||||||||||||||||||||||||||||||||||
| return i18n("install.failed.downloading.detail", uri) + "\n" + i18n("exception.artifact_malformed"); | ||||||||||||||||||||||||||||||||||||||||||
| } else if (exception.getCause() instanceof SSLHandshakeException) { | ||||||||||||||||||||||||||||||||||||||||||
| } else if (exception.getCause() instanceof SSLHandshakeException && !(exception.getCause().getMessage() != null && exception.getCause().getMessage().contains("Remote host terminated"))) { | ||||||||||||||||||||||||||||||||||||||||||
| if (exception.getCause().getMessage() != null && (exception.getCause().getMessage().contains("No name matching") || exception.getCause().getMessage().contains("No subject alternative DNS name matching"))) { | ||||||||||||||||||||||||||||||||||||||||||
| return i18n("install.failed.downloading.detail", uri) + "\n" + i18n("exception.dns.pollution"); | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
| return i18n("install.failed.downloading.detail", uri) + "\n" + i18n("exception.ssl_handshake"); | ||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||
| return i18n("install.failed.downloading.detail", uri) + "\n" + StringUtils.getStackTrace(exception.getCause()); | ||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+137
to
143
|
||||||||||||||||||||||||||||||||||||||||||
| } else if (exception.getCause() instanceof SSLHandshakeException && !(exception.getCause().getMessage() != null && exception.getCause().getMessage().contains("Remote host terminated"))) { | |
| if (exception.getCause().getMessage() != null && (exception.getCause().getMessage().contains("No name matching") || exception.getCause().getMessage().contains("No subject alternative DNS name matching"))) { | |
| return i18n("install.failed.downloading.detail", uri) + "\n" + i18n("exception.dns.pollution"); | |
| } | |
| return i18n("install.failed.downloading.detail", uri) + "\n" + i18n("exception.ssl_handshake"); | |
| } else { | |
| return i18n("install.failed.downloading.detail", uri) + "\n" + StringUtils.getStackTrace(exception.getCause()); | |
| } else { | |
| Throwable cause = exception.getCause(); | |
| String causeMessage = cause == null ? null : cause.getMessage(); | |
| boolean isRemoteHostTerminated = causeMessage != null && causeMessage.contains("Remote host terminated"); | |
| if (cause instanceof SSLHandshakeException && !isRemoteHostTerminated) { | |
| if (causeMessage != null && (causeMessage.contains("No name matching") || causeMessage.contains("No subject alternative DNS name matching"))) { | |
| return i18n("install.failed.downloading.detail", uri) + "\n" + i18n("exception.dns.pollution"); | |
| } | |
| return i18n("install.failed.downloading.detail", uri) + "\n" + i18n("exception.ssl_handshake"); | |
| } else { | |
| return i18n("install.failed.downloading.detail", uri) + "\n" + StringUtils.getStackTrace(exception.getCause()); | |
| } |
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.
The method call exception.getCause().getMessage() is repeated multiple times on lines 137-138. Consider caching this value in a local variable to improve readability and avoid redundant method calls.