[ 
https://issues.apache.org/jira/browse/MYFACES-4125?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16125986#comment-16125986
 ] 

Eduardo Breijo commented on MYFACES-4125:
-----------------------------------------

I checked the JIRA issue that introduced the flush call and I noticed that the 
behavior is gated behind context parameter 
"org.apache.myfaces.EARLY_FLUSH_ENABLED". Maybe we can use this same context 
parameter in the HtmlResponseWriterImpl.endDocument() to perform the flush only 
when this parameter is set to true.

public void endDocument() throws IOException
{
    MyfacesConfig myfacesConfig = 
MyfacesConfig.getCurrentInstance(FacesContext.getCurrentInstance().getExternalContext());
    if (myfacesConfig.isEarlyFlushEnabled()) 
    {
        _currentWriter.flush();
    }
        
    _facesContext = null;
}

> Response committed too early due to flush from StateWriter
> ----------------------------------------------------------
>
>                 Key: MYFACES-4125
>                 URL: https://issues.apache.org/jira/browse/MYFACES-4125
>             Project: MyFaces Core
>          Issue Type: Bug
>    Affects Versions: 2.2.12
>            Reporter: Eduardo Breijo
>            Assignee: Leonardo Uribe
>         Attachments: server.log, StateWriter.war
>
>
> We've found a problem where it seems that MyFaces is flushing output too 
> early in the RENDER_RESPONSE PHASE. As a result the response is committed 
> before we have a chance to handle an error in that phase. 
> This is because the renderView method from FaceletViewDeclarationLanguage 
> calls writer.endDocument() which ends up calling the flush() method from 
> StateWriter. This commit behavior is different between 2.0 and 2.2.  It looks 
> like a flush() was empty on 2.0, and now a call was added, which causes the 
> issue we are seeing.
> Here's a sample app:
> 1) Drive a request: localhost:9080/StateWriter/index.xhtml
> 2) You should be able to see in the logs that response was committed, so 
> redirect to error.xhtml cannot be performed.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to