BalusC opened a new pull request, #1033:
URL: https://github.com/apache/myfaces/pull/1033

   `ServletExternalContextImpl.getResponseOutputWriter()` caches a 
`BufferedWriter` since 0e84278c5. `responseReset()` and `responseSendError()` 
drop that field, but a `ResponseWriter` created earlier in the render phase 
keeps writing into the instance it obtained back then. Everything rendered 
after the reset — typically an error page — therefore lands in a buffer nobody 
drains, and the client gets HTTP 200 with an empty body.
   
   This is not limited to third party exception handlers: 
`AjaxExceptionHandlerImpl` (line 205) and `ErrorPageWriter` (line 427) follow 
the same reset-then-reuse-the-cached-writer pattern.
   
   There is a second break from the same commit: `release()` flushes the 
`BufferedWriter`, which flushes the container writer and thereby commits the 
response. A render exception on a non-ajax request can then no longer be reset 
and forwarded to the error page.
   
   ### Fix
   
   `ResettableBufferedWriter` replaces the plain `BufferedWriter`:
   
   - it keeps its identity across `responseReset()` / `responseSendError()`, 
which now discard the buffered chars instead of dropping the writer;
   - it resolves the container writer per drain instead of holding on to it, so 
it survives `HttpServletResponse.reset()`;
   - `flush()` drains into the container writer but does not flush it — 
committing stays the container's decision, or that of an explicit 
`responseFlushBuffer()`.
   
   The buffering and its performance benefit are unchanged: same 8 KB buffer, 
same coalescing of the many small `HtmlResponseWriterImpl` writes.
   
   ### Verified
   
   - New 
`ServletExternalContextImplTest#testResponseResetDiscardsBufferedOutputButKeepsWriterUsable`.
 On current `main` it fails with `expected: <error page> but was: <aborted 
responseerror page>`, which also shows aborted output being re-committed.
   - Full `mvn clean verify` on the reactor is green.
   - Real world reproduction: OmniFaces `FullAjaxExceptionHandlerIT` on Tomcat 
11 + MyFaces 5.0.0-SNAPSHOT goes from 7 errors to 14/14 passing.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code) (Opus 5)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to