[MGNLUI-1791] Suspicious handling of null selection in ListViewImpl Created: 27/Jun/13  Updated: 03/Apr/18  Resolved: 03/Apr/18

Status: Closed
Project: Magnolia UI
Component/s: None
Affects Version/s: 5.0
Fix Version/s: None

Type: Bug Priority: Neutral
Reporter: Tobias Mattsson Assignee: Unassigned
Resolution: Outdated Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[ ]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled

 Description   

The ValueChangeListener in ListViewImpl creates a Set of size 1 containing the null value and then passes this Set to its listener, AbstractContentPresenter#onItemSelection. It expects to be given a Set of zero elements when nothing is selected.

The code should be changed to:

                    Set<String> items;
                    if (value instanceof Set) {
                        items = (Set<String>) value;
                    } else {
                        items = new LinkedHashSet<String>();
                        if (value != null) {
                            items.add((String) value);
                        }
                    }
                    listener.onItemSelection(items);

We need to be make sure this doesn't have side effects elsewhere. Because the set is later passed to setSelectedItemIds() and a ContentChangedEvent is sent containing jcr item adapters, this is probably also a collection of size 1 containing null.


Generated at Mon Feb 12 08:50:10 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.