This is an automated email from the ASF dual-hosted git repository. papegaaij pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/wicket.git
The following commit(s) were added to refs/heads/master by this push: new 625f9af WICKET-6848: Do not flush before detach when session needs invalidation 625f9af is described below commit 625f9afd88efc98e5c01c89431067385a993d94d Author: Emond Papegaaij <emond.papega...@topicus.nl> AuthorDate: Mon Nov 2 13:25:18 2020 +0100 WICKET-6848: Do not flush before detach when session needs invalidation --- .../src/main/java/org/apache/wicket/Session.java | 19 ++++++++++++++++++- .../org/apache/wicket/protocol/http/WicketFilter.java | 9 ++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/wicket-core/src/main/java/org/apache/wicket/Session.java b/wicket-core/src/main/java/org/apache/wicket/Session.java index 2376267..9d76c97 100644 --- a/wicket-core/src/main/java/org/apache/wicket/Session.java +++ b/wicket-core/src/main/java/org/apache/wicket/Session.java @@ -557,7 +557,24 @@ public abstract class Session implements IClusterable, IEventSink, IMetadataCont */ public final boolean isSessionInvalidated() { - return Boolean.TRUE.equals(RequestCycle.get().getMetaData(SESSION_INVALIDATED)); + RequestCycle requestCycle = RequestCycle.get(); + return isSessionInvalidated(requestCycle); + } + + /** + * Whether the session is invalid now, or will be invalidated by the end of the request. Clients + * should rarely need to use this method if ever. + * + * @param requestCycle + * The current request cycle + * @return Whether the session is invalid when the current request is done + * + * @see #invalidate() + * @see #invalidateNow() + */ + public static boolean isSessionInvalidated(RequestCycle requestCycle) + { + return Boolean.TRUE.equals(requestCycle.getMetaData(SESSION_INVALIDATED)); } /** diff --git a/wicket-core/src/main/java/org/apache/wicket/protocol/http/WicketFilter.java b/wicket-core/src/main/java/org/apache/wicket/protocol/http/WicketFilter.java index 35c456c..c6faaad 100644 --- a/wicket-core/src/main/java/org/apache/wicket/protocol/http/WicketFilter.java +++ b/wicket-core/src/main/java/org/apache/wicket/protocol/http/WicketFilter.java @@ -32,6 +32,7 @@ import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import org.apache.wicket.Session; import org.apache.wicket.ThreadContext; import org.apache.wicket.WicketRuntimeException; import org.apache.wicket.protocol.http.servlet.ResponseIOException; @@ -271,11 +272,13 @@ public class WicketFilter implements Filter final FilterChain chain) throws IOException, ServletException { boolean reqProcessed; + boolean respFlushed = false; try { reqProcessed = requestCycle.processRequest(); - if (reqProcessed) + if (reqProcessed && !Session.isSessionInvalidated(requestCycle)) { + respFlushed = true; webResponse.flush(); } } @@ -292,6 +295,10 @@ public class WicketFilter implements Filter chain.doFilter(httpServletRequest, httpServletResponse); } } + else if (!respFlushed) + { + webResponse.flush(); + } return reqProcessed; }