Re: [solved] Getting Exception rarerly with my website

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


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
String viewId = prettyContext.getCurrentCalculatedViewId();
messagesUtils.saveMessages(facesContext, facesContext.getExternalContext().getRequestMap());

// should be in a finally block

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?