Skip to content

Commit f7bb0c7

Browse files
committed
JENKINS-75602: add error proper errorhandling to the checkUpdatesServer method in PluginManager class
1 parent 1366fa9 commit f7bb0c7

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

core/src/main/java/hudson/PluginManager.java

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2174,19 +2174,33 @@ FormValidation checkUpdateSiteURL(@CheckForNull String value) throws Interrupted
21742174

21752175
private FormValidation checkUpdatesServer() throws Exception {
21762176
for (UpdateSite site : Jenkins.get().getUpdateCenter().getSites()) {
2177-
FormValidation v = site.updateDirectlyNow();
2178-
if (v.kind != FormValidation.Kind.OK) {
2179-
// Stop with an error
2180-
return v;
2177+
try {
2178+
FormValidation v = site.updateDirectlyNow();
2179+
if (v.kind != FormValidation.Kind.OK) {
2180+
// Stop with an error
2181+
return v;
2182+
}
2183+
} catch (IOException e) {
2184+
String url = site.getUrl();
2185+
LOGGER.log(Level.SEVERE, "Failed to check updates server: " + url, e);
2186+
return FormValidation.error("Failed to check updates server: " + e.getMessage());
21812187
}
21822188
}
2189+
21832190
for (DownloadService.Downloadable d : DownloadService.Downloadable.all()) {
2184-
FormValidation v = d.updateNow();
2185-
if (v.kind != FormValidation.Kind.OK) {
2186-
// Stop with an error
2187-
return v;
2191+
try {
2192+
FormValidation v = d.updateNow();
2193+
if (v.kind != FormValidation.Kind.OK) {
2194+
// Stop with an error
2195+
return v;
2196+
}
2197+
} catch (IOException e) {
2198+
String url = d.getUrl();
2199+
LOGGER.log(Level.SEVERE, "Failed to update downloadable: " + url, e);
2200+
return FormValidation.error(e, "Failed to update downloadable: " + e.getMessage());
21882201
}
21892202
}
2203+
21902204
return FormValidation.ok();
21912205
}
21922206

0 commit comments

Comments
 (0)