Uploaded image for project: 'Sling'
  1. Sling
  2. SLING-3547

Default handling for numerical types on Sling Models broken

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • Sling Models Implementation 1.0.2, Sling Models Implementation 1.0.4
    • Extensions
    • None

    Description

      Currently all default annotations on numeric types lead to the following warning:
      org.apache.sling.models.impl.ModelAdapterFactory Default values for class java.lang.Boolean are not supported and the default is not used.

      This is due to the fact that first all types are converted from Primitives to Object Wrapper Classes (in mapPrimitiveClasses). Then the comparison against that type only considers Primitives (in getDefaultValue, except for Strings), which obviously failed, because either those were Object Wrapper Classes right from the beginning, or they were converted to those.

      In my regard you should compare the Type against e.g. Integer.class instead of Integer.TYPE (ModelAdapterFactory, line 428ff). Otherwise defaults for numerical types will not work.

      Attachments

        Issue Links

          Activity

            People

              justinedelson Justin Edelson
              kwin Konrad Windszus
              Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: