Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-48293

Default values are ignored if a null value is set in preferences

    Details

      Description

      If a null value is set to the preferences, the default value is not used.
      e.g.

      portletPreferences.setValue(key, null);
      
      
      portletPreferences.getValue(key, someDefaultValue)) == null
      

      According to the specification, "A null value is treated as a non-existent value", thus the default value should be used.

      This behavior causes problem during the import process, when the preferences are copied. When there is no value for a key, a null value is copied to the preferences. Querying this value ignores the default value, and returns null, which leads to NullPointerExceptions.

      Possible reproduction steps:

      1. Create a Site Template
      2. Add an RSS portlet to a page, configure it, delete all of the displayed feeds.
      3. Create a Site from the template
      4. Go to the page with the RSS portlet, modify something the page.
      5. At the top of the page, a message is displayed: "This page has been changed since the last update from the site template. "
      6. Reset the changes
      7. Refresh the page

      Result: NullPointerException in the logs.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              felix.zhang Felix Zhang
              Reporter:
              tamas.molnar Tamas Molnar
              Participants of an Issue:
              Recent user:
              Esther Sanz
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Days since last comment:
                6 years, 32 weeks, 3 days ago

                  Packages

                  Version Package
                  6.2.2 CE GA3
                  6.2.X EE
                  7.0.0 M1