Skip to content
Permalink
Browse files

[FIXED JENKINS-25073] Avoid double-counting health metrics from subfo…

…lders.
  • Loading branch information...
jglick committed Oct 9, 2014
1 parent 70a4d47 commit 832860377665641de69fcc8848f7ce342ca980fd
@@ -25,13 +25,11 @@
package com.cloudbees.hudson.plugins.folder.health;

import com.cloudbees.hudson.plugins.folder.Folder;
import com.cloudbees.hudson.plugins.folder.FolderProperty;
import hudson.DescriptorExtensionList;
import hudson.model.AbstractDescribableImpl;
import hudson.model.HealthReport;
import hudson.model.Hudson;
import hudson.model.Item;
import hudson.model.Job;
import hudson.model.TopLevelItem;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@@ -62,6 +60,11 @@ public static HealthReport getHealthReport(Item item) {
}

public static interface Reporter {
/**
* Called during recursive traversal of the tree from the folder on which this metric is specified.
* May be called on intermediate {@code Folder}s, so implementations should not call {@link #getHealthReport} in this case.
* @param item a {@link Folder} or any other {@link TopLevelItem}
*/
void observe(Item item);
List<HealthReport> report();
}
@@ -24,6 +24,7 @@

package com.cloudbees.hudson.plugins.folder.health;

import com.cloudbees.hudson.plugins.folder.Folder;
import hudson.Extension;
import hudson.model.HealthReport;
import hudson.model.Item;
@@ -60,6 +61,10 @@ public String getDisplayName() {
HealthReport worst = null;

public void observe(Item item) {
if (item instanceof Folder) {
// only interested in non-folders in order to prevent double counting
return;
}
HealthReport report = getHealthReport(item);
if (report != null && (worst == null || report.getScore() < worst.getScore())) {
worst = new HealthReport(report.getScore(), report.getIconUrl(),

0 comments on commit 8328603

Please sign in to comment.
You can’t perform that action at this time.