[ 
https://issues.apache.org/jira/browse/GEODE-8221?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17137993#comment-17137993
 ] 

ASF GitHub Bot commented on GEODE-8221:
---------------------------------------

boglesby commented on a change in pull request #5246:
URL: https://github.com/apache/geode/pull/5246#discussion_r441207166



##########
File path: 
extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/AbstractCommitSessionValve.java
##########
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license
+ * agreements. See the NOTICE file distributed with this work for additional 
information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache 
License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the 
License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software 
distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 
KIND, either express
+ * or implied. See the License for the specific language governing permissions 
and limitations under
+ * the License.
+ */
+package org.apache.geode.modules.session.catalina;
+
+import static org.apache.geode.util.internal.UncheckedUtils.uncheckedCast;
+
+import java.io.IOException;
+
+import javax.servlet.ServletException;
+
+import org.apache.catalina.Context;
+import org.apache.catalina.Manager;
+import org.apache.catalina.connector.Request;
+import org.apache.catalina.connector.Response;
+import org.apache.catalina.valves.ValveBase;
+import org.apache.juli.logging.Log;
+import org.apache.juli.logging.LogFactory;
+
+
+public abstract class AbstractCommitSessionValve<SelfT extends 
AbstractCommitSessionValve<?>>
+    extends ValveBase {
+
+  private static final Log log = 
LogFactory.getLog(AbstractCommitSessionValve.class);
+
+  protected static final String info =
+      "org.apache.geode.modules.session.catalina.CommitSessionValve/1.0";
+
+  AbstractCommitSessionValve() {
+    log.info("Initialized");
+  }
+
+  @Override
+  public void invoke(final Request request, final Response response)
+      throws IOException, ServletException {
+    // Invoke the next Valve
+    try {
+      getNext().invoke(request, wrapResponse(response));
+    } finally {
+      commitSession(request);
+    }
+  }
+
+  /**
+   * Commit session only if DeltaSessionManager is in place.
+   *
+   * @param request to commit session from.
+   */
+  protected static <SelfT extends AbstractCommitSessionValve<?>> void 
commitSession(
+      final Request request) {
+    final Context context = request.getContext();
+    final Manager manager = context.getManager();
+    if (manager instanceof DeltaSessionManager) {
+      final DeltaSessionFacade session = (DeltaSessionFacade) 
request.getSession(false);
+      if (session != null) {
+        final DeltaSessionManager<SelfT> deltaSessionManager = 
uncheckedCast(manager);
+        final Log contextLogger = context.getLogger();

Review comment:
       Can you change this to use the AbstractCommitSessionValve's Logger (the 
static log variable) instead of the Context's logger? I'm not sure why its like 
this, but if we use the AbstractCommitSessionValve's Logger, then only 1 line 
in logging.properties is necessary to debug this class rather than 2:
   ```
   org.apache.geode.modules.session.level = FINE
   ```




----------------------------------------------------------------
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.

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


> Session state not committed prior to servlet output flush with commit valve 
> enabled
> -----------------------------------------------------------------------------------
>
>                 Key: GEODE-8221
>                 URL: https://issues.apache.org/jira/browse/GEODE-8221
>             Project: Geode
>          Issue Type: Bug
>          Components: http session
>            Reporter: Jacob Barrett
>            Assignee: Jacob Barrett
>            Priority: Major
>
> The Tomcat session state module does not commit session data to Geode prior 
> to servlet output flushing to browser if commit valve is enabled. The commit 
> valve delays the commit of session state until the of the request scope prior 
> to closing and ending the current request with the browser. This can result 
> in some data being sent to the browser asynchronously with the session state 
> persistence. If the servlet or JSP invokes a flush on output stream, write or 
> response either explicitly through the flush method or implicitly because of 
> full buffers then the browser may receive data that instructs it to make 
> another request. This subsequent request may receive the currently committed 
> session state prior to the completion of the initial request. 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to