[MAGNOLIA-8636] PropertyUtil: null list value always converted to list of empty Strings, no matter of the property type Created: 14/Nov/22 Updated: 07/Mar/23 |
|
| Status: | Open |
| Project: | Magnolia |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Neutral |
| Reporter: | Roman Kovařík | Assignee: | Unassigned |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||
| 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
|
||||||||||||||||
| Epic Link: | FieldsMaintenance | ||||||||||||||||
| Description |
Steps to reproduce
PropertyUtil.setProperty(node, name, Arrays.asList(Calendar.getInstance().getTime(), null));
Expected resultsassertThat(node, hasProperty("multiValue", new Object[]{null, date})); passes Actual resultsThe assertion fails. WorkaroundCreate the value manually like this:
var valueFactory = node.getSession().getValueFactory();
node.setProperty(name, ((List<?>) value).stream()
.map(Exceptions.wrap().function(o -> o == null ? null :
PropertyUtil.createValue(o, valueFactory)))
.toArray(Value[]::new)
);
Development notes
|