I get an error when I try to redirect a page in JSF action with a h:commandLink when I use the Omnifaces GzipResponseFilter (only in Glassfish).
Exception: java.lang.IllegalStateException: Current state = FLUSHED, new state = CODING_END
Environment Glassfish 3 Omnifaces 1.7 (GzipResponseFilter) Mojarra 2.1.27 JDK 6
web.xml
<filter>
<filter-name>gzipResponseFilter</filter-name>
<filter-class>org.omnifaces.filter.GzipResponseFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>gzipResponseFilter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>ERROR</dispatcher>
</filter-mapping>
MyBean.doAction()
Faces.redirect("anotherPage.jsf");
page.xhtml
<h:commandLink action="#{myBean.doAction()}">Click</h:commandLink>
The problem happens only in Glassfish, I tested in Tomcat and it works.
If I remove the GzipResponseFilter declaration, the redirect works normally on both servers.
Do you know if it's a bug on Omnifaces or in my code? Thanks in advance.
Stack trace
java.lang.IllegalStateException: Current state = FLUSHED, new state = CODING_END
at java.nio.charset.CharsetEncoder.throwIllegalStateException(CharsetEncoder.java:951)
at java.nio.charset.CharsetEncoder.encode(CharsetEncoder.java:537)
at sun.nio.cs.StreamEncoder.flushLeftoverChar(StreamEncoder.java:223)
at sun.nio.cs.StreamEncoder.implClose(StreamEncoder.java:282)
at sun.nio.cs.StreamEncoder.close(StreamEncoder.java:130)
at java.io.OutputStreamWriter.close(OutputStreamWriter.java:216)
at org.omnifaces.io.ResettableBufferedWriter.close(ResettableBufferedWriter.java:98)
at java.io.PrintWriter.close(PrintWriter.java:295)
at org.omnifaces.servlet.HttpServletResponseOutputWrapper.close(HttpServletResponseOutputWrapper.java:149)
at org.omnifaces.servlet.GzipHttpServletResponse.close(GzipHttpServletResponse.java:133)
at org.omnifaces.filter.GzipResponseFilter.doFilter(GzipResponseFilter.java:150)
at org.omnifaces.filter.HttpFilter.doFilter(HttpFilter.java:77)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)