Skip to content

Commit

Permalink
[FIXED JENKINS-20143] Pass full list of all possible jobs to ViewJobF…
Browse files Browse the repository at this point in the history
…ilter when recurse option is set
  • Loading branch information
ndeloof committed Oct 22, 2013
1 parent f9f1483 commit 7115589
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions changelog.html
Expand Up @@ -56,6 +56,10 @@
<div id="trunk" style="display:none"><!--=TRUNK-BEGIN=-->
<ul class=image>
<li class=>
<li class=bug>
Pass full list of all possible jobs to ViewJobFilter when recurse option is set
(a href="https://issues.jenkins-ci.org/browse/JENKINS-20123">issue 20123</a>)

This comment has been minimized.

Copy link
@jglick

jglick Oct 22, 2013

Member

Corrected in 82b6e8e.

</li>
</ul>
</div><!--=TRUNK-END=-->

Expand Down
14 changes: 14 additions & 0 deletions core/src/main/java/hudson/model/ListView.java
Expand Up @@ -175,6 +175,7 @@ public List<TopLevelItem> getItems() {
// check the filters
Iterable<ViewJobFilter> jobFilters = getJobFilters();
List<TopLevelItem> allItems = new ArrayList<TopLevelItem>(parentItems);
if (recurse) allItems = expand(allItems, new ArrayList<TopLevelItem>());
for (ViewJobFilter jobFilter: jobFilters) {
items = jobFilter.filter(items, allItems, this);
}
Expand All @@ -183,6 +184,19 @@ public List<TopLevelItem> getItems() {

return items;
}

private List<TopLevelItem> expand(Collection<TopLevelItem> items, List<TopLevelItem> allItems) {
for (Item item : items) {
if (item instanceof ItemGroup) {
ItemGroup<TopLevelItem> ig = (ItemGroup<TopLevelItem>) item;
expand(ig.getItems(), allItems);
}
if (item instanceof TopLevelItem) {
allItems.add((TopLevelItem) item);
}
}
return allItems;
}

@Override
public boolean contains(TopLevelItem item) {
Expand Down

1 comment on commit 7115589

@jglick
Copy link
Member

@jglick jglick commented on 7115589 Oct 22, 2013

Choose a reason for hiding this comment

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

OK…I will probably wind up rewriting this anyway for JENKINS-20052 (which still has an unresolved performance component), and there is no test here to demonstrate the correct behavior so I will still need to write one.

Please sign in to comment.