Skip to content

Commit

Permalink
[JENKINS-16845] Hotfix to at least allow the job to be loaded.
Browse files Browse the repository at this point in the history
Root cause seems to be broken serial form of FingerprintAction, probably caused by lazy loading.
  • Loading branch information
jglick committed Apr 3, 2013
1 parent e172407 commit 353ebe6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
3 changes: 3 additions & 0 deletions changelog.html
Expand Up @@ -58,6 +58,9 @@
<li class=bug>
JUnit result archiver should only fail builds if there are really no results - i.e. also no skipped tests.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-7970">issue 7970</a>)
<li class='major bug'>
<code>NullPointerException</code> related to lazy loading when loading some builds using fingerprinting.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-16845">issue 16845</a>)
<li class=rfe>
Better display of parameters in queue items.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-17454">issue 17454</a>)
Expand Down
12 changes: 11 additions & 1 deletion core/src/main/java/hudson/tasks/Fingerprinter.java
Expand Up @@ -294,7 +294,7 @@ public boolean isApplicable(Class<? extends AbstractProject> jobType) {
*/
public static final class FingerprintAction implements RunAction {

private final AbstractBuild build;
private AbstractBuild build;

private static final Random rand = new Random();

Expand Down Expand Up @@ -343,6 +343,11 @@ public Map<String,String> getRecords() {
}

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) {
Expand Down Expand Up @@ -430,6 +435,11 @@ public Map<AbstractProject,Integer> getDependencies() {
public Map<AbstractProject,Integer> getDependencies(boolean includeMissing) {
Map<AbstractProject,Integer> r = new HashMap<AbstractProject,Integer>();

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
Expand Down
Expand Up @@ -30,7 +30,9 @@ THE SOFTWARE.
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
<l:layout>
<st:include it="${it.build}" page="sidepanel.jelly" />
<j:if test="${it.build != null}">
<st:include it="${it.build}" page="sidepanel.jelly"/>
</j:if> <!-- else broken -->
<l:main-panel>
<h1>
<img src="${imagesURL}/48x48/fingerprint.png" alt="" height="48" width="48"/>
Expand Down

0 comments on commit 353ebe6

Please sign in to comment.