Skip to content

Commit

Permalink
Merge pull request #4 from jglick/NPE-JENKINS-17248
Browse files Browse the repository at this point in the history
[JENKINS-17248] Robustness against NPE
  • Loading branch information
fcamblor committed Sep 7, 2013
2 parents 2b4f1b3 + d919780 commit dff58df
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
Expand Up @@ -16,6 +16,7 @@
import hudson.security.Permission;
import hudson.util.ChartUtil;
import hudson.util.FormValidation;
import java.io.File;

import java.io.IOException;
import java.util.ArrayList;
Expand Down Expand Up @@ -98,6 +99,10 @@ public void load() throws IOException {
super.load();
}

public File getConfigXmlFile() {
return getConfigXml().getFile();
}

/**
* Hack allowing to either generate plugin informations (build stat configurations) OR
* generate chart data for a given buildStatConfigId request parameter
Expand Down
Expand Up @@ -10,6 +10,7 @@
import hudson.plugins.global_build_stats.xstream.GlobalBuildStatsXStreamConverter;
import hudson.security.Permission;
import hudson.util.DaemonThreadFactory;
import java.io.File;
import org.kohsuke.stapler.export.Exported;

import java.io.IOException;
Expand Down Expand Up @@ -98,6 +99,13 @@ public void reloadPlugin() {
this.plugin.load();
} catch (IOException e) {
LOGGER.log(Level.SEVERE, e.getMessage(), e);
} catch (NullPointerException x) {
File f = plugin.getConfigXmlFile();
File bak = new File(f.getParentFile(), f.getName() + ".bak");
if (!f.renameTo(bak)) {
LOGGER.log(Level.WARNING, "failed to rename {0} to {1}", new Object[] {f, bak});
}
LOGGER.log(Level.WARNING, "JENKINS-17248 load failure; saving problematic file to " + bak, x);
}
}

Expand Down

3 comments on commit dff58df

@jglick
Copy link
Member

@jglick jglick commented on dff58df Oct 4, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just saw someone else hit this bug in 1.509.3; do you plan to release a plugin update?

@fcamblor
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not having time to release ATM, if you want to release, I'm OK go for it (not working on urgent things on the plugin ATM)

@jglick
Copy link
Member

@jglick jglick commented on dff58df Oct 4, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, not releasing since I tried to sanity-check the plugin but I could not get it to do anything; always shows an empty chart no matter what I try.

Please sign in to comment.