Skip to content

Commit

Permalink
[FIXED JENKINS-13353] avoid benign NPE when saving a configuration on…
Browse files Browse the repository at this point in the history
… a master with no executors
  • Loading branch information
Rob Petti committed Apr 5, 2012
1 parent 16ef60d commit 91c658a
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/main/java/hudson/plugins/perforce/PerforceSCM.java
Expand Up @@ -322,9 +322,14 @@ public PerforceSCM(
String systemRoot = null;
if (Hudson.isWindows()) {
try {
EnvVars envVars = Computer.currentComputer().getEnvironment();
systemDrive = envVars.get("SystemDrive");
systemRoot = envVars.get("SystemRoot");
Computer currentComputer = Computer.currentComputer();
// A master with no executors seems to throw an NPE here, so
// we need to check for null.
if(currentComputer != null) {
EnvVars envVars = currentComputer.getEnvironment();
systemDrive = envVars.get("SystemDrive");
systemRoot = envVars.get("SystemRoot");
}
} catch (Exception ex) {
LOGGER.log(Level.WARNING, ex.getMessage(), ex);
}
Expand Down

0 comments on commit 91c658a

Please sign in to comment.