in ideaSupport/src/main/scala/org/jetbrains/sbtidea/download/FileDownloader.scala [145:182]
private def downloadNativeWithConnectionRetry(
url: URL,
reuseExistingPartFile: Boolean
)(progressCallback: ProgressCallback): DownloadedPath = {
val retry1Timeout: Duration = DownloadRetryConnectionTimeoutWait
val retry2Timeout: Duration = DownloadRetryConnectionIssueWait
var isFirstAttempt = true
//noinspection NoTailRecursionAnnotation
def inner(retries1: Long, retries2: Long): DownloadedPath = {
try downloadNative(url, reuseExistingPartFile, isFirstAttempt = isFirstAttempt)(progressCallback)
catch {
//this can happen when server is restarted
case exception @ (_: SocketTimeoutException | _: SSLException) if retries1 > 0 =>
log.warn(s"Error occurred during download: ${exception.getMessage}, retry in $retry1Timeout ...")
Thread.sleep(retry1Timeout.toMillis)
inner(retries1 - 1, retries2)
case downloadException: DownloadException =>
//if we got "404: Not Found" response we can be pretty sure that it's not a network error and hte artefact doesn't exist
if (retries2 <= 0 || downloadException.responseCode.contains(NotFoundHttpResponseCode))
throw downloadException
log.warn(s"Error occurred during download: ${downloadException.getMessage}, retry in $retry2Timeout ...")
Thread.sleep(retry2Timeout.toMillis)
inner(retries1, retries2 - 1)
}
finally {
isFirstAttempt = false
}
}
inner(
DownloadRetryConnectionTimeoutCount,
DownloadRetryConnectionIssueCount
)
}