From 5383ca921edf33db05b43d8e69d54e20540fe462 Mon Sep 17 00:00:00 2001 From: Mikhail Mazurkevich Date: Mon, 2 Aug 2021 14:24:46 +0300 Subject: [PATCH] [jps cache] Add HTTP status code at logging the root cause of failed download GitOrigin-RevId: 788a96457df1aa1759ff9894c4e610c9c92b1df0 --- .../jps/cache/client/JpsCachesDownloader.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/plugins/jps-cache/src/com/intellij/jps/cache/client/JpsCachesDownloader.java b/plugins/jps-cache/src/com/intellij/jps/cache/client/JpsCachesDownloader.java index e8af196e22ea..a837d107e841 100644 --- a/plugins/jps-cache/src/com/intellij/jps/cache/client/JpsCachesDownloader.java +++ b/plugins/jps-cache/src/com/intellij/jps/cache/client/JpsCachesDownloader.java @@ -62,15 +62,23 @@ class JpsCachesDownloader { try { downloaded = downloadFile(description, existing, requestHeaders, indicator); } catch (IOException e) { - if (e instanceof HttpRequests.HttpStatusException && ((HttpRequests.HttpStatusException)e).getStatusCode() == 404) { - LOG.info("File not found to download " + description.getDownloadUrl()); - indicator.finished(); - return null; + int httpStatusCode = -1; + if (e instanceof HttpRequests.HttpStatusException) { + httpStatusCode = ((HttpRequests.HttpStatusException)e).getStatusCode(); + if (httpStatusCode == 404) { + LOG.info("File not found to download " + description.getDownloadUrl()); + indicator.finished(); + return null; + } } // If max attempt count exceeded, rethrow exception further if (attempt != MAX_RETRY_COUNT) { - LOG.info("Failed to download " + description.getDownloadUrl() + ". Attempt " + attempt + " to download file again"); + if (httpStatusCode != -1) { + LOG.info("Failed to download " + description.getDownloadUrl() + " HTTP code: " + httpStatusCode + ". Attempt " + attempt + " to download file again"); + } else { + LOG.info("Failed to download " + description.getDownloadUrl() + ". Attempt " + attempt + " to download file again"); + } } else { throw new IOException(IdeBundle.message("error.file.download.failed", description.getDownloadUrl(), e.getMessage()), e); }