[MGNLUI-2408] MultiValueJSONTransformer - NPE Created: 15/Nov/13  Updated: 28/Jan/14  Resolved: 28/Jan/14

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

Type: Bug Priority: Neutral
Reporter: Ricardo Ulate Assignee: Federico Grilli
Resolution: Duplicate Votes: 0
Labels: support
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
duplicate
duplicates MGNLUI-2303 MultiValueJSONTransformer throws an e... Closed
relation
Template:
Patch included:
Yes
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   

read from item method in MultiValueJSONTransformer should check for null before proceeding

this code:

    public PropertysetItem readFromItem() {
        PropertysetItem newValues = new PropertysetItem();

        Property<String> property = getOrCreateProperty(String.class);
        String value = property.getValue();
        List<String> list = Arrays.asList(value.split(","));
        int position = 0;
        for (String element : list) {
            newValues.addItemProperty(position, new DefaultProperty(element));
            position += 1;
        }
        return newValues;
    }

should be something like this:

    public PropertysetItem readFromItem() {
        PropertysetItem newValues = new PropertysetItem();

        Property<String> property = getOrCreateProperty(String.class);
        String value = property.getValue();
        if (value == null)
           return null;
        List<String> list = Arrays.asList(value.split(","));
        int position = 0;
        for (String element : list) {
            newValues.addItemProperty(position, new DefaultProperty(element));
            position += 1;
        }
        return newValues;
    }

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