portletspec3
  1. portletspec3
  2. PORTLETSPEC3-20

Errata: Clarification in Javadoc for an illegal scope use in PortletSession methods

    Details

      Description

      Some PortletSession attribute get methods do not specify their behavior when they are invoked with an unknown container scope:

      • PortletSession#getAttribute(String,int)
      • PortletSession#getAttributeNames(int)
      • PortletSession#getAttributeMap(int)
      • PortletSession#removeAttribute(String,int)

      There are other methods of the PortletSession interface that must throw an IllegalArgumentException when the parameter null is provided such as PortletSession#setAttribute(String,Object,int): "java.lang.IllegalArgumentException if name is <code>null</code> or scope is unknown to the container."

      We should change clarify how the getAttribute

      The possible correction are:
      1. the methods should fail fail with throwing an `IllegalArgumentException`
      2. the methods should ignore it (return null or empty map)

      The removeAttribute method should likely be corrected to 1. as the setAttribute(String,Object,int) says clearly "If the value is <code>null</code>, this has the same effect as calling
      removeAttribute()".

      The three other methods could use 1 or 2.

        Activity

        Hide
        msnicklous added a comment -

        I agree that this should be corrected. I think an IllegalArgumentException should be thrown in whenever the scope is unknown to the container.

        Note that in the JSR 286 Javadoc for:

        PortletSession#getAttribute(String,int)
        PortletSession#getAttributeNames(int)

        it states:

        ----------
        Throws:
        java.lang.IllegalStateException - if this method is called on an invalidated session*, or the scope is unknown to the container.*
        ----------

        so we would be changing the type of exception thrown. But an IllegalArgumentException makes more sense to me that an IllegalStateException in this case.

        For:

        PortletSession#getAttributeMap(int)
        PortletSession#removeAttribute(String,int)

        we could just add the IllegalArgumentException when the scope is unknown to the container.

        Show
        msnicklous added a comment - I agree that this should be corrected. I think an IllegalArgumentException should be thrown in whenever the scope is unknown to the container. Note that in the JSR 286 Javadoc for: PortletSession#getAttribute(String,int) PortletSession#getAttributeNames(int) it states: ---------- Throws: java.lang.IllegalStateException - if this method is called on an invalidated session*, or the scope is unknown to the container.* ---------- so we would be changing the type of exception thrown. But an IllegalArgumentException makes more sense to me that an IllegalStateException in this case. For: PortletSession#getAttributeMap(int) PortletSession#removeAttribute(String,int) we could just add the IllegalArgumentException when the scope is unknown to the container.
        Hide
        msnicklous added a comment -

        updated javadoc comments in PortletSession to clarify behavior when the scope is unknown.

        Show
        msnicklous added a comment - updated javadoc comments in PortletSession to clarify behavior when the scope is unknown.

          People

          • Assignee:
            msnicklous
            Reporter:
            julien_viet
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: