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

PropertyUtil.setProperty fails when passing an integer value

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Neutral
    • Resolution: Fixed
    • Affects Version/s: 5.4.5, 5.4.7
    • Fix Version/s: 5.4.8, 5.5
    • Component/s: core
    • Labels:
    • Sprint:
      Saigon 48
    • Story Points:
      3
    • Magnolia Release:
      5.4.8, 5.5

      Description

      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.

        Attachments

          Activity

            People

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

              Dates

              Created:
              Updated:
              Resolved:
              Date of First Response:

                Time Tracking

                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