Uploaded image for project: 'Magnolia UI'
  1. Magnolia UI
  2. MGNLUI-2408

MultiValueJSONTransformer - NPE

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Neutral Neutral
    • None
    • 5.1
    • None
    • Yes

      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;
          }
      

        Acceptance criteria

              fgrilli Federico Grilli
              rulate Ricardo Ulate
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: