myfaces-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Leonardo Uribe (Commented) (JIRA)" <>
Subject [jira] [Commented] (MYFACES-3191) Handing exception (in exception handler) from render response phase with forward/redirect is inconsistent
Date Wed, 14 Mar 2012 17:10:46 GMT


Leonardo Uribe commented on MYFACES-3191:

The problem here is to do that we need to buffer the response before send it to the client,
so if an error occur, be able to reset the response and render the error page. This has a
significant impact in performance, specially in memory usage. In client side state saving
a part of the response is buffered to render the state token, but in server side it does not.

The question is simple: it is really wanted to buffer all requests into memory before sent
it to the server? 

I think it is possible to use StreamCharBuffer to do that and handle memory usage in a efficient
way. There exists a method called ServletResponse.resetBuffer() but it is not useable because
the buffer size should be bigger than the response size otherwise, the buffer is flushed automatically.
Unfortunately there is no ExternalContext.responseResetBuffer() but there is ExternalContext.responseReset().

Maybe this should be considered a flaw of servlet spec. It is possible to set the buffer in
FaceletsViewDeclarationLanguage.renderView and change ExternalContext.responseReset() to reset
that buffer too if it is called. Note that is something outside the spec, but is reasonable
behavior, because if the user set the buffer size (with javax.faces.FACELETS_BUFFER_SIZE)
to a enough big value, it will work anyway. I think the buffer stuff could be handled better
by the servlet container, but in this case we don't have choice.

> Handing exception (in exception handler) from render response phase with forward/redirect
is inconsistent
> ---------------------------------------------------------------------------------------------------------
>                 Key: MYFACES-3191
>                 URL:
>             Project: MyFaces Core
>          Issue Type: Sub-task
>          Components: General
>    Affects Versions: 2.1.2-SNAPSHOT
>         Environment: myfaces trunk
>            Reporter: Martin Kočí
> View.xhtml snippet:
> <h:commandButton value="Submit">
>                 <f:setPropertyActionListener value="#{true}" target="#{bean.rendered}"
>                 <f:ajax render="outputText" />
> </h:commandButton>
> <h:outputText rendered="#{bean.rendered}" id="outputText" value="#{bean.value}" />
> snippet:
> public Object getValue() {
> 		throw new NullPointerException();
> }
> Custom exception handler code:
> 			if (PhaseId.RENDER_RESPONSE.equals(currentPhaseId)) {
> 				try {
> 					nav.handleNavigation(facesContext, null, "/ErrorPage.xhtml?faces-redirect=true");
> 				} finally {
> 					i.remove();
> 				}
> 			}
> Modify view and exception handler to achieve following combinations (HTML request = comment
out f:ajax, forward = remove ?faces-redirect=true)
> 1) HTML request  + forward: nothing in log, and malformed output is produced (no closing
tags for  </body> etc.)
> 2) HTML request + redirect: OK , redirect to ErrorPage.xhtml is done
> 3) AJAX request + forward: exception in log, bud no forward to ErrorPage performed
> 4) AJAX request + redirect: exception in log, malformed XML produced (<?xml and <partial-response
2x in output) , no redirect performed

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:!default.jspa
For more information on JIRA, see:


View raw message