From 353ebe6bfed33ef528e661d534449cfafca1aca8 Mon Sep 17 00:00:00 2001 From: Jesse Glick Date: Wed, 3 Apr 2013 16:31:05 -0400 Subject: [PATCH] [JENKINS-16845] Hotfix to at least allow the job to be loaded. Root cause seems to be broken serial form of FingerprintAction, probably caused by lazy loading. --- changelog.html | 3 +++ core/src/main/java/hudson/tasks/Fingerprinter.java | 12 +++++++++++- .../Fingerprinter/FingerprintAction/index.jelly | 4 +++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/changelog.html b/changelog.html index 99e22aa9b3..f826f5d672 100644 --- a/changelog.html +++ b/changelog.html @@ -58,6 +58,9 @@ Upcoming changes
  • JUnit result archiver should only fail builds if there are really no results - i.e. also no skipped tests. (issue 7970) +
  • + NullPointerException related to lazy loading when loading some builds using fingerprinting. + (issue 16845)
  • Better display of parameters in queue items. (issue 17454) diff --git a/core/src/main/java/hudson/tasks/Fingerprinter.java b/core/src/main/java/hudson/tasks/Fingerprinter.java index 01cf2ae196..2bf37ef36d 100644 --- a/core/src/main/java/hudson/tasks/Fingerprinter.java +++ b/core/src/main/java/hudson/tasks/Fingerprinter.java @@ -294,7 +294,7 @@ public class Fingerprinter extends Recorder implements Serializable, DependencyD */ public static final class FingerprintAction implements RunAction { - private final AbstractBuild build; + private AbstractBuild build; private static final Random rand = new Random(); @@ -343,6 +343,11 @@ public class Fingerprinter extends Recorder implements Serializable, DependencyD } public void onLoad() { + if (build.getParent() == null) { + logger.warning("JENKINS-16845: broken FingerprintAction record"); + build = null; + return; + } // share data structure with nearby builds, but to keep lazy loading efficient, // don't go back the history forever. if (rand.nextInt(2)!=0) { @@ -430,6 +435,11 @@ public class Fingerprinter extends Recorder implements Serializable, DependencyD public Map getDependencies(boolean includeMissing) { Map r = new HashMap(); + if (build == null) { + // Broken, do not do anything. + return r; + } + for (Fingerprint fp : getFingerprints().values()) { BuildPtr bp = fp.getOriginal(); if(bp==null) continue; // outside Hudson diff --git a/core/src/main/resources/hudson/tasks/Fingerprinter/FingerprintAction/index.jelly b/core/src/main/resources/hudson/tasks/Fingerprinter/FingerprintAction/index.jelly index fca14503c9..d0b191a5a9 100644 --- a/core/src/main/resources/hudson/tasks/Fingerprinter/FingerprintAction/index.jelly +++ b/core/src/main/resources/hudson/tasks/Fingerprinter/FingerprintAction/index.jelly @@ -30,7 +30,9 @@ THE SOFTWARE. - + + +

    -- GitLab