Skip to content

Commit

Permalink
[JENKINS-32831] if metadata for tool installer does not exist should …
Browse files Browse the repository at this point in the history
…not fail

(cherry picked from commit d2b1f15)
  • Loading branch information
varmenise authored and olivergondza committed Mar 30, 2016
1 parent c57af86 commit 951729c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions core/src/main/java/hudson/model/DownloadService.java
Expand Up @@ -395,10 +395,12 @@ private FormValidation load(String json, long dataTimestamp) throws IOException
@Restricted(NoExternalUse.class)
public FormValidation updateNow() throws IOException {
List<JSONObject> jsonList = new ArrayList<>();
boolean toolInstallerMetadataExists = false;
for (String site : getUrls()) {
String jsonString;
try {
jsonString = loadJSONHTML(new URL(site + ".html?id=" + URLEncoder.encode(getId(), "UTF-8") + "&version=" + URLEncoder.encode(Jenkins.VERSION, "UTF-8")));
toolInstallerMetadataExists = true;
} catch (Exception e) {
LOGGER.log(Level.WARNING, "Could not load json from " + site, e );
continue;
Expand All @@ -407,13 +409,17 @@ public FormValidation updateNow() throws IOException {
if (signatureCheck) {
FormValidation e = new JSONSignatureValidator("downloadable '"+id+"'").verifySignature(o);
if (e.kind!= Kind.OK) {
LOGGER.log(Level.WARNING, "signature check failed for " + site, e );
continue;
}
}
jsonList.add(o);
}
if (jsonList.size() == 0) {
return FormValidation.warning("None of the Update Sites passed the signature check");
if (jsonList.size() == 0 && toolInstallerMetadataExists) {
return FormValidation.warning("None of the tool installer metadata passed the signature check");
} else if (!toolInstallerMetadataExists) {
LOGGER.log(Level.WARNING, "No tool installer metadata found for " + id);
return FormValidation.ok();
}
JSONObject reducedJson = reduce(jsonList);
return load(reducedJson.toString(), System.currentTimeMillis());
Expand Down

0 comments on commit 951729c

Please sign in to comment.