[MAGNOLIA-2989] GZipFilter causes "getWriter() has already been called for this response" error to be thrown on Glassfish v3 Created: 04/Jan/10 Updated: 23/Jan/13 Resolved: 26/Mar/10 |
|
| Status: | Closed |
| Project: | Magnolia |
| Component/s: | admininterface, cache, core |
| Affects Version/s: | 4.2.3 |
| Fix Version/s: | 4.3.2 |
| Type: | Bug | Priority: | Major |
| Reporter: | joshua portway | Assignee: | Magnolia International |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | 0d | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | 0d | ||
| Attachments: |
|
||||||||||||||||
| Issue Links: |
|
||||||||||||||||
| Template: |
|
||||||||||||||||
| Patch included: |
Yes
|
||||||||||||||||
| Acceptance criteria: |
Empty
|
||||||||||||||||
| Task DoD: |
[ ]*
Doc/release notes changes? Comment present?
[ ]*
Downstream builds green?
[ ]*
Solution information and context easily available?
[ ]*
Tests
[ ]*
FixVersion filled and not yet released
[ ] 
Architecture Decision Record (ADR)
|
||||||||||||||||
| Bug DoR: |
[ ]*
Steps to reproduce, expected, and actual results filled
[ ]*
Affected version filled
|
||||||||||||||||
| Date of First Response: | |||||||||||||||||
| Description |
|
Immediately after logging in this error is thrown by the server, and the admin page never renders. This means that magnolia is effectively completely unusable under Glassfish v3. This has been a problem in previous version of glassfish, and with previous versions of Magnolia (going back to at least 3.5, probably earlier, but I can't remember), but in previous version of glassfish the problem only caused a warning to be logged. Glassfish version 3 treats this as a fatal error and aborts rendering the page. here's the stack trace : java.lang.IllegalStateException: PWC3990: getWriter() has already been called for this response
at org.apache.catalina.connector.Response.getOutputStream(Response.java:676)
at org.apache.catalina.connector.ResponseFacade.getOutputStream(ResponseFacade.java:205)
at info.magnolia.module.cache.filter.GZipFilter.doFilter(GZipFilter.java:106)
at info.magnolia.cms.filters.OncePerRequestAbstractMgnlFilter.doFilter(OncePerRequestAbstractMgnlFilter.java:62)
[...]
|
| Comments |
| Comment by joshua portway [ 04/Jan/10 ] |
|
I notice that there are two instances of a method called "OncePerRequestAbstractMgnlFilter.doFilter()" in this stack trace, which sounds like a problem to me...... |
| Comment by joshua portway [ 04/Jan/10 ] |
|
This is a screenshot (sorry about the awkward format - I can't figure out how to copy the stack as text from the debugger) of the first time getWriter is called, which is when calling "response.sendRedirect(redirectUrl);" from VirtualUriFilter |
| Comment by joshua portway [ 04/Jan/10 ] |
|
This is the stack of when the error is actually thrown. getOutputStream is called by GZipFilter.doFilter() |
| Comment by Philipp Bärfuss [ 05/Jan/10 ] |
|
Having multiple instances (subclasses) of OncePerRequestAbstractMgnlFilter is OK. Each of this filter is then just executed once (no matter how often your forward). |
| Comment by joshua portway [ 05/Jan/10 ] |
|
so it looks to me like the problem is that virtualURIFilter is doing a redirect, but for some reason the request is carrying on and eventually GZipFilter gets called to return something. Presumably if sendRedirect() is being called then there probably shouldn't be any more processing done on the request? |
| Comment by joshua portway [ 06/Jan/10 ] |
|
check for zero length response before writing to output stream |
| Comment by joshua portway [ 06/Jan/10 ] |
|
submitted patch which seems to fix the issue. Only bother to write anything to the output stream if there's something to write (length of response >0) |
| Comment by Philipp Bärfuss [ 02/Feb/10 ] |
|
Scheduling for 4.3 to not forget to apply it |
| Comment by Magnolia International [ 26/Mar/10 ] |
|
Patch applied, thanks ! At first I was dubious, since we make sure we write to the same single stream, whether getWriter or getOutputStream is called further down the chain with info.magnolia.module.cache.filter.CacheResponseWrapper (so that renderers and template engines may use whatever they want); however this specific filter called getOutputstream AFTER the use of this response wrapper. (the wrapper is also used when caching content, which does not happen in this case) |
| Comment by Magnolia International [ 26/Mar/10 ] |
|
Also applied patch to the 4.2, 4.1 and 4.0 branches, although 4.1 and 4.0 will probably still suffer from |