Issue Details (XML | Word | Printable)

Key: PORTLETSPEC3-23
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Minor Minor
Assignee: msnicklous
Reporter: msnicklous
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
portletspec3

Errata: Issue in GenericPortlet Exception Handling for Annotations

Created: 13/May/13 01:38 PM   Updated: 19/Aug/13 01:13 PM   Resolved: 19/Aug/13 01:13 PM
Component/s: JSR 286 Portlet Specification Errata
Affects Version/s: None
Fix Version/s: None

Time Tracking:
Not Specified

Tags:
Participants: msnicklous


 Description  « Hide

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); }
}
-------------------------



msnicklous added a comment - 19/Aug/13 01:13 PM

updated GenericPortlet.java. Code change only; no apidoc change. See: GenericPortlet.java

Test portlet: PORTLETSPEC3_23 from portletbox.