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

PropertyUtil.setProperty fails when passing an integer value

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Neutral Neutral
    • 5.4.8, 5.5
    • 5.4.5, 5.4.7
    • core
    • Saigon 48
    • 3

      Even though JCR's Node API doesn't explicitly allow setting an Integer as a node property (Long is accepted), I think our API could be more lenient and accept an integer value instead of failing as happens to the following code

      info.magnolia.jcr.util.PropertyUtil.setProperty(node, "someProperty", 123)
      

      will fail with

      java.lang.IllegalArgumentException: Cannot set property to a value of type class java.lang.Integer
      at info.magnolia.jcr.util.PropertyUtil.setProperty(PropertyUtil.java:132)
      

      A simple

      else if (propertyValue instanceof Integer) {
                  node.setProperty(propertyName, ((Integer) propertyValue).intValue());
                 }
      

      should do.

        Acceptance criteria

              hieu.nguyen Hieu Nguyen Duc
              fgrilli Federico Grilli
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

                Created:
                Updated:
                Resolved:

                  Bug DoR
                  Task DoD

                    Estimated:
                    Original Estimate - 3d Original Estimate - 3d
                    3d
                    Remaining:
                    Time Spent - 3d 3h Remaining Estimate - 3h
                    3h
                    Logged:
                    Time Spent - 3d 3h Remaining Estimate - 3h
                    3d 3h