This is an automated email from the ASF dual-hosted git repository.

papegaaij pushed a commit to branch wicket-8.x
in repository https://gitbox.apache.org/repos/asf/wicket.git


The following commit(s) were added to refs/heads/wicket-8.x by this push:
     new 8150ad1  WICKET-6848: Do not flush before detach when session needs 
invalidation
8150ad1 is described below

commit 8150ad19cbb3b436f8e8aed32c766269811e6c62
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 cdbffbf..066c2cb 100644
--- a/wicket-core/src/main/java/org/apache/wicket/Session.java
+++ b/wicket-core/src/main/java/org/apache/wicket/Session.java
@@ -551,7 +551,24 @@ public abstract class Session implements IClusterable, 
IEventSink, IFeedbackCont
         */
        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 c53d0cd..5eb4fc6 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
@@ -31,6 +31,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;
@@ -270,11 +271,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();
                        }
                }
@@ -291,6 +294,10 @@ public class WicketFilter implements Filter
                                chain.doFilter(httpServletRequest, 
httpServletResponse);
                        }
                }
+               else if (!respFlushed)
+               {
+                       webResponse.flush();
+               }
                return reqProcessed;
        }
 

Reply via email to