Skip to content

Commit

Permalink
[FIXED JENKINS-12970] Fixed possible NPE when DI fails to load plugin…
Browse files Browse the repository at this point in the history
…s, not to block whole Jenkins startup.
  • Loading branch information
vjuranek committed Apr 13, 2012
1 parent 85f72f4 commit a1a0230
Showing 1 changed file with 8 additions and 0 deletions.
Expand Up @@ -3,6 +3,7 @@
import hudson.init.InitMilestone;
import hudson.init.Initializer;
import hudson.model.*;
import hudson.plugins.disk_usage.DiskUsageThread.DiskUsageCallable;
import hudson.Extension;
import net.sf.json.JSONObject;
import org.kohsuke.stapler.StaplerRequest;
Expand All @@ -11,6 +12,7 @@
import java.io.ObjectStreamException;
import java.util.Collection;
import java.util.Collections;
import java.util.logging.Logger;

//(basically nothing to see here)
/**
Expand All @@ -33,6 +35,10 @@ public Collection<? extends Action> getJobActions(Job<?, ?> job) {
@Initializer(after = InitMilestone.PLUGINS_STARTED)
public static void transitionAuth() throws IOException {
DiskUsageDescriptor that = (DiskUsageDescriptor) Hudson.getInstance().getDescriptor(DiskUsageProperty.class);
if(that == null){
LOGGER.warning("Cannot convert DiskUsageProjectActions, DiskUsageDescripto is null, check log for previous DI error, e.g. Guice errors.");
return;
}
if (!that.converted) {
DiskUsageProjectActionFactory.DESCRIPTOR.setShowGraph(that.showGraph);
that.converted = true;
Expand Down Expand Up @@ -86,6 +92,8 @@ public void setShowGraph(Boolean showGraph) {
this.showGraph = showGraph;
}
}

public static final Logger LOGGER = Logger.getLogger(DiskUsageProperty.class.getName());
}


0 comments on commit a1a0230

Please sign in to comment.