Pluto
  1. Pluto
  2. PLUTO-506

Invoking the store() method of PortletPreferences object results in NPE if no preferences declared in portlet.xml

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0-refactoring, 2.0.0
    • Fix Version/s: 2.0-refactoring, 2.0.0
    • Component/s: portlet container
    • Labels:
      None
    • Environment:
      JDK 1.5.0_16, Tomcat 5.5.27

      Description

      If you have not declared any preferences for a portlet in the deployment descriptor (portlet.xml) and then invoke the store() method of the PortletPreferences object, a NullPointerException is thrown with the following stack trace:

      java.lang.NullPointerException
      at org.apache.pluto.internal.PreferencesValidatorRegistry.getPreferencesValidator(PreferencesValidatorRegistry.java:97)
      at org.apache.pluto.internal.impl.PortletEntityImpl.getPreferencesValidator(PortletEntityImpl.java:167)
      at org.apache.pluto.internal.impl.PortletPreferencesImpl.internalStore(PortletPreferencesImpl.java:298)
      at org.apache.pluto.internal.impl.PortletPreferencesImpl.store(PortletPreferencesImpl.java:277) . . .

      In the getPreferencesValidator() method of the PreferencesValidatorRegistry the PortletPreferencesDD object is retrieved and its getPreferencesValidator() method is invoked without first checking to see if the PortletPreferencesDD object is null.

      As a workaround you can make sure that you always declare at least one preference in your portlet.xml file – this will ensure that the PortletPreferencesDD object is not null.

      1. patch-506.txt
        3 kB
        Brian DeHamer

        Activity

        Brian DeHamer created issue -
        Hide
        Brian DeHamer added a comment -

        The attached patch to the PreferencesValidatorRegistry class updates the getPreferencesValidator method to ensure that the PortletPreferencesDD is non-null before invoking its getPreferencesValidator() method.

        Show
        Brian DeHamer added a comment - The attached patch to the PreferencesValidatorRegistry class updates the getPreferencesValidator method to ensure that the PortletPreferencesDD is non-null before invoking its getPreferencesValidator() method.
        Brian DeHamer made changes -
        Field Original Value New Value
        Attachment patch-506.txt [ 12391644 ]
        Hide
        Craig Doremus added a comment -

        Applied patch in SVN rev 702737 and 702738. Thank you Brian!

        Show
        Craig Doremus added a comment - Applied patch in SVN rev 702737 and 702738. Thank you Brian!
        Craig Doremus made changes -
        Resolution Fixed [ 1 ]
        Status Open [ 1 ] Closed [ 6 ]
        Mark Thomas made changes -
        Workflow jira [ 12443651 ] Default workflow, editable Closed status [ 12565049 ]
        Mark Thomas made changes -
        Workflow Default workflow, editable Closed status [ 12565049 ] jira [ 12586155 ]

          People

          • Assignee:
            Unassigned
            Reporter:
            Brian DeHamer
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development