Re: Exception swallowed in JSF phase class

Splash Forums PrettyFaces Users Exception swallowed in JSF phase class Re: Exception swallowed in JSF phase class

#21004

rspuler
Participant

The exception is logged with level WARNING. So there is no problem for me to find out what the exception is.

What I would like to do is to handle the exceptions in a general manner higher up the call stack. But because the handleAfterPhase just swallows the exception and returns from the method the exception never gets there.

I use 3.3.0 but I don’t think the type of exception is a problem as this method catches all exceptions.

Here is the method from com.sun.faces.lifecycle.Phase.

protected void handleAfterPhase(FacesContext context,
ListIterator<PhaseListener> listenersIterator,
PhaseEvent event) {

while (listenersIterator.hasPrevious()) {
PhaseListener listener = listenersIterator.previous();
if (this.getId().equals(listener.getPhaseId()) ||
PhaseId.ANY_PHASE.equals(listener.getPhaseId())) {
try {
listener.afterPhase(event);
} catch (Exception e) {
if (LOGGER.isLoggable(Level.WARNING)) {
LOGGER.log(Level.WARNING,
"jsf.lifecycle.phaselistener.exception",
new Object[]{
listener.getClass().getName()
+ ".afterPhase()",
this.getId().toString(),
((context.getViewRoot() != null)
? context.getViewRoot().getViewId()
: ""),
e});
LOGGER.warning(Util.getStackTraceString(e));
return;
}
}
}
}

}