Skip to content

Commit

Permalink
[FIXED JENKINS-24161] Break recursion in UpstreamCause.onLoad.
Browse files Browse the repository at this point in the history
  • Loading branch information
jglick committed Aug 7, 2014
1 parent b55f5eb commit 479dfb4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
3 changes: 3 additions & 0 deletions changelog.html
Expand Up @@ -67,6 +67,9 @@
<li class="bug">
Improving security of <code>set-build-parameter</code> and <code>set-build-result</code> CLI commands.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-24080">issue 24080</a>)
<li class="bug">
Startup can be broken by deeply recursive causes in build records.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-24161">issue 24161</a>)
<li class="rfe">
Added support for host:port format in X-Forwarded-Host header.
(<a href="https://github.com/jenkinsci/jenkins/commit/19d8b80bb2f33e4877c7170bcca8bfa318ebe77d">commit 19d8b80</a>)
Expand Down
18 changes: 10 additions & 8 deletions core/src/main/java/hudson/model/Cause.java
Expand Up @@ -98,6 +98,13 @@ public void onLoad(@Nonnull Run<?,?> build) {
}
}

void onLoad(@Nonnull Job<?,?> job, int buildNumber) {
Run<?,?> build = job.getBuildByNumber(buildNumber);
if (build != null) {
onLoad(build);
}
}

@Deprecated
public void onLoad(AbstractBuild<?,?> build) {
if (Util.isOverridden(Cause.class, getClass(), "onLoad", Run.class)) {
Expand Down Expand Up @@ -178,22 +185,16 @@ private UpstreamCause(String upstreamProject, int upstreamBuild, String upstream
}

@Override
public void onLoad(@Nonnull Run run) {
public void onLoad(@Nonnull Job<?,?> _job, int _buildNumber) {
Item i = Jenkins.getInstance().getItemByFullName(this.upstreamProject);
if (i == null || !(i instanceof Job)) {
// cannot initialize upstream causes
return;
}

Job j = (Job)i;
Run r = j.getBuildByNumber(this.getUpstreamBuild());
if (r == null) {
// build doesn't exist anymore
return;
}

for (Cause c : this.upstreamCauses) {
c.onLoad(r);
c.onLoad(j, upstreamBuild);
}
}

Expand Down Expand Up @@ -349,6 +350,7 @@ public static class DeeplyNestedUpstreamCause extends Cause {
@Override public String toString() {
return "JENKINS-14814";
}
@Override public void onLoad(@Nonnull Job<?,?> _job, int _buildNumber) {}
}

}
Expand Down

0 comments on commit 479dfb4

Please sign in to comment.