Uploaded image for project: 'Magnolia'
  1. Magnolia
  2. MAGNOLIA-8636

PropertyUtil: null list value always converted to list of empty Strings, no matter of the property type

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Neutral Neutral
    • None
    • None
    • None
    • None

      Steps to reproduce

      PropertyUtil.setProperty(node, name, Arrays.asList(Calendar.getInstance().getTime(), null));
      

      Expected results

      assertThat(node, hasProperty("multiValue", new Object[]{null, date})); 
      

      passes

      Actual results

      The assertion fails.

      Workaround

      Create 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

      1. PropertUtils points to https://git.magnolia-cms.com/projects/PLATFORM/repos/main.pub/browse/magnolia-core/src/main/java/info/magnolia/jcr/util/PropertyUtil.java#140
      2. And that to https://git.magnolia-cms.com/projects/PLATFORM/repos/main.pub/browse/magnolia-core/src/main/java/info/magnolia/jcr/util/PropertyUtil.java#347 Here one would expect to not fallback to empty String but just return null as JCR Value
      3. When this is fixed, assertion fails on NPE in PropertyUtil.getValue which might be fixed as well as part of this ticket

        Acceptance criteria

              Unassigned Unassigned
              rkovarik Roman Kovařík
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:

                  Bug DoR
                  Task DoD