portletspec3
  1. portletspec3
  2. PORTLETSPEC3-23

Errata: Issue in GenericPortlet Exception Handling for Annotations

    Details

      Description

      The doView Method is defined to throw two exceptions - a PortletException
      and a java.io.IOException.

      -------------------------
      protected void doView(RenderRequest request, RenderResponse response)
      throws PortletException, java.io.IOException

      { ... }

      -------------------------

      However, the annotation handling code in the GenericPortlet doDispatch() method
      wraps all exceptions from an annotated method as a PortletException so that
      effectively a potential java.io.IOException is never thrown.

      -------------------------
      try {
      // check if mode is cached
      if ( renderModeHandlingMethodsMap.containsKey(mode) )

      { renderModeHandlingMethodsMap.get(mode).invoke(this, request, response); return; }
      } catch (Exception e) { throw new PortletException(e); }
      -------------------------

      the processAction() and processEvent() code wraps all exceptions from annotated
      methods as PortletExceptions in the same manner. The corrected exception handling
      code should be something like:

      Corrected:
      -------------------------
      try {
      // check if mode is cached
      if ( renderModeHandlingMethodsMap.containsKey(mode) ) { renderModeHandlingMethodsMap.get(mode).invoke(this, request, response); return; }


      } catch (InvocationTargetException ex) {
      // root cause
      final Throwable th = ex.getCause();
      // fallthru
      if (th instanceof PortletException)

      { throw (PortletException) th; }

      else
      if (th instanceof IOException)

      { throw (IOException) th; }

      else
      if (th instanceof RuntimeException)

      { throw (RuntimeException) th; }

      else

      { // rethrow throw new PortletException(ex); }

      }
      -------------------------

        Activity

        msnicklous created issue -
        msnicklous made changes -
        Field Original Value New Value
        Assignee msnicklous [ msnicklous ]
        msnicklous made changes -
        Status Open [ 1 ] In Progress [ 3 ]
        msnicklous made changes -
        Status In Progress [ 3 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]

          People

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

            Dates

            • Created:
              Updated:
              Resolved: