Skip to content

Commit

Permalink
Merge pull request #2050 from varmenise/JENKINS-32831
Browse files Browse the repository at this point in the history
[FIXED JENKINS-32831] do not fail if there are no metadata for tool installers
  • Loading branch information
daniel-beck committed Mar 16, 2016
2 parents 37111bf + 3deb73b commit d8241ff
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 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
4 changes: 2 additions & 2 deletions core/src/main/java/hudson/tools/DownloadFromUrlInstaller.java
Expand Up @@ -136,7 +136,7 @@ public Downloadable createDownloadable() {
final DownloadFromUrlInstaller.DescriptorImpl delegate = (DownloadFromUrlInstaller.DescriptorImpl)this;
return new Downloadable(getId()) {
public JSONObject reduce(List<JSONObject> jsonList) {
if (isDefualtSchema(jsonList)) {
if (isDefaultSchema(jsonList)) {
return delegate.reduce(jsonList);
} else {
//if it's not default schema fall back to the super class implementation
Expand All @@ -153,7 +153,7 @@ public JSONObject reduce(List<JSONObject> jsonList) {
* @param jsonList the list of Update centers json files
* @return true if the schema is the default one (id, name, url), false otherwise
*/
private boolean isDefualtSchema(List<JSONObject> jsonList) {
private boolean isDefaultSchema(List<JSONObject> jsonList) {
JSONObject jsonToolInstallerList = jsonList.get(0);
ToolInstallerList toolInstallerList = (ToolInstallerList) JSONObject.toBean(jsonToolInstallerList, ToolInstallerList.class);

Expand Down

0 comments on commit d8241ff

Please sign in to comment.