FacesContext
instances are unique per thread, and The FacesServlet
creates a ThreadLocal<FacesContext>
on the beginning of the request while acquiring the FacesContext
(which is the contract of FacesContextFactory#getFacesContext)
and removes it on the end of the response associated with the HTTP servlet request (by calling the FacesContext#release
).
Whenever you do a FacesContext#getCurrentInstance()
in your JSF code, you'll always get the same instance throughout the entire HTTP servlet request/response processing.
About the method UIViewRoot#processDecodes
,I really don't see any line which probably can indicate that method uses it's own created instance rather than the passed one. Which line made you think that?
It can be seen in the FacesServlet#service
method that it creates the FacesContext
from The FacesContextFactory
, here is a excerpt from the FacesServlet#service
method which shows this -
// Acquire the FacesContext instance for this request
FacesContext context = facesContextFactory.getFacesContext
(servletConfig.getServletContext(), request, response, lifecycle);
// Execute the request processing lifecycle for this request
try {
...
} catch (FacesException e) {
...
}
finally {
// Release the FacesContext instance for this request
context.release();
}
Considering this, I don't feel UIViewRoot#processDecodes
can have the FacesContext
instance which is not from FacesContextFactory
.
Since you're saying - you have set some additional parameters to the FacesContext
which get returned from FacesContextFactory
, that means you have your own custom implementation of FacesContextFactory
, if this is the case then are you sure that your instance is injected in the FacesServlet
and not mojarra's com.sun.faces.context.FacesContextFactoryImpl
(if you're using mojarra)?