Skip to content

Commit

Permalink
[JENKINS-33591] Don't modify CauseAction's causes
Browse files Browse the repository at this point in the history
The cause list is immutable as described in the comments of
JENKINS-33467.
  • Loading branch information
solita-timo-mihaljov committed Mar 20, 2016
1 parent 3b4634e commit d56ff03
Showing 1 changed file with 4 additions and 2 deletions.
Expand Up @@ -475,10 +475,12 @@ private int triggerBuild(final AbstractProject<?, ?> triggerProject, final Abstr
final Action buildParametersAction) {
LOGGER.fine("Triggering build for project: " + triggerProject.getFullDisplayName()); //$NON-NLS-1$
final List<Action> buildActions = new ArrayList<Action>();
final CauseAction causeAction = new CauseAction(new UserIdCause());
final List<Cause> causes = new ArrayList<Cause>();
causes.add(new UserIdCause());
if (upstreamBuild != null) {
causeAction.getCauses().add(new Cause.UpstreamCause((Run<?, ?>) upstreamBuild));
causes.add(new Cause.UpstreamCause((Run<?, ?>) upstreamBuild));
}
final CauseAction causeAction = new CauseAction(causes);
buildActions.add(causeAction);
ParametersAction parametersAction =
buildParametersAction instanceof ParametersAction
Expand Down

2 comments on commit d56ff03

@CloCkWeRX
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@noidi can you please take a look at https://issues.jenkins-ci.org/browse/JENKINS-33935 ; which I believe is regression from this change / needs a similar fix?

@noidi
Copy link

@noidi noidi commented on d56ff03 May 3, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@CloCkWeRX I took a quick glance, and that looks like a similar sort of problem, only there Causes are being removed from a CauseAction instead of being added. The Cause list is now immutable, which is why the call to remove fails with UnsupportedOperationException.

I'm not really familiar with the Build Pipeline Plugin or Jenkins in general (I've only learned enough to make this particular fix), but I think filterOutUserIdCause should return a new CauseAction created with a new list of Causes, as I've done here, instead of modifying the Cause list of the CauseAction it receives as an argument.

Please sign in to comment.