Skip to content

Commit

Permalink
[JENKINS-47574] - Be protective against null parents in readResolve()
Browse files Browse the repository at this point in the history
  • Loading branch information
oleg-nenashev committed Oct 22, 2017
1 parent 781b257 commit cb7ba5a
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/main/java/org/jenkinsci/lib/envinject/EnvInjectAction.java
Expand Up @@ -159,13 +159,24 @@ public String transformEntry(String key, String value) {
return this;
}

@SuppressFBWarnings(value = "RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE",
justification = "JENKINS-47574 - parent may be null during readResolve()")
private static boolean runHasNoParent(@Nonnull Run<?,?> run) {
return run.getParent() != null;
}

@CheckForNull
private Map<String, String> getEnvironment(@CheckForNull Run<?, ?> build) throws EnvInjectException {

if (build == null) {
return null;
}

// It happens in the case of usage of this logic for a not-fully loaded build
if (runHasNoParent(build)) {
return null;
}

EnvInjectSavable dao = new EnvInjectSavable();
return dao.getEnvironment(build.getRootDir());
}
Expand Down

0 comments on commit cb7ba5a

Please sign in to comment.