Re: [solved] Getting Exception rarerly with my website askkuber.com

Splash Forums PrettyFaces Users [solved] Getting Exception rarerly with my website askkuber.com Re: [solved] Getting Exception rarerly with my website askkuber.com

#19940

I did some further research on this. I fully understand why this happens with PrettyFaces 1.2.6. It is definitely a bug in PrettyFaces. This is the code in PrettyFilter:

// FacesContext gets created
FacesContext facesContext = initFacesContext(request, response);

// any exception thrown here are critical
prettyContext.injectParameters();
prettyContext.computeDynamicViewId();
String viewId = prettyContext.getCurrentCalculatedViewId();
messagesUtils.saveMessages(facesContext, facesContext.getExternalContext().getRequestMap());

// should be in a finally block
facesContext.release();

As you can see release() won’t get called when an exception is thrown in the block above. Fixing this is easy.

But I don’t understand why this happens with 3.0.1. In this version the PrettyFilter doesn’t create any FacesContext any more. All JSF depended stuff is done from the PrettyPhaseListener where we get the FacesContext from the PhaseEvent. As we don’t create the FacesContext it isn’t our responsibility to release it.

A looked at the MyFaces 2.0 source to see how JSF implementations handle this. MyFaces releases the FacesContext in a finally block after processing the request in the FacesServlet. But I didn’t check the RI yet.

Any further thoughts on this?