Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[JENKINS-33467] Clarifying that CauseAction.getCauses is immutable an…
…d you should construct the action with the causes you want. (cherry picked from commit 4adee75)
- Loading branch information
1 parent
916e759
commit 63886be
Showing
1 changed file
with
9 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -82,14 +82,21 @@ public CauseAction(Collection<? extends Cause> causes) { | |
public CauseAction(CauseAction ca) { | ||
addCauses(ca.getCauses()); | ||
} | ||
|
||
|
||
/** | ||
* Lists all causes of this build. | ||
* Note that the current implementation does not preserve insertion order of duplicates. | ||
* @return an immutable list; | ||
* to create an action with multiple causes use either of the constructors that support this; | ||
* to append causes retroactively to a build you must create a new {@link CauseAction} and replace the old | ||
*/ | ||
@Exported(visibility=2) | ||
public List<Cause> getCauses() { | ||
List<Cause> r = new ArrayList<>(); | ||
for (Map.Entry<Cause,Integer> entry : causeBag.entrySet()) { | ||
r.addAll(Collections.nCopies(entry.getValue(), entry.getKey())); | ||
} | ||
return r; | ||
return Collections.unmodifiableList(r); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
oleg-nenashev
Member
|
||
} | ||
|
||
/** | ||
|
FTR, this was a backward incompatible change and should not have been backported.