You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by sa...@apache.org on 2021/04/13 14:28:10 UTC

[geode] branch support/1.13 updated (b32e20b -> 31d2613)

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

sabbey37 pushed a change to branch support/1.13
in repository https://gitbox.apache.org/repos/asf/geode.git.


    from b32e20b  GEODE-8623: Retry getting local host if it fails. (#5743)
     new ccdb502  Revert "GEODE-8684: Setting a session's maxInactiveInterval does not work when the commit valve is disabled"
     new de2238d  Revert "GEODE-8513: Remove (de)serialization of local sessions."
     new 618eea0  Revert "GEODE-7896 Update tomcat support"
     new 8d87057  Revert "GEODE-8781: Added ReconnectListener to PeerToPeerSessionCache"
     new 45d9f5c  GEODE-8221: Refactor tests to run in appropriate projects. (#5244)
     new d5bc7e8  GEODE-7896 Update tomcat support
     new 8c849ec  GEODE-8221: Commits session data prior to sending output to browser (#5246)
     new 7095050  GEODE-8217: Deserialize attribute before update and remove. (#5256)
     new 29bb5a2  GEODE-8513: Remove (de)serialization of local sessions. (#5532)
     new 814482d  GEODE-8684: Setting a session's maxInactiveInterval does not work when the commit valve is disabled (#5724)
     new 31d2613  GEODE-8781: Added ReconnectListener to PeerToPeerSessionCache

The 11 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 ...SessionsBase.java => AbstractSessionsTest.java} | 143 ++++-----
 ...AbstractCommitSessionValveIntegrationTest.java} |  42 ++-
 .../AbstractDeltaSessionIntegrationTest.java       | 110 +++++++
 ...t.java => AbstractDeltaSessionManagerTest.java} |  77 ++---
 ...UnitTest.java => AbstractDeltaSessionTest.java} | 103 +++---
 .../AbstractSessionValveIntegrationTest.java       |   0
 .../ClientServerSessionCacheJUnitTest.java         | 334 --------------------
 extensions/geode-modules-tomcat7/build.gradle      |   1 +
 ...ionsJUnitTest.java => Tomcat7SessionsTest.java} |  10 +-
 .../CommitSessionValveIntegrationTest.java         |  57 ++++
 .../session/catalina/DeltaSession7Test.java}       |  38 +--
 .../catalina/Tomcat7CommitSessionOutputBuffer.java |  53 ++++
 .../catalina/Tomcat7CommitSessionValve.java        |  58 ++++
 .../catalina/Tomcat7DeltaSessionManager.java       |  12 +-
 .../session/catalina/DeltaSession7Test.java        | 147 +++++++++
 .../Tomcat7CommitSessionOutputBufferTest.java      |  63 ++++
 .../catalina/Tomcat7CommitSessionValveTest.java    |  98 ++++++
 ...st.java => Tomcat7DeltaSessionManagerTest.java} |   7 +-
 .../CommitSessionValveIntegrationTest.java         |  57 ++++
 .../session/catalina/DeltaSession8Test.java}       |  38 +--
 .../modules/session/catalina/DeltaSession8.java    |   1 +
 .../catalina/Tomcat8CommitSessionOutputBuffer.java |  60 ++++
 .../catalina/Tomcat8CommitSessionValve.java        |  59 ++++
 .../catalina/Tomcat8DeltaSessionManager.java       |   8 +-
 .../session/catalina/DeltaSession8Test.java        | 147 +++++++++
 .../Tomcat8CommitSessionOutputBufferTest.java      |  77 +++++
 .../catalina/Tomcat8CommitSessionValveTest.java    |  98 ++++++
 ...st.java => Tomcat8DeltaSessionManagerTest.java} |   3 +-
 .../CommitSessionValveIntegrationTest.java         |  52 ++++
 .../session/catalina/DeltaSession9Test.java}       |  40 +--
 .../catalina/Tomcat9CommitSessionOutputBuffer.java |  53 ++++
 .../catalina/Tomcat9CommitSessionValve.java        |  58 ++++
 .../catalina/Tomcat9DeltaSessionManager.java       |   7 +-
 .../session/catalina/DeltaSession9Test.java        | 147 +++++++++
 .../Tomcat9CommitSessionOutputBufferTest.java      |  60 ++++
 .../catalina/Tomcat9CommitSessionValveTest.java    |  94 ++++++
 ...st.java => Tomcat9DeltaSessionManagerTest.java} |   3 +-
 ...ionsJUnitTest.java => Tomcat6SessionsTest.java} |   4 +-
 .../catalina/AbstractCommitSessionValve.java       |  83 +++++
 .../session/catalina/CommitSessionValve.java       |  69 ----
 .../modules/session/catalina/DeltaSession.java     | 346 ++++++++++++---------
 .../session/catalina/DeltaSessionManager.java      | 130 ++++----
 ....java => DeltaSessionManagerConfiguration.java} |  46 ++-
 .../session/catalina/JvmRouteBinderValve.java      |  10 +-
 .../{SessionManager.java => SessionCommitter.java} |  37 +--
 .../modules/session/catalina/SessionManager.java   |   4 +
 ...Manager.java => Tomcat6CommitSessionValve.java} |  36 +--
 .../catalina/Tomcat6DeltaSessionManager.java       |   7 +-
 .../callback/SessionExpirationCacheListener.java   |   2 +-
 .../catalina/AbstractSessionCacheTest.java}        |  26 +-
 .../catalina/ClientServerSessionCacheTest.java     | 301 +++++++++++++++++-
 .../session/catalina/DeltaSessionFacadeTest.java}  |   6 +-
 .../catalina/PeerToPeerSessionCacheTest.java}      |  26 +-
 .../SessionExpirationCacheListenerTest.java}       |  10 +-
 .../DeltaSessionAttributeEventBatchTest.java}      |  17 +-
 .../DeltaSessionDestroyAttributeEventTest.java}    |   9 +-
 .../internal/DeltaSessionStatisticsTest.java}      |  11 +-
 .../DeltaSessionUpdateAttributeEventTest.java}     |  10 +-
 .../modules/util/CreateRegionFunctionTest.java}    |  17 +-
 ...TouchPartitionedRegionEntriesFunctionTest.java} |  16 +-
 .../TouchReplicatedRegionEntriesFunctionTest.java} |  20 +-
 .../session/AccessAttributeValueListener.java}     |  24 +-
 .../src/main/webapp/WEB-INF/web.xml                |   4 +
 geode-assembly/geode-assembly-test/build.gradle    |   2 +
 .../apache/geode/session/tests/CargoTestBase.java  |  41 ++-
 .../org/apache/geode/session/tests/LogChecker.java | 126 ++++++++
 .../integrationTest/resources/assembly_content.txt |   6 +-
 67 files changed, 2811 insertions(+), 1050 deletions(-)
 rename extensions/geode-modules-test/src/main/java/org/apache/geode/modules/session/{TestSessionsBase.java => AbstractSessionsTest.java} (72%)
 rename extensions/{geode-modules/src/integrationTest/java/org/apache/geode/modules/session/catalina/CommitSessionValveIntegrationTest.java => geode-modules-test/src/main/java/org/apache/geode/modules/session/catalina/AbstractCommitSessionValveIntegrationTest.java} (83%)
 create mode 100644 extensions/geode-modules-test/src/main/java/org/apache/geode/modules/session/catalina/AbstractDeltaSessionIntegrationTest.java
 rename extensions/geode-modules-test/src/main/java/org/apache/geode/modules/session/catalina/{DeltaSessionManagerJUnitTest.java => AbstractDeltaSessionManagerTest.java} (76%)
 rename extensions/geode-modules-test/src/main/java/org/apache/geode/modules/session/catalina/{DeltaSessionJUnitTest.java => AbstractDeltaSessionTest.java} (62%)
 rename extensions/{geode-modules/src/integrationTest => geode-modules-test/src/main}/java/org/apache/geode/modules/session/catalina/AbstractSessionValveIntegrationTest.java (100%)
 delete mode 100644 extensions/geode-modules-test/src/main/java/org/apache/geode/modules/session/catalina/ClientServerSessionCacheJUnitTest.java
 rename extensions/geode-modules-tomcat7/src/integrationTest/java/org/apache/geode/modules/session/{Tomcat7SessionsJUnitTest.java => Tomcat7SessionsTest.java} (87%)
 create mode 100644 extensions/geode-modules-tomcat7/src/integrationTest/java/org/apache/geode/modules/session/catalina/CommitSessionValveIntegrationTest.java
 copy extensions/{geode-modules/src/main/java/org/apache/geode/modules/session/catalina/SessionManager.java => geode-modules-tomcat7/src/integrationTest/java/org/apache/geode/modules/session/catalina/DeltaSession7Test.java} (61%)
 create mode 100644 extensions/geode-modules-tomcat7/src/main/java/org/apache/geode/modules/session/catalina/Tomcat7CommitSessionOutputBuffer.java
 create mode 100644 extensions/geode-modules-tomcat7/src/main/java/org/apache/geode/modules/session/catalina/Tomcat7CommitSessionValve.java
 create mode 100644 extensions/geode-modules-tomcat7/src/test/java/org/apache/geode/modules/session/catalina/DeltaSession7Test.java
 create mode 100644 extensions/geode-modules-tomcat7/src/test/java/org/apache/geode/modules/session/catalina/Tomcat7CommitSessionOutputBufferTest.java
 create mode 100644 extensions/geode-modules-tomcat7/src/test/java/org/apache/geode/modules/session/catalina/Tomcat7CommitSessionValveTest.java
 rename extensions/geode-modules-tomcat7/src/test/java/org/apache/geode/modules/session/catalina/{Tomcat7DeltaSessionManagerJUnitTest.java => Tomcat7DeltaSessionManagerTest.java} (95%)
 create mode 100644 extensions/geode-modules-tomcat8/src/integrationTest/java/org/apache/geode/modules/session/catalina/CommitSessionValveIntegrationTest.java
 copy extensions/{geode-modules/src/main/java/org/apache/geode/modules/session/catalina/SessionManager.java => geode-modules-tomcat8/src/integrationTest/java/org/apache/geode/modules/session/catalina/DeltaSession8Test.java} (61%)
 create mode 100644 extensions/geode-modules-tomcat8/src/main/java/org/apache/geode/modules/session/catalina/Tomcat8CommitSessionOutputBuffer.java
 create mode 100644 extensions/geode-modules-tomcat8/src/main/java/org/apache/geode/modules/session/catalina/Tomcat8CommitSessionValve.java
 create mode 100644 extensions/geode-modules-tomcat8/src/test/java/org/apache/geode/modules/session/catalina/DeltaSession8Test.java
 create mode 100644 extensions/geode-modules-tomcat8/src/test/java/org/apache/geode/modules/session/catalina/Tomcat8CommitSessionOutputBufferTest.java
 create mode 100644 extensions/geode-modules-tomcat8/src/test/java/org/apache/geode/modules/session/catalina/Tomcat8CommitSessionValveTest.java
 rename extensions/geode-modules-tomcat8/src/test/java/org/apache/geode/modules/session/catalina/{Tomcat8DeltaSessionManagerJUnitTest.java => Tomcat8DeltaSessionManagerTest.java} (97%)
 create mode 100644 extensions/geode-modules-tomcat9/src/integrationTest/java/org/apache/geode/modules/session/catalina/CommitSessionValveIntegrationTest.java
 copy extensions/{geode-modules/src/main/java/org/apache/geode/modules/session/catalina/SessionManager.java => geode-modules-tomcat9/src/integrationTest/java/org/apache/geode/modules/session/catalina/DeltaSession9Test.java} (61%)
 create mode 100644 extensions/geode-modules-tomcat9/src/main/java/org/apache/geode/modules/session/catalina/Tomcat9CommitSessionOutputBuffer.java
 create mode 100644 extensions/geode-modules-tomcat9/src/main/java/org/apache/geode/modules/session/catalina/Tomcat9CommitSessionValve.java
 create mode 100644 extensions/geode-modules-tomcat9/src/test/java/org/apache/geode/modules/session/catalina/DeltaSession9Test.java
 create mode 100644 extensions/geode-modules-tomcat9/src/test/java/org/apache/geode/modules/session/catalina/Tomcat9CommitSessionOutputBufferTest.java
 create mode 100644 extensions/geode-modules-tomcat9/src/test/java/org/apache/geode/modules/session/catalina/Tomcat9CommitSessionValveTest.java
 rename extensions/geode-modules-tomcat9/src/test/java/org/apache/geode/modules/session/catalina/{Tomcat9DeltaSessionManagerJUnitTest.java => Tomcat9DeltaSessionManagerTest.java} (97%)
 copy extensions/geode-modules/src/integrationTest/java/org/apache/geode/modules/session/{Tomcat6SessionsJUnitTest.java => Tomcat6SessionsTest.java} (88%)
 create mode 100644 extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/AbstractCommitSessionValve.java
 delete mode 100644 extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/CommitSessionValve.java
 copy extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/{SessionManager.java => DeltaSessionManagerConfiguration.java} (57%)
 copy extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/{SessionManager.java => SessionCommitter.java} (61%)
 copy extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/{SessionManager.java => Tomcat6CommitSessionValve.java} (61%)
 rename extensions/{geode-modules-test/src/main/java/org/apache/geode/modules/session/catalina/AbstractSessionCacheJUnitTest.java => geode-modules/src/test/java/org/apache/geode/modules/session/catalina/AbstractSessionCacheTest.java} (86%)
 rename extensions/{geode-modules-test/src/main/java/org/apache/geode/modules/session/catalina/DeltaSessionFacadeJUnitTest.java => geode-modules/src/test/java/org/apache/geode/modules/session/catalina/DeltaSessionFacadeTest.java} (88%)
 rename extensions/{geode-modules-test/src/main/java/org/apache/geode/modules/session/catalina/PeerToPeerSessionCacheJUnitTest.java => geode-modules/src/test/java/org/apache/geode/modules/session/catalina/PeerToPeerSessionCacheTest.java} (90%)
 rename extensions/{geode-modules-test/src/main/java/org/apache/geode/modules/session/catalina/callback/SessionExpirationCacheListenerJUnitTest.java => geode-modules/src/test/java/org/apache/geode/modules/session/catalina/callback/SessionExpirationCacheListenerTest.java} (80%)
 rename extensions/{geode-modules-test/src/main/java/org/apache/geode/modules/session/catalina/internal/DeltaSessionAttributeEventBatchJUnitTest.java => geode-modules/src/test/java/org/apache/geode/modules/session/catalina/internal/DeltaSessionAttributeEventBatchTest.java} (77%)
 rename extensions/{geode-modules-test/src/main/java/org/apache/geode/modules/session/catalina/internal/DeltaSessionDestroyAttributeEventJUnitTest.java => geode-modules/src/test/java/org/apache/geode/modules/session/catalina/internal/DeltaSessionDestroyAttributeEventTest.java} (79%)
 rename extensions/{geode-modules-test/src/main/java/org/apache/geode/modules/session/catalina/internal/DeltaSessionStatisticsJUnitTest.java => geode-modules/src/test/java/org/apache/geode/modules/session/catalina/internal/DeltaSessionStatisticsTest.java} (85%)
 rename extensions/{geode-modules-test/src/main/java/org/apache/geode/modules/session/catalina/internal/DeltaSessionUpdateAttributeEventJUnitTest.java => geode-modules/src/test/java/org/apache/geode/modules/session/catalina/internal/DeltaSessionUpdateAttributeEventTest.java} (81%)
 rename extensions/{geode-modules-test/src/main/java/org/apache/geode/modules/util/CreateRegionFunctionJUnitTest.java => geode-modules/src/test/java/org/apache/geode/modules/util/CreateRegionFunctionTest.java} (85%)
 rename extensions/{geode-modules-test/src/main/java/org/apache/geode/modules/util/TouchPartitionedRegionEntriesFunctionJUnitTest.java => geode-modules/src/test/java/org/apache/geode/modules/util/TouchPartitionedRegionEntriesFunctionTest.java} (84%)
 rename extensions/{geode-modules-test/src/main/java/org/apache/geode/modules/util/TouchReplicatedRegionEntriesFunctionJUnitTest.java => geode-modules/src/test/java/org/apache/geode/modules/util/TouchReplicatedRegionEntriesFunctionTest.java} (79%)
 rename extensions/{geode-modules/src/integrationTest/java/org/apache/geode/modules/session/Tomcat6SessionsJUnitTest.java => session-testing-war/src/main/java/org/apache/geode/modules/session/AccessAttributeValueListener.java} (55%)
 create mode 100644 geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/LogChecker.java

[geode] 06/11: GEODE-7896 Update tomcat support

Posted by sa...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

sabbey37 pushed a commit to branch support/1.13
in repository https://gitbox.apache.org/repos/asf/geode.git

commit d5bc7e891fc4570ed57fcc8817972d3b13bd1bee
Author: Anthony Baker <ab...@apache.org>
AuthorDate: Wed May 13 12:04:43 2020 -0700

    GEODE-7896 Update tomcat support
    
    Update tomcat integration to work with versions after 9.0.21.
    
    (cherry picked from commit 70fe060bbdba951512403cc0795f29bd2d7d21d6)
---
 .../gradle/plugins/DependencyConstraints.groovy    |  2 +-
 .../modules/session/catalina/DeltaSession.java     | 24 +++++++++++++++++++++-
 .../apache/geode/session/tests/TomcatInstall.java  |  2 +-
 3 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/buildSrc/src/main/groovy/org/apache/geode/gradle/plugins/DependencyConstraints.groovy b/buildSrc/src/main/groovy/org/apache/geode/gradle/plugins/DependencyConstraints.groovy
index 9098324..ec8449e 100644
--- a/buildSrc/src/main/groovy/org/apache/geode/gradle/plugins/DependencyConstraints.groovy
+++ b/buildSrc/src/main/groovy/org/apache/geode/gradle/plugins/DependencyConstraints.groovy
@@ -53,7 +53,7 @@ class DependencyConstraints implements Plugin<Project> {
     deps.put("tomcat6.version", "6.0.37")
     deps.put("tomcat7.version", "7.0.99")
     deps.put("tomcat8.version", "8.5.50")
-    deps.put("tomcat9.version", "9.0.12")
+    deps.put("tomcat9.version", "9.0.33")
 
     // The jetty version is also hard-coded in geode-assembly:test
     // at o.a.g.sessions.tests.GenericAppServerInstall.java
diff --git a/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/DeltaSession.java b/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/DeltaSession.java
index aa8b3f5..4e5e969 100644
--- a/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/DeltaSession.java
+++ b/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/DeltaSession.java
@@ -366,7 +366,29 @@ public class DeltaSession extends StandardSession
 
   @Override
   public void localUpdateAttribute(String name, Object value) {
-    super.setAttribute(name, value, false); // don't do notification since this is a replication
+    if (this.manager == null) {
+      // Name cannot be null
+      if (name == null) {
+        throw new IllegalArgumentException(sm.getString("standardSession.setAttribute.namenull"));
+      }
+
+      // Null value is the same as removeAttribute()
+      if (value == null) {
+        removeAttribute(name);
+        return;
+      }
+
+      // Validate our current state
+      if (!isValidInternal()) {
+        throw new IllegalStateException(
+            sm.getString("standardSession.setAttribute.ise", getIdInternal()));
+      }
+
+      // Replace or add this attribute
+      getAttributes().put(name, value);
+    } else {
+      super.setAttribute(name, value, false); // don't do notification since this is a replication
+    }
   }
 
   @Override
diff --git a/geode-assembly/geode-assembly-test/src/main/java/org/apache/geode/session/tests/TomcatInstall.java b/geode-assembly/geode-assembly-test/src/main/java/org/apache/geode/session/tests/TomcatInstall.java
index 90eeaa5..322558e 100644
--- a/geode-assembly/geode-assembly-test/src/main/java/org/apache/geode/session/tests/TomcatInstall.java
+++ b/geode-assembly/geode-assembly-test/src/main/java/org/apache/geode/session/tests/TomcatInstall.java
@@ -43,7 +43,7 @@ public class TomcatInstall extends ContainerInstall {
     TOMCAT6(6, "tomcat-6.0.37.zip"),
     TOMCAT7(7, "tomcat-7.0.99.zip"),
     TOMCAT8(8, "tomcat-8.5.50.zip"),
-    TOMCAT9(9, "tomcat-9.0.12.zip");
+    TOMCAT9(9, "tomcat-9.0.33.zip");
 
     private final int version;
 

[geode] 03/11: Revert "GEODE-7896 Update tomcat support"

Posted by sa...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

sabbey37 pushed a commit to branch support/1.13
in repository https://gitbox.apache.org/repos/asf/geode.git

commit 618eea0dd393359f65802b5f73a917a2c1eb9f64
Author: Sarah <sa...@pivotal.io>
AuthorDate: Mon Apr 12 09:22:35 2021 -0400

    Revert "GEODE-7896 Update tomcat support"
    
    This reverts commit 937326e1f9717c3d9132d78a58e81db7bd6c929e.
---
 .../gradle/plugins/DependencyConstraints.groovy    |  2 +-
 .../modules/session/catalina/DeltaSession.java     | 24 +---------------------
 .../apache/geode/session/tests/TomcatInstall.java  |  2 +-
 3 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/buildSrc/src/main/groovy/org/apache/geode/gradle/plugins/DependencyConstraints.groovy b/buildSrc/src/main/groovy/org/apache/geode/gradle/plugins/DependencyConstraints.groovy
index ec8449e..9098324 100644
--- a/buildSrc/src/main/groovy/org/apache/geode/gradle/plugins/DependencyConstraints.groovy
+++ b/buildSrc/src/main/groovy/org/apache/geode/gradle/plugins/DependencyConstraints.groovy
@@ -53,7 +53,7 @@ class DependencyConstraints implements Plugin<Project> {
     deps.put("tomcat6.version", "6.0.37")
     deps.put("tomcat7.version", "7.0.99")
     deps.put("tomcat8.version", "8.5.50")
-    deps.put("tomcat9.version", "9.0.33")
+    deps.put("tomcat9.version", "9.0.12")
 
     // The jetty version is also hard-coded in geode-assembly:test
     // at o.a.g.sessions.tests.GenericAppServerInstall.java
diff --git a/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/DeltaSession.java b/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/DeltaSession.java
index 4e5e969..aa8b3f5 100644
--- a/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/DeltaSession.java
+++ b/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/DeltaSession.java
@@ -366,29 +366,7 @@ public class DeltaSession extends StandardSession
 
   @Override
   public void localUpdateAttribute(String name, Object value) {
-    if (this.manager == null) {
-      // Name cannot be null
-      if (name == null) {
-        throw new IllegalArgumentException(sm.getString("standardSession.setAttribute.namenull"));
-      }
-
-      // Null value is the same as removeAttribute()
-      if (value == null) {
-        removeAttribute(name);
-        return;
-      }
-
-      // Validate our current state
-      if (!isValidInternal()) {
-        throw new IllegalStateException(
-            sm.getString("standardSession.setAttribute.ise", getIdInternal()));
-      }
-
-      // Replace or add this attribute
-      getAttributes().put(name, value);
-    } else {
-      super.setAttribute(name, value, false); // don't do notification since this is a replication
-    }
+    super.setAttribute(name, value, false); // don't do notification since this is a replication
   }
 
   @Override
diff --git a/geode-assembly/geode-assembly-test/src/main/java/org/apache/geode/session/tests/TomcatInstall.java b/geode-assembly/geode-assembly-test/src/main/java/org/apache/geode/session/tests/TomcatInstall.java
index 322558e..90eeaa5 100644
--- a/geode-assembly/geode-assembly-test/src/main/java/org/apache/geode/session/tests/TomcatInstall.java
+++ b/geode-assembly/geode-assembly-test/src/main/java/org/apache/geode/session/tests/TomcatInstall.java
@@ -43,7 +43,7 @@ public class TomcatInstall extends ContainerInstall {
     TOMCAT6(6, "tomcat-6.0.37.zip"),
     TOMCAT7(7, "tomcat-7.0.99.zip"),
     TOMCAT8(8, "tomcat-8.5.50.zip"),
-    TOMCAT9(9, "tomcat-9.0.33.zip");
+    TOMCAT9(9, "tomcat-9.0.12.zip");
 
     private final int version;
 

[geode] 10/11: GEODE-8684: Setting a session's maxInactiveInterval does not work when the commit valve is disabled (#5724)

Posted by sa...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

sabbey37 pushed a commit to branch support/1.13
in repository https://gitbox.apache.org/repos/asf/geode.git

commit 814482d186f094b388076194b1e1f1189f4dc9b4
Author: Jens Deppe <jd...@pivotal.io>
AuthorDate: Wed Nov 11 08:40:48 2020 -0800

    GEODE-8684: Setting a session's maxInactiveInterval does not work when the commit valve is disabled (#5724)
    
    Co-Authored-by: Jens Deppe <jd...@vmware.com>
    Co-Authored-by: Sarah Abbey <sa...@vmware.com>
    (cherry picked from commit ba8f9015530af10c3e9d1df1e73524bdc6c8a3cc)
---
 .../modules/session/catalina/DeltaSession.java     |  4 +++
 .../geode/session/tests/TomcatContainer.java       | 15 +++++----
 .../apache/geode/session/tests/TomcatInstall.java  | 36 ++++++++++++++++++++--
 .../apache/geode/session/tests/CargoTestBase.java  |  9 +++---
 .../tests/Tomcat6CachingClientServerTest.java      |  2 +-
 .../session/tests/Tomcat6ClientServerTest.java     |  3 +-
 .../apache/geode/session/tests/Tomcat6Test.java    |  3 +-
 .../tests/Tomcat7CachingClientServerTest.java      |  2 +-
 .../session/tests/Tomcat7ClientServerTest.java     |  3 +-
 .../apache/geode/session/tests/Tomcat7Test.java    |  3 +-
 .../tests/Tomcat8CachingClientServerTest.java      |  2 +-
 .../session/tests/Tomcat8ClientServerTest.java     |  3 +-
 .../apache/geode/session/tests/Tomcat8Test.java    |  3 +-
 .../tests/Tomcat9CachingClientServerTest.java      |  2 +-
 ...mcat9CachingClientServerValveDisabledTest.java} |  4 +--
 .../session/tests/Tomcat9ClientServerTest.java     |  3 +-
 .../apache/geode/session/tests/Tomcat9Test.java    |  3 +-
 .../Tomcat8ClientServerRollingUpgradeTest.java     |  4 +--
 ...omcatSessionBackwardsCompatibilityTestBase.java |  8 ++---
 19 files changed, 76 insertions(+), 36 deletions(-)

diff --git a/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/DeltaSession.java b/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/DeltaSession.java
index 1968550..e745ffe 100644
--- a/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/DeltaSession.java
+++ b/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/DeltaSession.java
@@ -413,6 +413,10 @@ public class DeltaSession extends StandardSession
   @Override
   public void setMaxInactiveInterval(int interval) {
     super.setMaxInactiveInterval(interval);
+
+    if (!isCommitEnabled() && id != null) {
+      putInRegion(getOperatingRegion(), true, null);
+    }
   }
 
   @Override
diff --git a/geode-assembly/geode-assembly-test/src/main/java/org/apache/geode/session/tests/TomcatContainer.java b/geode-assembly/geode-assembly-test/src/main/java/org/apache/geode/session/tests/TomcatContainer.java
index 38d262d..b0d4168 100644
--- a/geode-assembly/geode-assembly-test/src/main/java/org/apache/geode/session/tests/TomcatContainer.java
+++ b/geode-assembly/geode-assembly-test/src/main/java/org/apache/geode/session/tests/TomcatContainer.java
@@ -65,17 +65,16 @@ public class TomcatContainer extends ServerContainer {
     setConfigFile(contextXMLFile.getAbsolutePath(), DEFAULT_TOMCAT_XML_REPLACEMENT_DIR,
         DEFAULT_TOMCAT_CONTEXT_XML_REPLACEMENT_NAME);
 
-    if (install.getConnectionType() == ContainerInstall.ConnectionType.CLIENT_SERVER) {
-      // using proxy region, override the default client/server setting to set to false
+    if (install.getConnectionType() == ContainerInstall.ConnectionType.CLIENT_SERVER ||
+        install.getConnectionType() == ContainerInstall.ConnectionType.CACHING_CLIENT_SERVER) {
       setCacheProperty("enableLocalCache",
           String.valueOf(install.getConnectionType().enableLocalCache()));
-    } else {
-      // using default, either setting it explicitly or leave it off should have the same effect
-      if (System.currentTimeMillis() % 2 == 0) {
-        setCacheProperty("enableLocalCache",
-            String.valueOf(install.getConnectionType().enableLocalCache()));
-      }
     }
+
+    if (install.getCommitValve() != TomcatInstall.CommitValve.DEFAULT) {
+      setCacheProperty("enableCommitValve", install.getCommitValve().getValue());
+    }
+
     setCacheProperty("className", install.getContextSessionManagerClass());
 
     // Deploy war file to container configuration
diff --git a/geode-assembly/geode-assembly-test/src/main/java/org/apache/geode/session/tests/TomcatInstall.java b/geode-assembly/geode-assembly-test/src/main/java/org/apache/geode/session/tests/TomcatInstall.java
index 322558e..af7d955 100644
--- a/geode-assembly/geode-assembly-test/src/main/java/org/apache/geode/session/tests/TomcatInstall.java
+++ b/geode-assembly/geode-assembly-test/src/main/java/org/apache/geode/session/tests/TomcatInstall.java
@@ -89,6 +89,26 @@ public class TomcatInstall extends ContainerInstall {
   }
 
   /**
+   * This determines the setting for 'enableCommitValve' in Tomcat's context.xml when configuring
+   * the DeltaSessionManager.
+   */
+  public enum CommitValve {
+    ENABLED("true"),
+    DISABLED("false"),
+    DEFAULT(null);
+
+    private final String value;
+
+    CommitValve(String value) {
+      this.value = value;
+    }
+
+    public String getValue() {
+      return value;
+    }
+  }
+
+  /**
    * If you update this list method to return different dependencies, please also update the Tomcat
    * module documentation! The documentation can be found here:
    * geode-docs/tools_modules/http_session_mgmt/tomcat_installing_the_module.html.md.erb
@@ -103,11 +123,14 @@ public class TomcatInstall extends ContainerInstall {
 
   private final TomcatVersion version;
 
+  private final CommitValve commitValve;
+
   public TomcatInstall(String name, TomcatVersion version, ConnectionType connectionType,
-      IntSupplier portSupplier)
+      IntSupplier portSupplier,
+      CommitValve commitValve)
       throws Exception {
     this(name, version, connectionType, DEFAULT_MODULE_LOCATION, GEODE_BUILD_HOME_LIB,
-        portSupplier);
+        portSupplier, commitValve);
   }
 
   /**
@@ -120,12 +143,14 @@ public class TomcatInstall extends ContainerInstall {
    * skipping properties needed to speedup container startup.
    */
   public TomcatInstall(String name, TomcatVersion version, ConnectionType connType,
-      String modulesJarLocation, String extraJarsPath, IntSupplier portSupplier)
+      String modulesJarLocation, String extraJarsPath, IntSupplier portSupplier,
+      CommitValve commitValve)
       throws Exception {
     // Does download and install from URL
     super(name, version.getDownloadURL(), connType, "tomcat", modulesJarLocation, portSupplier);
 
     this.version = version;
+    this.commitValve = commitValve;
     modulesJarLocation = getModulePath() + "/lib/";
 
     // Install geode sessions into tomcat install
@@ -241,6 +266,10 @@ public class TomcatInstall extends ContainerInstall {
     return version.name() + "_" + getConnectionType().getName();
   }
 
+  public CommitValve getCommitValve() {
+    return commitValve;
+  }
+
   /**
    * Copies jars specified by {@link #tomcatRequiredJars} from the {@link #getModulePath()} and the
    * specified other directory passed to the function
@@ -315,4 +344,5 @@ public class TomcatInstall extends ContainerInstall {
     editPropertyFile(getHome() + "/conf/catalina.properties", version.jarSkipPropertyName(),
         jarsToSkip, true);
   }
+
 }
diff --git a/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/CargoTestBase.java b/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/CargoTestBase.java
index 8f487de..9d57f22 100644
--- a/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/CargoTestBase.java
+++ b/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/CargoTestBase.java
@@ -24,6 +24,7 @@ import java.net.URISyntaxException;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
+import java.util.concurrent.TimeUnit;
 import java.util.function.IntSupplier;
 
 import org.apache.logging.log4j.Logger;
@@ -34,7 +35,6 @@ import org.junit.Test;
 import org.junit.experimental.categories.Category;
 import org.junit.rules.TestName;
 
-import org.apache.geode.internal.AvailablePortHelper;
 import org.apache.geode.internal.UniquePortSupplier;
 import org.apache.geode.logging.internal.log4j.api.LogService;
 import org.apache.geode.modules.session.functions.GetMaxInactiveInterval;
@@ -82,8 +82,7 @@ public abstract class CargoTestBase {
   public void setup() throws Exception {
     dumpDockerInfo();
     announceTest("START");
-    int locatorPortSuggestion = AvailablePortHelper.getRandomAvailableTCPPort();
-    locatorVM = clusterStartupRule.startLocatorVM(0, locatorPortSuggestion);
+    locatorVM = clusterStartupRule.startLocatorVM(0);
 
     client = new Client();
     manager = new ContainerManager();
@@ -257,7 +256,7 @@ public abstract class CargoTestBase {
     client.setMaxInactive(1); // max inactive time is 1 second. Lets wait a second.
     Thread.sleep(2000);
 
-    await().untilAsserted(() -> {
+    await().atMost(10, TimeUnit.SECONDS).untilAsserted(() -> {
       verifySessionIsRemoved(key);
       Thread.sleep(1000);
     });
@@ -293,7 +292,7 @@ public abstract class CargoTestBase {
     for (int i = 0; i < manager.numContainers(); i++) {
       client.setPort(Integer.parseInt(manager.getContainerPort(i)));
       if (install.getConnectionType() == ContainerInstall.ConnectionType.CACHING_CLIENT_SERVER) {
-        await().until(() -> Integer.toString(expected)
+        await().atMost(30, TimeUnit.SECONDS).until(() -> Integer.toString(expected)
             .equals(client.executionFunction(GetMaxInactiveInterval.class).getResponse()));
       } else {
         assertEquals(Integer.toString(expected),
diff --git a/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat6CachingClientServerTest.java b/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat6CachingClientServerTest.java
index 3bd14ee..1c6f9d0 100644
--- a/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat6CachingClientServerTest.java
+++ b/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat6CachingClientServerTest.java
@@ -23,6 +23,6 @@ public class Tomcat6CachingClientServerTest extends TomcatClientServerTest {
   @Override
   public ContainerInstall getInstall(IntSupplier portSupplier) throws Exception {
     return new TomcatInstall(getClass().getSimpleName(), TOMCAT6, CACHING_CLIENT_SERVER,
-        portSupplier);
+        portSupplier, TomcatInstall.CommitValve.DEFAULT);
   }
 }
diff --git a/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat6ClientServerTest.java b/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat6ClientServerTest.java
index 1924034..75d853d 100644
--- a/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat6ClientServerTest.java
+++ b/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat6ClientServerTest.java
@@ -22,6 +22,7 @@ import java.util.function.IntSupplier;
 public class Tomcat6ClientServerTest extends TomcatClientServerTest {
   @Override
   public ContainerInstall getInstall(IntSupplier portSupplier) throws Exception {
-    return new TomcatInstall(getClass().getSimpleName(), TOMCAT6, CLIENT_SERVER, portSupplier);
+    return new TomcatInstall(getClass().getSimpleName(), TOMCAT6, CLIENT_SERVER, portSupplier,
+        TomcatInstall.CommitValve.DEFAULT);
   }
 }
diff --git a/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat6Test.java b/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat6Test.java
index 60dface..50487d0 100644
--- a/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat6Test.java
+++ b/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat6Test.java
@@ -22,6 +22,7 @@ import java.util.function.IntSupplier;
 public class Tomcat6Test extends CargoTestBase {
   @Override
   public ContainerInstall getInstall(IntSupplier portSupplier) throws Exception {
-    return new TomcatInstall(getClass().getSimpleName(), TOMCAT6, PEER_TO_PEER, portSupplier);
+    return new TomcatInstall(getClass().getSimpleName(), TOMCAT6, PEER_TO_PEER, portSupplier,
+        TomcatInstall.CommitValve.DEFAULT);
   }
 }
diff --git a/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat7CachingClientServerTest.java b/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat7CachingClientServerTest.java
index c2db978..4401bfe 100644
--- a/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat7CachingClientServerTest.java
+++ b/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat7CachingClientServerTest.java
@@ -23,6 +23,6 @@ public class Tomcat7CachingClientServerTest extends TomcatClientServerTest {
   @Override
   public ContainerInstall getInstall(IntSupplier portSupplier) throws Exception {
     return new TomcatInstall(getClass().getSimpleName(), TOMCAT7, CACHING_CLIENT_SERVER,
-        portSupplier);
+        portSupplier, TomcatInstall.CommitValve.DEFAULT);
   }
 }
diff --git a/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat7ClientServerTest.java b/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat7ClientServerTest.java
index 5c39fd2..f2cacf5 100644
--- a/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat7ClientServerTest.java
+++ b/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat7ClientServerTest.java
@@ -23,6 +23,7 @@ import java.util.function.IntSupplier;
 public class Tomcat7ClientServerTest extends TomcatClientServerTest {
   @Override
   public ContainerInstall getInstall(IntSupplier portSupplier) throws Exception {
-    return new TomcatInstall(getClass().getSimpleName(), TOMCAT7, CLIENT_SERVER, portSupplier);
+    return new TomcatInstall(getClass().getSimpleName(), TOMCAT7, CLIENT_SERVER, portSupplier,
+        TomcatInstall.CommitValve.DEFAULT);
   }
 }
diff --git a/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat7Test.java b/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat7Test.java
index 1922fdb..5e93e1f 100644
--- a/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat7Test.java
+++ b/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat7Test.java
@@ -22,6 +22,7 @@ import java.util.function.IntSupplier;
 public class Tomcat7Test extends CargoTestBase {
   @Override
   public ContainerInstall getInstall(IntSupplier portSupplier) throws Exception {
-    return new TomcatInstall(getClass().getSimpleName(), TOMCAT7, PEER_TO_PEER, portSupplier);
+    return new TomcatInstall(getClass().getSimpleName(), TOMCAT7, PEER_TO_PEER, portSupplier,
+        TomcatInstall.CommitValve.DEFAULT);
   }
 }
diff --git a/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat8CachingClientServerTest.java b/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat8CachingClientServerTest.java
index 03b65df..ca3e921 100644
--- a/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat8CachingClientServerTest.java
+++ b/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat8CachingClientServerTest.java
@@ -23,6 +23,6 @@ public class Tomcat8CachingClientServerTest extends TomcatClientServerTest {
   @Override
   public ContainerInstall getInstall(IntSupplier portSupplier) throws Exception {
     return new TomcatInstall(getClass().getSimpleName(), TOMCAT8, CACHING_CLIENT_SERVER,
-        portSupplier);
+        portSupplier, TomcatInstall.CommitValve.DEFAULT);
   }
 }
diff --git a/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat8ClientServerTest.java b/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat8ClientServerTest.java
index a4e960d..f52eacc 100644
--- a/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat8ClientServerTest.java
+++ b/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat8ClientServerTest.java
@@ -22,6 +22,7 @@ import java.util.function.IntSupplier;
 public class Tomcat8ClientServerTest extends TomcatClientServerTest {
   @Override
   public ContainerInstall getInstall(IntSupplier portSupplier) throws Exception {
-    return new TomcatInstall(getClass().getSimpleName(), TOMCAT8, CLIENT_SERVER, portSupplier);
+    return new TomcatInstall(getClass().getSimpleName(), TOMCAT8, CLIENT_SERVER, portSupplier,
+        TomcatInstall.CommitValve.DEFAULT);
   }
 }
diff --git a/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat8Test.java b/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat8Test.java
index 93a7441..dba0402 100644
--- a/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat8Test.java
+++ b/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat8Test.java
@@ -22,6 +22,7 @@ import java.util.function.IntSupplier;
 public class Tomcat8Test extends CargoTestBase {
   @Override
   public ContainerInstall getInstall(IntSupplier portSupplier) throws Exception {
-    return new TomcatInstall(getClass().getSimpleName(), TOMCAT8, PEER_TO_PEER, portSupplier);
+    return new TomcatInstall(getClass().getSimpleName(), TOMCAT8, PEER_TO_PEER, portSupplier,
+        TomcatInstall.CommitValve.DEFAULT);
   }
 }
diff --git a/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat9CachingClientServerTest.java b/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat9CachingClientServerTest.java
index 8e8b4c4..a02376c 100644
--- a/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat9CachingClientServerTest.java
+++ b/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat9CachingClientServerTest.java
@@ -23,6 +23,6 @@ public class Tomcat9CachingClientServerTest extends TomcatClientServerTest {
   @Override
   public ContainerInstall getInstall(IntSupplier portSupplier) throws Exception {
     return new TomcatInstall(getClass().getSimpleName(), TOMCAT9, CACHING_CLIENT_SERVER,
-        portSupplier);
+        portSupplier, TomcatInstall.CommitValve.DEFAULT);
   }
 }
diff --git a/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat9CachingClientServerTest.java b/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat9CachingClientServerValveDisabledTest.java
similarity index 89%
copy from geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat9CachingClientServerTest.java
copy to geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat9CachingClientServerValveDisabledTest.java
index 8e8b4c4..3738d9c 100644
--- a/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat9CachingClientServerTest.java
+++ b/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat9CachingClientServerValveDisabledTest.java
@@ -19,10 +19,10 @@ import static org.apache.geode.session.tests.TomcatInstall.TomcatVersion.TOMCAT9
 
 import java.util.function.IntSupplier;
 
-public class Tomcat9CachingClientServerTest extends TomcatClientServerTest {
+public class Tomcat9CachingClientServerValveDisabledTest extends TomcatClientServerTest {
   @Override
   public ContainerInstall getInstall(IntSupplier portSupplier) throws Exception {
     return new TomcatInstall(getClass().getSimpleName(), TOMCAT9, CACHING_CLIENT_SERVER,
-        portSupplier);
+        portSupplier, TomcatInstall.CommitValve.DISABLED);
   }
 }
diff --git a/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat9ClientServerTest.java b/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat9ClientServerTest.java
index a617e19..f922d2b 100644
--- a/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat9ClientServerTest.java
+++ b/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat9ClientServerTest.java
@@ -23,6 +23,7 @@ public class Tomcat9ClientServerTest extends TomcatClientServerTest {
 
   @Override
   public ContainerInstall getInstall(IntSupplier portSupplier) throws Exception {
-    return new TomcatInstall(getClass().getSimpleName(), TOMCAT9, CLIENT_SERVER, portSupplier);
+    return new TomcatInstall(getClass().getSimpleName(), TOMCAT9, CLIENT_SERVER, portSupplier,
+        TomcatInstall.CommitValve.DEFAULT);
   }
 }
diff --git a/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat9Test.java b/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat9Test.java
index b7777d1..cb65d56 100644
--- a/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat9Test.java
+++ b/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat9Test.java
@@ -22,6 +22,7 @@ import java.util.function.IntSupplier;
 public class Tomcat9Test extends CargoTestBase {
   @Override
   public ContainerInstall getInstall(IntSupplier portSupplier) throws Exception {
-    return new TomcatInstall(getClass().getSimpleName(), TOMCAT9, PEER_TO_PEER, portSupplier);
+    return new TomcatInstall(getClass().getSimpleName(), TOMCAT9, PEER_TO_PEER, portSupplier,
+        TomcatInstall.CommitValve.DEFAULT);
   }
 }
diff --git a/geode-assembly/src/upgradeTest/java/org/apache/geode/session/tests/Tomcat8ClientServerRollingUpgradeTest.java b/geode-assembly/src/upgradeTest/java/org/apache/geode/session/tests/Tomcat8ClientServerRollingUpgradeTest.java
index ec6c39c..be78750 100644
--- a/geode-assembly/src/upgradeTest/java/org/apache/geode/session/tests/Tomcat8ClientServerRollingUpgradeTest.java
+++ b/geode-assembly/src/upgradeTest/java/org/apache/geode/session/tests/Tomcat8ClientServerRollingUpgradeTest.java
@@ -136,12 +136,12 @@ public class Tomcat8ClientServerRollingUpgradeTest {
             ContainerInstall.ConnectionType.CLIENT_SERVER,
             oldModules.getAbsolutePath(),
             oldBuild.getAbsolutePath() + "/lib",
-            portSupplier::getAvailablePort);
+            portSupplier::getAvailablePort, TomcatInstall.CommitValve.DEFAULT);
 
     tomcat8AndCurrentModules =
         new TomcatInstall("Tomcat8AndCurrentModules", TomcatInstall.TomcatVersion.TOMCAT8,
             ContainerInstall.ConnectionType.CLIENT_SERVER,
-            portSupplier::getAvailablePort);
+            portSupplier::getAvailablePort, TomcatInstall.CommitValve.DEFAULT);
 
     classPathTomcat8AndOldModules = getClassPathTomcat8AndOldModules();
 
diff --git a/geode-assembly/src/upgradeTest/java/org/apache/geode/session/tests/TomcatSessionBackwardsCompatibilityTestBase.java b/geode-assembly/src/upgradeTest/java/org/apache/geode/session/tests/TomcatSessionBackwardsCompatibilityTestBase.java
index 7c71b83..15dc1c8 100644
--- a/geode-assembly/src/upgradeTest/java/org/apache/geode/session/tests/TomcatSessionBackwardsCompatibilityTestBase.java
+++ b/geode-assembly/src/upgradeTest/java/org/apache/geode/session/tests/TomcatSessionBackwardsCompatibilityTestBase.java
@@ -120,24 +120,24 @@ public abstract class TomcatSessionBackwardsCompatibilityTestBase {
         new TomcatInstall("Tomcat7079AndOldModules", TomcatInstall.TomcatVersion.TOMCAT7,
             ContainerInstall.ConnectionType.CLIENT_SERVER,
             oldModules.getAbsolutePath(), oldBuild.getAbsolutePath() + "/lib",
-            portSupplier::getAvailablePort);
+            portSupplier::getAvailablePort, TomcatInstall.CommitValve.DEFAULT);
 
     tomcat7079AndCurrentModules =
         new TomcatInstall("Tomcat7079AndCurrentModules", TomcatInstall.TomcatVersion.TOMCAT7,
             ContainerInstall.ConnectionType.CLIENT_SERVER,
-            portSupplier::getAvailablePort);
+            portSupplier::getAvailablePort, TomcatInstall.CommitValve.DEFAULT);
 
     tomcat8AndOldModules =
         new TomcatInstall("Tomcat8AndOldModules", TomcatInstall.TomcatVersion.TOMCAT8,
             ContainerInstall.ConnectionType.CLIENT_SERVER,
             oldModules.getAbsolutePath(),
             oldBuild.getAbsolutePath() + "/lib",
-            portSupplier::getAvailablePort);
+            portSupplier::getAvailablePort, TomcatInstall.CommitValve.DEFAULT);
 
     tomcat8AndCurrentModules =
         new TomcatInstall("Tomcat8AndCurrentModules", TomcatInstall.TomcatVersion.TOMCAT8,
             ContainerInstall.ConnectionType.CLIENT_SERVER,
-            portSupplier::getAvailablePort);
+            portSupplier::getAvailablePort, TomcatInstall.CommitValve.DEFAULT);
 
     classPathTomcat7079 = tomcat7079AndCurrentModules.getHome() + "/lib/*" + File.pathSeparator
         + tomcat7079AndCurrentModules.getHome() + "/bin/*";

[geode] 07/11: GEODE-8221: Commits session data prior to sending output to browser (#5246)

Posted by sa...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

sabbey37 pushed a commit to branch support/1.13
in repository https://gitbox.apache.org/repos/asf/geode.git

commit 8c849ec535540d1643369f59b5653aed5ba809cb
Author: Jacob Barrett <jb...@pivotal.io>
AuthorDate: Fri Jun 19 10:38:46 2020 -0700

    GEODE-8221: Commits session data prior to sending output to browser (#5246)
    
    * Refactors abstraction of CommitSessionValve.
    * Wraps Coyote OutputBuffer to commit sessions when data is sent to client.
    
    (cherry picked from commit 9939cc0f2f1caad051bd104a0a06a4e1737d3830)
---
 ...AbstractCommitSessionValveIntegrationTest.java} | 42 +++++-----
 .../AbstractSessionValveIntegrationTest.java       |  0
 extensions/geode-modules-tomcat7/build.gradle      |  1 +
 .../CommitSessionValveIntegrationTest.java         | 57 +++++++++++++
 .../catalina/Tomcat7CommitSessionOutputBuffer.java | 53 ++++++++++++
 .../catalina/Tomcat7CommitSessionValve.java        | 58 +++++++++++++
 .../catalina/Tomcat7DeltaSessionManager.java       | 12 ++-
 .../Tomcat7CommitSessionOutputBufferTest.java      | 63 ++++++++++++++
 .../catalina/Tomcat7CommitSessionValveTest.java    | 98 ++++++++++++++++++++++
 .../CommitSessionValveIntegrationTest.java         | 57 +++++++++++++
 .../modules/session/catalina/DeltaSession8.java    |  1 +
 .../catalina/Tomcat8CommitSessionOutputBuffer.java | 60 +++++++++++++
 .../catalina/Tomcat8CommitSessionValve.java        | 59 +++++++++++++
 .../catalina/Tomcat8DeltaSessionManager.java       |  8 +-
 .../Tomcat8CommitSessionOutputBufferTest.java      | 77 +++++++++++++++++
 .../catalina/Tomcat8CommitSessionValveTest.java    | 98 ++++++++++++++++++++++
 .../CommitSessionValveIntegrationTest.java         | 52 ++++++++++++
 .../catalina/Tomcat9CommitSessionOutputBuffer.java | 53 ++++++++++++
 .../catalina/Tomcat9CommitSessionValve.java        | 58 +++++++++++++
 .../catalina/Tomcat9DeltaSessionManager.java       |  7 +-
 .../Tomcat9CommitSessionOutputBufferTest.java      | 60 +++++++++++++
 .../catalina/Tomcat9CommitSessionValveTest.java    | 94 +++++++++++++++++++++
 .../catalina/AbstractCommitSessionValve.java       | 83 ++++++++++++++++++
 .../session/catalina/CommitSessionValve.java       | 69 ---------------
 .../session/catalina/DeltaSessionManager.java      |  9 +-
 .../session/catalina/SessionCommitter.java}        | 26 ++----
 .../catalina/Tomcat6CommitSessionValve.java}       | 26 ++----
 .../catalina/Tomcat6DeltaSessionManager.java       |  7 +-
 geode-assembly/geode-assembly-test/build.gradle    |  2 +
 .../integrationTest/resources/assembly_content.txt |  6 +-
 30 files changed, 1157 insertions(+), 139 deletions(-)

diff --git a/extensions/geode-modules/src/integrationTest/java/org/apache/geode/modules/session/catalina/CommitSessionValveIntegrationTest.java b/extensions/geode-modules-test/src/main/java/org/apache/geode/modules/session/catalina/AbstractCommitSessionValveIntegrationTest.java
similarity index 83%
rename from extensions/geode-modules/src/integrationTest/java/org/apache/geode/modules/session/catalina/CommitSessionValveIntegrationTest.java
rename to extensions/geode-modules-test/src/main/java/org/apache/geode/modules/session/catalina/AbstractCommitSessionValveIntegrationTest.java
index c7e056e..7849d99 100644
--- a/extensions/geode-modules/src/integrationTest/java/org/apache/geode/modules/session/catalina/CommitSessionValveIntegrationTest.java
+++ b/extensions/geode-modules-test/src/main/java/org/apache/geode/modules/session/catalina/AbstractCommitSessionValveIntegrationTest.java
@@ -19,7 +19,6 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
 import static org.mockito.ArgumentMatchers.anyString;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
@@ -35,35 +34,34 @@ import org.apache.catalina.Manager;
 import org.apache.catalina.connector.Request;
 import org.apache.catalina.connector.Response;
 import org.apache.juli.logging.Log;
-import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
 import org.apache.geode.cache.RegionShortcut;
 
 @RunWith(JUnitParamsRunner.class)
-public class CommitSessionValveIntegrationTest extends AbstractSessionValveIntegrationTest {
-  private Request request;
-  private Response response;
-  private TestValve testValve;
-  private CommitSessionValve commitSessionValve;
-  private DeltaSessionFacade deltaSessionFacade;
-
-  @Before
-  public void setUp() {
-    request = spy(Request.class);
-    response = spy(Response.class);
+public abstract class AbstractCommitSessionValveIntegrationTest<CommitSessionValveT extends AbstractCommitSessionValve<CommitSessionValveT>>
+    extends AbstractSessionValveIntegrationTest {
+  protected Request request;
+  protected Response response;
+  protected final TestValve testValve;
+  protected final CommitSessionValveT commitSessionValve;
+  protected DeltaSessionFacade deltaSessionFacade;
+
+  public AbstractCommitSessionValveIntegrationTest() {
     testValve = new TestValve(false);
 
-    commitSessionValve = new CommitSessionValve();
+    commitSessionValve = createCommitSessionValve();
     commitSessionValve.setNext(testValve);
   }
 
-  protected void parameterizedSetUp(RegionShortcut regionShortcut) {
+  protected abstract CommitSessionValveT createCommitSessionValve();
+
+  @Override
+  protected void parameterizedSetUp(final RegionShortcut regionShortcut) {
     super.parameterizedSetUp(regionShortcut);
 
     deltaSessionFacade = new DeltaSessionFacade(deltaSession);
-    when(request.getContext()).thenReturn(mock(Context.class));
 
     // Valve use the context to log messages
     when(deltaSessionManager.getTheContext()).thenReturn(mock(Context.class));
@@ -73,7 +71,7 @@ public class CommitSessionValveIntegrationTest extends AbstractSessionValveInteg
   @Test
   @Parameters({"REPLICATE", "PARTITION"})
   public void invokeShouldCallNextChainedValveAndDoNothingWhenSessionManagerDoesNotBelongToGeode(
-      RegionShortcut regionShortcut) throws IOException, ServletException {
+      final RegionShortcut regionShortcut) throws IOException, ServletException {
     parameterizedSetUp(regionShortcut);
     when(request.getContext().getManager()).thenReturn(mock(Manager.class));
 
@@ -85,7 +83,7 @@ public class CommitSessionValveIntegrationTest extends AbstractSessionValveInteg
   @Test
   @Parameters({"REPLICATE", "PARTITION"})
   public void invokeShouldCallNextChainedValveAndDoNothingWhenSessionManagerBelongsToGeodeButSessionDoesNotExist(
-      RegionShortcut regionShortcut) throws IOException, ServletException {
+      final RegionShortcut regionShortcut) throws IOException, ServletException {
     parameterizedSetUp(regionShortcut);
     doReturn(null).when(request).getSession(false);
     when(request.getContext().getManager()).thenReturn(deltaSessionManager);
@@ -99,7 +97,7 @@ public class CommitSessionValveIntegrationTest extends AbstractSessionValveInteg
   @Test
   @Parameters({"REPLICATE", "PARTITION"})
   public void invokeShouldCallNextChainedValveAndDoNothingWhenSessionManagerBelongsToGeodeAndSessionExistsButIsNotValid(
-      RegionShortcut regionShortcut) throws IOException, ServletException {
+      final RegionShortcut regionShortcut) throws IOException, ServletException {
     parameterizedSetUp(regionShortcut);
     doReturn(false).when(deltaSession).isValid();
     doReturn(deltaSessionFacade).when(request).getSession(false);
@@ -114,7 +112,7 @@ public class CommitSessionValveIntegrationTest extends AbstractSessionValveInteg
   @Test
   @Parameters({"REPLICATE", "PARTITION"})
   public void invokeShouldCallNextChainedValveAndCommitTheExistingValidSessionWhenSessionManagerBelongsToGeode(
-      RegionShortcut regionShortcut) throws IOException, ServletException {
+      final RegionShortcut regionShortcut) throws IOException, ServletException {
     parameterizedSetUp(regionShortcut);
     deltaSessionManager.addSessionToTouch(TEST_SESSION_ID);
     doReturn(deltaSessionFacade).when(request).getSession(false);
@@ -129,9 +127,9 @@ public class CommitSessionValveIntegrationTest extends AbstractSessionValveInteg
   @Test
   @Parameters({"REPLICATE", "PARTITION"})
   public void invokeShouldCommitTheExistingValidSessionWhenSessionManagerBelongsToGeodeEvenWhenTheNextChainedValveThrowsAnException(
-      RegionShortcut regionShortcut) {
+      final RegionShortcut regionShortcut) {
     parameterizedSetUp(regionShortcut);
-    TestValve exceptionValve = new TestValve(true);
+    final TestValve exceptionValve = new TestValve(true);
     commitSessionValve.setNext(exceptionValve);
     deltaSessionManager.addSessionToTouch(TEST_SESSION_ID);
     doReturn(deltaSessionFacade).when(request).getSession(false);
diff --git a/extensions/geode-modules/src/integrationTest/java/org/apache/geode/modules/session/catalina/AbstractSessionValveIntegrationTest.java b/extensions/geode-modules-test/src/main/java/org/apache/geode/modules/session/catalina/AbstractSessionValveIntegrationTest.java
similarity index 100%
rename from extensions/geode-modules/src/integrationTest/java/org/apache/geode/modules/session/catalina/AbstractSessionValveIntegrationTest.java
rename to extensions/geode-modules-test/src/main/java/org/apache/geode/modules/session/catalina/AbstractSessionValveIntegrationTest.java
diff --git a/extensions/geode-modules-tomcat7/build.gradle b/extensions/geode-modules-tomcat7/build.gradle
index cb3f3a6..5f82f5b 100644
--- a/extensions/geode-modules-tomcat7/build.gradle
+++ b/extensions/geode-modules-tomcat7/build.gradle
@@ -18,6 +18,7 @@
 import org.apache.geode.gradle.plugins.DependencyConstraints
 
 apply from: "${rootDir}/${scriptDir}/standard-subproject-configuration.gradle"
+apply from: "${rootDir}/${scriptDir}/warnings.gradle"
 
 evaluationDependsOn(":geode-core")
 
diff --git a/extensions/geode-modules-tomcat7/src/integrationTest/java/org/apache/geode/modules/session/catalina/CommitSessionValveIntegrationTest.java b/extensions/geode-modules-tomcat7/src/integrationTest/java/org/apache/geode/modules/session/catalina/CommitSessionValveIntegrationTest.java
new file mode 100644
index 0000000..b64e862
--- /dev/null
+++ b/extensions/geode-modules-tomcat7/src/integrationTest/java/org/apache/geode/modules/session/catalina/CommitSessionValveIntegrationTest.java
@@ -0,0 +1,57 @@
+/*
+ * 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.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+
+import org.apache.catalina.Context;
+import org.apache.catalina.connector.Connector;
+import org.apache.catalina.connector.Request;
+import org.apache.catalina.connector.Response;
+import org.apache.coyote.OutputBuffer;
+import org.apache.juli.logging.Log;
+import org.junit.Before;
+
+public class CommitSessionValveIntegrationTest
+    extends AbstractCommitSessionValveIntegrationTest<Tomcat7CommitSessionValve> {
+
+  @Before
+  public void setUp() {
+    final Context context = mock(Context.class);
+    doReturn(mock(Log.class)).when(context).getLogger();
+
+    request = mock(Request.class);
+    doReturn(context).when(request).getContext();
+
+    final OutputBuffer outputBuffer = mock(OutputBuffer.class);
+
+    final org.apache.coyote.Response coyoteResponse = new org.apache.coyote.Response();
+    coyoteResponse.setOutputBuffer(outputBuffer);
+
+    response = new Response();
+    response.setConnector(mock(Connector.class));
+    response.setRequest(request);
+    response.setCoyoteResponse(coyoteResponse);
+  }
+
+
+  @Override
+  protected Tomcat7CommitSessionValve createCommitSessionValve() {
+    return new Tomcat7CommitSessionValve();
+  }
+
+}
diff --git a/extensions/geode-modules-tomcat7/src/main/java/org/apache/geode/modules/session/catalina/Tomcat7CommitSessionOutputBuffer.java b/extensions/geode-modules-tomcat7/src/main/java/org/apache/geode/modules/session/catalina/Tomcat7CommitSessionOutputBuffer.java
new file mode 100644
index 0000000..fcf01b2
--- /dev/null
+++ b/extensions/geode-modules-tomcat7/src/main/java/org/apache/geode/modules/session/catalina/Tomcat7CommitSessionOutputBuffer.java
@@ -0,0 +1,53 @@
+/*
+ * 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 java.io.IOException;
+
+import org.apache.coyote.OutputBuffer;
+import org.apache.coyote.Response;
+import org.apache.tomcat.util.buf.ByteChunk;
+
+/**
+ * Delegating {@link OutputBuffer} that commits sessions on write through. Output data is buffered
+ * ahead of this object and flushed through this interface when full or explicitly flushed.
+ */
+class Tomcat7CommitSessionOutputBuffer implements OutputBuffer {
+
+  private final SessionCommitter sessionCommitter;
+  private final OutputBuffer delegate;
+
+  public Tomcat7CommitSessionOutputBuffer(final SessionCommitter sessionCommitter,
+      final OutputBuffer delegate) {
+    this.sessionCommitter = sessionCommitter;
+    this.delegate = delegate;
+  }
+
+  @Override
+  public int doWrite(final ByteChunk chunk, final Response response) throws IOException {
+    sessionCommitter.commit();
+    return delegate.doWrite(chunk, response);
+  }
+
+  @Override
+  public long getBytesWritten() {
+    return delegate.getBytesWritten();
+  }
+
+  OutputBuffer getDelegate() {
+    return delegate;
+  }
+}
diff --git a/extensions/geode-modules-tomcat7/src/main/java/org/apache/geode/modules/session/catalina/Tomcat7CommitSessionValve.java b/extensions/geode-modules-tomcat7/src/main/java/org/apache/geode/modules/session/catalina/Tomcat7CommitSessionValve.java
new file mode 100644
index 0000000..f6a4839
--- /dev/null
+++ b/extensions/geode-modules-tomcat7/src/main/java/org/apache/geode/modules/session/catalina/Tomcat7CommitSessionValve.java
@@ -0,0 +1,58 @@
+/*
+ * 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 java.lang.reflect.Field;
+
+import org.apache.catalina.connector.Request;
+import org.apache.catalina.connector.Response;
+import org.apache.coyote.OutputBuffer;
+
+public class Tomcat7CommitSessionValve
+    extends AbstractCommitSessionValve<Tomcat7CommitSessionValve> {
+
+  private static final Field outputBufferField;
+
+  static {
+    try {
+      outputBufferField = org.apache.coyote.Response.class.getDeclaredField("outputBuffer");
+      outputBufferField.setAccessible(true);
+    } catch (final NoSuchFieldException e) {
+      throw new IllegalStateException(e);
+    }
+  }
+
+  @Override
+  Response wrapResponse(final Response response) {
+    final org.apache.coyote.Response coyoteResponse = response.getCoyoteResponse();
+    final OutputBuffer delegateOutputBuffer = getOutputBuffer(coyoteResponse);
+    if (!(delegateOutputBuffer instanceof Tomcat7CommitSessionOutputBuffer)) {
+      final Request request = response.getRequest();
+      final OutputBuffer sessionCommitOutputBuffer =
+          new Tomcat7CommitSessionOutputBuffer(() -> commitSession(request), delegateOutputBuffer);
+      coyoteResponse.setOutputBuffer(sessionCommitOutputBuffer);
+    }
+    return response;
+  }
+
+  static OutputBuffer getOutputBuffer(final org.apache.coyote.Response coyoteResponse) {
+    try {
+      return (OutputBuffer) outputBufferField.get(coyoteResponse);
+    } catch (final IllegalAccessException e) {
+      throw new IllegalStateException(e);
+    }
+  }
+}
diff --git a/extensions/geode-modules-tomcat7/src/main/java/org/apache/geode/modules/session/catalina/Tomcat7DeltaSessionManager.java b/extensions/geode-modules-tomcat7/src/main/java/org/apache/geode/modules/session/catalina/Tomcat7DeltaSessionManager.java
index e965cc5..b6d304a 100644
--- a/extensions/geode-modules-tomcat7/src/main/java/org/apache/geode/modules/session/catalina/Tomcat7DeltaSessionManager.java
+++ b/extensions/geode-modules-tomcat7/src/main/java/org/apache/geode/modules/session/catalina/Tomcat7DeltaSessionManager.java
@@ -20,14 +20,15 @@ import org.apache.catalina.LifecycleException;
 import org.apache.catalina.LifecycleListener;
 import org.apache.catalina.LifecycleState;
 import org.apache.catalina.session.StandardSession;
-import org.apache.catalina.util.LifecycleSupport;
 
-public class Tomcat7DeltaSessionManager extends DeltaSessionManager {
+public class Tomcat7DeltaSessionManager extends DeltaSessionManager<Tomcat7CommitSessionValve> {
 
   /**
    * The <code>LifecycleSupport</code> for this component.
    */
-  protected LifecycleSupport lifecycle = new LifecycleSupport(this);
+  @SuppressWarnings("deprecation")
+  protected org.apache.catalina.util.LifecycleSupport lifecycle =
+      new org.apache.catalina.util.LifecycleSupport(this);
 
   /**
    * Prepare for the beginning of active use of the public methods of this component. This method
@@ -165,4 +166,9 @@ public class Tomcat7DeltaSessionManager extends DeltaSessionManager {
     return new DeltaSession7(this);
   }
 
+  @Override
+  protected Tomcat7CommitSessionValve createCommitSessionValve() {
+    return new Tomcat7CommitSessionValve();
+  }
+
 }
diff --git a/extensions/geode-modules-tomcat7/src/test/java/org/apache/geode/modules/session/catalina/Tomcat7CommitSessionOutputBufferTest.java b/extensions/geode-modules-tomcat7/src/test/java/org/apache/geode/modules/session/catalina/Tomcat7CommitSessionOutputBufferTest.java
new file mode 100644
index 0000000..20facaf
--- /dev/null
+++ b/extensions/geode-modules-tomcat7/src/test/java/org/apache/geode/modules/session/catalina/Tomcat7CommitSessionOutputBufferTest.java
@@ -0,0 +1,63 @@
+/*
+ * 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.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.inOrder;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.io.IOException;
+
+import org.apache.coyote.OutputBuffer;
+import org.apache.coyote.Response;
+import org.apache.tomcat.util.buf.ByteChunk;
+import org.junit.Test;
+import org.mockito.InOrder;
+
+public class Tomcat7CommitSessionOutputBufferTest {
+
+  final SessionCommitter sessionCommitter = mock(SessionCommitter.class);
+  final OutputBuffer delegate = mock(OutputBuffer.class);
+
+  final Tomcat7CommitSessionOutputBuffer commitSesssionOutputBuffer =
+      new Tomcat7CommitSessionOutputBuffer(sessionCommitter, delegate);
+
+  @Test
+  public void doWrite() throws IOException {
+    final ByteChunk byteChunk = new ByteChunk();
+    final Response response = new Response();
+
+    commitSesssionOutputBuffer.doWrite(byteChunk, response);
+
+    final InOrder inOrder = inOrder(sessionCommitter, delegate);
+    inOrder.verify(sessionCommitter).commit();
+    inOrder.verify(delegate).doWrite(byteChunk, response);
+    inOrder.verifyNoMoreInteractions();
+  }
+
+
+  @Test
+  public void getBytesWritten() {
+    when(delegate.getBytesWritten()).thenReturn(42L);
+
+    assertThat(commitSesssionOutputBuffer.getBytesWritten()).isEqualTo(42L);
+
+    final InOrder inOrder = inOrder(sessionCommitter, delegate);
+    inOrder.verify(delegate).getBytesWritten();
+    inOrder.verifyNoMoreInteractions();
+  }
+}
diff --git a/extensions/geode-modules-tomcat7/src/test/java/org/apache/geode/modules/session/catalina/Tomcat7CommitSessionValveTest.java b/extensions/geode-modules-tomcat7/src/test/java/org/apache/geode/modules/session/catalina/Tomcat7CommitSessionValveTest.java
new file mode 100644
index 0000000..c9be9b2
--- /dev/null
+++ b/extensions/geode-modules-tomcat7/src/test/java/org/apache/geode/modules/session/catalina/Tomcat7CommitSessionValveTest.java
@@ -0,0 +1,98 @@
+/*
+ * 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.modules.session.catalina.Tomcat7CommitSessionValve.getOutputBuffer;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.inOrder;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.reset;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+import org.apache.catalina.Context;
+import org.apache.catalina.connector.Connector;
+import org.apache.catalina.connector.Request;
+import org.apache.catalina.connector.Response;
+import org.apache.coyote.OutputBuffer;
+import org.apache.tomcat.util.buf.ByteChunk;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.ArgumentCaptor;
+import org.mockito.InOrder;
+
+
+public class Tomcat7CommitSessionValveTest {
+
+  private final Tomcat7CommitSessionValve valve = new Tomcat7CommitSessionValve();
+  private final OutputBuffer outputBuffer = mock(OutputBuffer.class);
+  private Response response;
+  private org.apache.coyote.Response coyoteResponse;
+
+  @Before
+  public void before() {
+    final Connector connector = mock(Connector.class);
+
+    final Context context = mock(Context.class);
+
+    final Request request = mock(Request.class);
+    doReturn(context).when(request).getContext();
+
+    coyoteResponse = new org.apache.coyote.Response();
+    coyoteResponse.setOutputBuffer(outputBuffer);
+
+    response = new Response();
+    response.setConnector(connector);
+    response.setRequest(request);
+    response.setCoyoteResponse(coyoteResponse);
+  }
+
+  @Test
+  public void wrappedOutputBufferForwardsToDelegate() throws IOException {
+    wrappedOutputBufferForwardsToDelegate(new byte[] {'a', 'b', 'c'});
+  }
+
+  @Test
+  public void recycledResponseObjectDoesNotWrapAlreadyWrappedOutputBuffer() throws IOException {
+    wrappedOutputBufferForwardsToDelegate(new byte[] {'a', 'b', 'c'});
+    response.recycle();
+    reset(outputBuffer);
+    wrappedOutputBufferForwardsToDelegate(new byte[] {'d', 'e', 'f'});
+  }
+
+  private void wrappedOutputBufferForwardsToDelegate(final byte[] bytes) throws IOException {
+    final OutputStream outputStream =
+        valve.wrapResponse(response).getResponse().getOutputStream();
+    outputStream.write(bytes);
+    outputStream.flush();
+
+    final ArgumentCaptor<ByteChunk> byteChunk = ArgumentCaptor.forClass(ByteChunk.class);
+
+    final InOrder inOrder = inOrder(outputBuffer);
+    inOrder.verify(outputBuffer).doWrite(byteChunk.capture(), any());
+    inOrder.verifyNoMoreInteractions();
+
+    final OutputBuffer wrappedOutputBuffer = getOutputBuffer(coyoteResponse);
+    assertThat(wrappedOutputBuffer).isInstanceOf(Tomcat7CommitSessionOutputBuffer.class);
+    assertThat(((Tomcat7CommitSessionOutputBuffer) wrappedOutputBuffer).getDelegate())
+        .isNotInstanceOf(Tomcat7CommitSessionOutputBuffer.class);
+
+    assertThat(byteChunk.getValue().getBytes()).contains(bytes);
+  }
+}
diff --git a/extensions/geode-modules-tomcat8/src/integrationTest/java/org/apache/geode/modules/session/catalina/CommitSessionValveIntegrationTest.java b/extensions/geode-modules-tomcat8/src/integrationTest/java/org/apache/geode/modules/session/catalina/CommitSessionValveIntegrationTest.java
new file mode 100644
index 0000000..79df936
--- /dev/null
+++ b/extensions/geode-modules-tomcat8/src/integrationTest/java/org/apache/geode/modules/session/catalina/CommitSessionValveIntegrationTest.java
@@ -0,0 +1,57 @@
+/*
+ * 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.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+
+import org.apache.catalina.Context;
+import org.apache.catalina.connector.Connector;
+import org.apache.catalina.connector.Request;
+import org.apache.catalina.connector.Response;
+import org.apache.coyote.OutputBuffer;
+import org.apache.juli.logging.Log;
+import org.junit.Before;
+
+public class CommitSessionValveIntegrationTest
+    extends AbstractCommitSessionValveIntegrationTest<Tomcat8CommitSessionValve> {
+
+  @Before
+  public void setUp() {
+    final Context context = mock(Context.class);
+    doReturn(mock(Log.class)).when(context).getLogger();
+
+    request = mock(Request.class);
+    doReturn(context).when(request).getContext();
+
+    final OutputBuffer outputBuffer = mock(OutputBuffer.class);
+
+    final org.apache.coyote.Response coyoteResponse = new org.apache.coyote.Response();
+    coyoteResponse.setOutputBuffer(outputBuffer);
+
+    response = new Response();
+    response.setConnector(mock(Connector.class));
+    response.setRequest(request);
+    response.setCoyoteResponse(coyoteResponse);
+  }
+
+
+  @Override
+  protected Tomcat8CommitSessionValve createCommitSessionValve() {
+    return new Tomcat8CommitSessionValve();
+  }
+
+}
diff --git a/extensions/geode-modules-tomcat8/src/main/java/org/apache/geode/modules/session/catalina/DeltaSession8.java b/extensions/geode-modules-tomcat8/src/main/java/org/apache/geode/modules/session/catalina/DeltaSession8.java
index a17fdde..c2ea5c5 100644
--- a/extensions/geode-modules-tomcat8/src/main/java/org/apache/geode/modules/session/catalina/DeltaSession8.java
+++ b/extensions/geode-modules-tomcat8/src/main/java/org/apache/geode/modules/session/catalina/DeltaSession8.java
@@ -12,6 +12,7 @@
  * or implied. See the License for the specific language governing permissions and limitations under
  * the License.
  */
+
 package org.apache.geode.modules.session.catalina;
 
 import org.apache.catalina.Manager;
diff --git a/extensions/geode-modules-tomcat8/src/main/java/org/apache/geode/modules/session/catalina/Tomcat8CommitSessionOutputBuffer.java b/extensions/geode-modules-tomcat8/src/main/java/org/apache/geode/modules/session/catalina/Tomcat8CommitSessionOutputBuffer.java
new file mode 100644
index 0000000..4197b59
--- /dev/null
+++ b/extensions/geode-modules-tomcat8/src/main/java/org/apache/geode/modules/session/catalina/Tomcat8CommitSessionOutputBuffer.java
@@ -0,0 +1,60 @@
+/*
+ * 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 java.io.IOException;
+import java.nio.ByteBuffer;
+
+import org.apache.coyote.OutputBuffer;
+import org.apache.tomcat.util.buf.ByteChunk;
+
+/**
+ * Delegating {@link OutputBuffer} that commits sessions on write through. Output data is buffered
+ * ahead of this object and flushed through this interface when full or explicitly flushed.
+ */
+class Tomcat8CommitSessionOutputBuffer implements OutputBuffer {
+
+  private final SessionCommitter sessionCommitter;
+  private final OutputBuffer delegate;
+
+  public Tomcat8CommitSessionOutputBuffer(final SessionCommitter sessionCommitter,
+      final OutputBuffer delegate) {
+    this.sessionCommitter = sessionCommitter;
+    this.delegate = delegate;
+  }
+
+  @Deprecated
+  @Override
+  public int doWrite(final ByteChunk chunk) throws IOException {
+    sessionCommitter.commit();
+    return delegate.doWrite(chunk);
+  }
+
+  @Override
+  public int doWrite(final ByteBuffer chunk) throws IOException {
+    sessionCommitter.commit();
+    return delegate.doWrite(chunk);
+  }
+
+  @Override
+  public long getBytesWritten() {
+    return delegate.getBytesWritten();
+  }
+
+  OutputBuffer getDelegate() {
+    return delegate;
+  }
+}
diff --git a/extensions/geode-modules-tomcat8/src/main/java/org/apache/geode/modules/session/catalina/Tomcat8CommitSessionValve.java b/extensions/geode-modules-tomcat8/src/main/java/org/apache/geode/modules/session/catalina/Tomcat8CommitSessionValve.java
new file mode 100644
index 0000000..fe5f65a
--- /dev/null
+++ b/extensions/geode-modules-tomcat8/src/main/java/org/apache/geode/modules/session/catalina/Tomcat8CommitSessionValve.java
@@ -0,0 +1,59 @@
+/*
+ * 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 java.lang.reflect.Field;
+
+import org.apache.catalina.connector.Request;
+import org.apache.catalina.connector.Response;
+import org.apache.coyote.OutputBuffer;
+
+public class Tomcat8CommitSessionValve
+    extends AbstractCommitSessionValve<Tomcat8CommitSessionValve> {
+
+  private static final Field outputBufferField;
+
+  static {
+    try {
+      outputBufferField = org.apache.coyote.Response.class.getDeclaredField("outputBuffer");
+      outputBufferField.setAccessible(true);
+    } catch (final NoSuchFieldException e) {
+      throw new IllegalStateException(e);
+    }
+  }
+
+  @Override
+  Response wrapResponse(final Response response) {
+    final org.apache.coyote.Response coyoteResponse = response.getCoyoteResponse();
+    final OutputBuffer delegateOutputBuffer = getOutputBuffer(coyoteResponse);
+    if (!(delegateOutputBuffer instanceof Tomcat8CommitSessionOutputBuffer)) {
+      final Request request = response.getRequest();
+      final OutputBuffer sessionCommitOutputBuffer =
+          new Tomcat8CommitSessionOutputBuffer(() -> commitSession(request), delegateOutputBuffer);
+      coyoteResponse.setOutputBuffer(sessionCommitOutputBuffer);
+    }
+    return response;
+  }
+
+  static OutputBuffer getOutputBuffer(final org.apache.coyote.Response coyoteResponse) {
+    try {
+      return (OutputBuffer) outputBufferField.get(coyoteResponse);
+    } catch (final IllegalAccessException e) {
+      throw new IllegalStateException(e);
+    }
+  }
+
+}
diff --git a/extensions/geode-modules-tomcat8/src/main/java/org/apache/geode/modules/session/catalina/Tomcat8DeltaSessionManager.java b/extensions/geode-modules-tomcat8/src/main/java/org/apache/geode/modules/session/catalina/Tomcat8DeltaSessionManager.java
index 8a32ac0..573bf43 100644
--- a/extensions/geode-modules-tomcat8/src/main/java/org/apache/geode/modules/session/catalina/Tomcat8DeltaSessionManager.java
+++ b/extensions/geode-modules-tomcat8/src/main/java/org/apache/geode/modules/session/catalina/Tomcat8DeltaSessionManager.java
@@ -12,6 +12,7 @@
  * or implied. See the License for the specific language governing permissions and limitations under
  * the License.
  */
+
 package org.apache.geode.modules.session.catalina;
 
 import java.io.IOException;
@@ -22,7 +23,7 @@ import org.apache.catalina.LifecycleState;
 import org.apache.catalina.Pipeline;
 import org.apache.catalina.session.StandardSession;
 
-public class Tomcat8DeltaSessionManager extends DeltaSessionManager {
+public class Tomcat8DeltaSessionManager extends DeltaSessionManager<Tomcat8CommitSessionValve> {
 
   /**
    * Prepare for the beginning of active use of the public methods of this component. This method
@@ -138,6 +139,11 @@ public class Tomcat8DeltaSessionManager extends DeltaSessionManager {
   }
 
   @Override
+  protected Tomcat8CommitSessionValve createCommitSessionValve() {
+    return new Tomcat8CommitSessionValve();
+  }
+
+  @Override
   public Context getTheContext() {
     return getContext();
   }
diff --git a/extensions/geode-modules-tomcat8/src/test/java/org/apache/geode/modules/session/catalina/Tomcat8CommitSessionOutputBufferTest.java b/extensions/geode-modules-tomcat8/src/test/java/org/apache/geode/modules/session/catalina/Tomcat8CommitSessionOutputBufferTest.java
new file mode 100644
index 0000000..4efc77b
--- /dev/null
+++ b/extensions/geode-modules-tomcat8/src/test/java/org/apache/geode/modules/session/catalina/Tomcat8CommitSessionOutputBufferTest.java
@@ -0,0 +1,77 @@
+/*
+ * 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.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.inOrder;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+import org.apache.coyote.OutputBuffer;
+import org.apache.tomcat.util.buf.ByteChunk;
+import org.junit.Test;
+import org.mockito.InOrder;
+
+public class Tomcat8CommitSessionOutputBufferTest {
+
+  final SessionCommitter sessionCommitter = mock(SessionCommitter.class);
+  final OutputBuffer delegate = mock(OutputBuffer.class);
+
+  final Tomcat8CommitSessionOutputBuffer commitSesssionOutputBuffer =
+      new Tomcat8CommitSessionOutputBuffer(sessionCommitter, delegate);
+
+  /**
+   * @deprecated Remove when {@link OutputBuffer} drops this method.
+   */
+  @Deprecated
+  @Test
+  public void doWrite() throws IOException {
+    final ByteChunk byteChunk = new ByteChunk();
+
+    commitSesssionOutputBuffer.doWrite(byteChunk);
+
+    final InOrder inOrder = inOrder(sessionCommitter, delegate);
+    inOrder.verify(sessionCommitter).commit();
+    inOrder.verify(delegate).doWrite(byteChunk);
+    inOrder.verifyNoMoreInteractions();
+  }
+
+  @Test
+  public void testDoWrite() throws IOException {
+    final ByteBuffer byteBuffer = ByteBuffer.allocate(0);
+
+    commitSesssionOutputBuffer.doWrite(byteBuffer);
+
+    final InOrder inOrder = inOrder(sessionCommitter, delegate);
+    inOrder.verify(sessionCommitter).commit();
+    inOrder.verify(delegate).doWrite(byteBuffer);
+    inOrder.verifyNoMoreInteractions();
+  }
+
+  @Test
+  public void getBytesWritten() {
+    when(delegate.getBytesWritten()).thenReturn(42L);
+
+    assertThat(commitSesssionOutputBuffer.getBytesWritten()).isEqualTo(42L);
+
+    final InOrder inOrder = inOrder(sessionCommitter, delegate);
+    inOrder.verify(delegate).getBytesWritten();
+    inOrder.verifyNoMoreInteractions();
+  }
+}
diff --git a/extensions/geode-modules-tomcat8/src/test/java/org/apache/geode/modules/session/catalina/Tomcat8CommitSessionValveTest.java b/extensions/geode-modules-tomcat8/src/test/java/org/apache/geode/modules/session/catalina/Tomcat8CommitSessionValveTest.java
new file mode 100644
index 0000000..5cc2f0a
--- /dev/null
+++ b/extensions/geode-modules-tomcat8/src/test/java/org/apache/geode/modules/session/catalina/Tomcat8CommitSessionValveTest.java
@@ -0,0 +1,98 @@
+/*
+ * 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.modules.session.catalina.Tomcat8CommitSessionValve.getOutputBuffer;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.inOrder;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.reset;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.nio.ByteBuffer;
+
+import org.apache.catalina.Context;
+import org.apache.catalina.connector.Connector;
+import org.apache.catalina.connector.Request;
+import org.apache.catalina.connector.Response;
+import org.apache.coyote.OutputBuffer;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.ArgumentCaptor;
+import org.mockito.InOrder;
+
+
+public class Tomcat8CommitSessionValveTest {
+
+  private final Tomcat8CommitSessionValve valve = new Tomcat8CommitSessionValve();
+  private final OutputBuffer outputBuffer = mock(OutputBuffer.class);
+  private Response response;
+  private org.apache.coyote.Response coyoteResponse;
+
+  @Before
+  public void before() {
+    final Connector connector = mock(Connector.class);
+
+    final Context context = mock(Context.class);
+
+    final Request request = mock(Request.class);
+    doReturn(context).when(request).getContext();
+
+    coyoteResponse = new org.apache.coyote.Response();
+    coyoteResponse.setOutputBuffer(outputBuffer);
+
+    response = new Response();
+    response.setConnector(connector);
+    response.setRequest(request);
+    response.setCoyoteResponse(coyoteResponse);
+  }
+
+  @Test
+  public void wrappedOutputBufferForwardsToDelegate() throws IOException {
+    wrappedOutputBufferForwardsToDelegate(new byte[] {'a', 'b', 'c'});
+  }
+
+  @Test
+  public void recycledResponseObjectDoesNotWrapAlreadyWrappedOutputBuffer() throws IOException {
+    wrappedOutputBufferForwardsToDelegate(new byte[] {'a', 'b', 'c'});
+    response.recycle();
+    reset(outputBuffer);
+    wrappedOutputBufferForwardsToDelegate(new byte[] {'d', 'e', 'f'});
+  }
+
+  private void wrappedOutputBufferForwardsToDelegate(final byte[] bytes) throws IOException {
+    final OutputStream outputStream =
+        valve.wrapResponse(response).getResponse().getOutputStream();
+    outputStream.write(bytes);
+    outputStream.flush();
+
+    final ArgumentCaptor<ByteBuffer> byteBuffer = ArgumentCaptor.forClass(ByteBuffer.class);
+
+    final InOrder inOrder = inOrder(outputBuffer);
+    inOrder.verify(outputBuffer).doWrite(byteBuffer.capture());
+    inOrder.verifyNoMoreInteractions();
+
+    final OutputBuffer wrappedOutputBuffer = getOutputBuffer(coyoteResponse);
+    assertThat(wrappedOutputBuffer).isInstanceOf(Tomcat8CommitSessionOutputBuffer.class);
+    assertThat(((Tomcat8CommitSessionOutputBuffer) wrappedOutputBuffer).getDelegate())
+        .isNotInstanceOf(Tomcat8CommitSessionOutputBuffer.class);
+
+    assertThat(byteBuffer.getValue().array()).contains(bytes);
+  }
+
+}
diff --git a/extensions/geode-modules-tomcat9/src/integrationTest/java/org/apache/geode/modules/session/catalina/CommitSessionValveIntegrationTest.java b/extensions/geode-modules-tomcat9/src/integrationTest/java/org/apache/geode/modules/session/catalina/CommitSessionValveIntegrationTest.java
new file mode 100644
index 0000000..c43729a
--- /dev/null
+++ b/extensions/geode-modules-tomcat9/src/integrationTest/java/org/apache/geode/modules/session/catalina/CommitSessionValveIntegrationTest.java
@@ -0,0 +1,52 @@
+/*
+ * 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.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+
+import org.apache.catalina.Context;
+import org.apache.catalina.connector.Request;
+import org.apache.catalina.connector.Response;
+import org.apache.coyote.OutputBuffer;
+import org.apache.juli.logging.Log;
+import org.junit.Before;
+
+public class CommitSessionValveIntegrationTest
+    extends AbstractCommitSessionValveIntegrationTest<Tomcat9CommitSessionValve> {
+
+  @Before
+  public void setUp() {
+    final Context context = mock(Context.class);
+    doReturn(mock(Log.class)).when(context).getLogger();
+
+    request = mock(Request.class);
+    doReturn(context).when(request).getContext();
+
+    final OutputBuffer outputBuffer = mock(OutputBuffer.class);
+
+    final org.apache.coyote.Response coyoteResponse = new org.apache.coyote.Response();
+    coyoteResponse.setOutputBuffer(outputBuffer);
+
+    response = new Response();
+    response.setRequest(request);
+    response.setCoyoteResponse(coyoteResponse);
+  }
+
+  @Override
+  protected Tomcat9CommitSessionValve createCommitSessionValve() {
+    return new Tomcat9CommitSessionValve();
+  }
+}
diff --git a/extensions/geode-modules-tomcat9/src/main/java/org/apache/geode/modules/session/catalina/Tomcat9CommitSessionOutputBuffer.java b/extensions/geode-modules-tomcat9/src/main/java/org/apache/geode/modules/session/catalina/Tomcat9CommitSessionOutputBuffer.java
new file mode 100644
index 0000000..4e4600b
--- /dev/null
+++ b/extensions/geode-modules-tomcat9/src/main/java/org/apache/geode/modules/session/catalina/Tomcat9CommitSessionOutputBuffer.java
@@ -0,0 +1,53 @@
+/*
+ * 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 java.io.IOException;
+import java.nio.ByteBuffer;
+
+import org.apache.coyote.OutputBuffer;
+
+
+/**
+ * Delegating {@link OutputBuffer} that commits sessions on write through. Output data is buffered
+ * ahead of this object and flushed through this interface when full or explicitly flushed.
+ */
+class Tomcat9CommitSessionOutputBuffer implements OutputBuffer {
+
+  private final SessionCommitter sessionCommitter;
+  private final OutputBuffer delegate;
+
+  public Tomcat9CommitSessionOutputBuffer(final SessionCommitter sessionCommitter,
+      final OutputBuffer delegate) {
+    this.sessionCommitter = sessionCommitter;
+    this.delegate = delegate;
+  }
+
+  @Override
+  public int doWrite(final ByteBuffer chunk) throws IOException {
+    sessionCommitter.commit();
+    return delegate.doWrite(chunk);
+  }
+
+  @Override
+  public long getBytesWritten() {
+    return delegate.getBytesWritten();
+  }
+
+  OutputBuffer getDelegate() {
+    return delegate;
+  }
+}
diff --git a/extensions/geode-modules-tomcat9/src/main/java/org/apache/geode/modules/session/catalina/Tomcat9CommitSessionValve.java b/extensions/geode-modules-tomcat9/src/main/java/org/apache/geode/modules/session/catalina/Tomcat9CommitSessionValve.java
new file mode 100644
index 0000000..925b0d2
--- /dev/null
+++ b/extensions/geode-modules-tomcat9/src/main/java/org/apache/geode/modules/session/catalina/Tomcat9CommitSessionValve.java
@@ -0,0 +1,58 @@
+/*
+ * 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 java.lang.reflect.Field;
+
+import org.apache.catalina.connector.Request;
+import org.apache.catalina.connector.Response;
+import org.apache.coyote.OutputBuffer;
+
+public class Tomcat9CommitSessionValve
+    extends AbstractCommitSessionValve<Tomcat9CommitSessionValve> {
+
+  private static final Field outputBufferField;
+
+  static {
+    try {
+      outputBufferField = org.apache.coyote.Response.class.getDeclaredField("outputBuffer");
+      outputBufferField.setAccessible(true);
+    } catch (final NoSuchFieldException e) {
+      throw new IllegalStateException(e);
+    }
+  }
+
+  @Override
+  Response wrapResponse(final Response response) {
+    final org.apache.coyote.Response coyoteResponse = response.getCoyoteResponse();
+    final OutputBuffer delegateOutputBuffer = getOutputBuffer(coyoteResponse);
+    if (!(delegateOutputBuffer instanceof Tomcat9CommitSessionOutputBuffer)) {
+      final Request request = response.getRequest();
+      final OutputBuffer sessionCommitOutputBuffer =
+          new Tomcat9CommitSessionOutputBuffer(() -> commitSession(request), delegateOutputBuffer);
+      coyoteResponse.setOutputBuffer(sessionCommitOutputBuffer);
+    }
+    return response;
+  }
+
+  static OutputBuffer getOutputBuffer(final org.apache.coyote.Response coyoteResponse) {
+    try {
+      return (OutputBuffer) outputBufferField.get(coyoteResponse);
+    } catch (final IllegalAccessException e) {
+      throw new IllegalStateException(e);
+    }
+  }
+}
diff --git a/extensions/geode-modules-tomcat9/src/main/java/org/apache/geode/modules/session/catalina/Tomcat9DeltaSessionManager.java b/extensions/geode-modules-tomcat9/src/main/java/org/apache/geode/modules/session/catalina/Tomcat9DeltaSessionManager.java
index ac9ac2c..5c7e47d 100644
--- a/extensions/geode-modules-tomcat9/src/main/java/org/apache/geode/modules/session/catalina/Tomcat9DeltaSessionManager.java
+++ b/extensions/geode-modules-tomcat9/src/main/java/org/apache/geode/modules/session/catalina/Tomcat9DeltaSessionManager.java
@@ -22,7 +22,7 @@ import org.apache.catalina.LifecycleState;
 import org.apache.catalina.Pipeline;
 import org.apache.catalina.session.StandardSession;
 
-public class Tomcat9DeltaSessionManager extends DeltaSessionManager {
+public class Tomcat9DeltaSessionManager extends DeltaSessionManager<Tomcat9CommitSessionValve> {
 
   /**
    * Prepare for the beginning of active use of the public methods of this component. This method
@@ -138,6 +138,11 @@ public class Tomcat9DeltaSessionManager extends DeltaSessionManager {
   }
 
   @Override
+  protected Tomcat9CommitSessionValve createCommitSessionValve() {
+    return new Tomcat9CommitSessionValve();
+  }
+
+  @Override
   public Context getTheContext() {
     return getContext();
   }
diff --git a/extensions/geode-modules-tomcat9/src/test/java/org/apache/geode/modules/session/catalina/Tomcat9CommitSessionOutputBufferTest.java b/extensions/geode-modules-tomcat9/src/test/java/org/apache/geode/modules/session/catalina/Tomcat9CommitSessionOutputBufferTest.java
new file mode 100644
index 0000000..0ec3a00
--- /dev/null
+++ b/extensions/geode-modules-tomcat9/src/test/java/org/apache/geode/modules/session/catalina/Tomcat9CommitSessionOutputBufferTest.java
@@ -0,0 +1,60 @@
+/*
+ * 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.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.inOrder;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+import org.apache.coyote.OutputBuffer;
+import org.junit.Test;
+import org.mockito.InOrder;
+
+public class Tomcat9CommitSessionOutputBufferTest {
+
+  final SessionCommitter sessionCommitter = mock(SessionCommitter.class);
+  final OutputBuffer delegate = mock(OutputBuffer.class);
+
+  final Tomcat9CommitSessionOutputBuffer commitSesssionOutputBuffer =
+      new Tomcat9CommitSessionOutputBuffer(sessionCommitter, delegate);
+
+  @Test
+  public void testDoWrite() throws IOException {
+    final ByteBuffer byteBuffer = ByteBuffer.allocate(0);
+
+    commitSesssionOutputBuffer.doWrite(byteBuffer);
+
+    final InOrder inOrder = inOrder(sessionCommitter, delegate);
+    inOrder.verify(sessionCommitter).commit();
+    inOrder.verify(delegate).doWrite(byteBuffer);
+    inOrder.verifyNoMoreInteractions();
+  }
+
+  @Test
+  public void getBytesWritten() {
+    when(delegate.getBytesWritten()).thenReturn(42L);
+
+    assertThat(commitSesssionOutputBuffer.getBytesWritten()).isEqualTo(42L);
+
+    final InOrder inOrder = inOrder(sessionCommitter, delegate);
+    inOrder.verify(delegate).getBytesWritten();
+    inOrder.verifyNoMoreInteractions();
+  }
+}
diff --git a/extensions/geode-modules-tomcat9/src/test/java/org/apache/geode/modules/session/catalina/Tomcat9CommitSessionValveTest.java b/extensions/geode-modules-tomcat9/src/test/java/org/apache/geode/modules/session/catalina/Tomcat9CommitSessionValveTest.java
new file mode 100644
index 0000000..32095a2
--- /dev/null
+++ b/extensions/geode-modules-tomcat9/src/test/java/org/apache/geode/modules/session/catalina/Tomcat9CommitSessionValveTest.java
@@ -0,0 +1,94 @@
+/*
+ * 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.modules.session.catalina.Tomcat9CommitSessionValve.getOutputBuffer;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.inOrder;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.reset;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.nio.ByteBuffer;
+
+import org.apache.catalina.Context;
+import org.apache.catalina.connector.Request;
+import org.apache.catalina.connector.Response;
+import org.apache.coyote.OutputBuffer;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.ArgumentCaptor;
+import org.mockito.InOrder;
+
+
+public class Tomcat9CommitSessionValveTest {
+
+  private final Tomcat9CommitSessionValve valve = new Tomcat9CommitSessionValve();
+  private final OutputBuffer outputBuffer = mock(OutputBuffer.class);
+  private Response response;
+  private org.apache.coyote.Response coyoteResponse;
+
+  @Before
+  public void before() {
+    final Context context = mock(Context.class);
+
+    final Request request = mock(Request.class);
+    doReturn(context).when(request).getContext();
+
+    coyoteResponse = new org.apache.coyote.Response();
+    coyoteResponse.setOutputBuffer(outputBuffer);
+
+    response = new Response();
+    response.setRequest(request);
+    response.setCoyoteResponse(coyoteResponse);
+  }
+
+  @Test
+  public void wrappedOutputBufferForwardsToDelegate() throws IOException {
+    wrappedOutputBufferForwardsToDelegate(new byte[] {'a', 'b', 'c'});
+  }
+
+  @Test
+  public void recycledResponseObjectDoesNotWrapAlreadyWrappedOutputBuffer() throws IOException {
+    wrappedOutputBufferForwardsToDelegate(new byte[] {'a', 'b', 'c'});
+    response.recycle();
+    reset(outputBuffer);
+    wrappedOutputBufferForwardsToDelegate(new byte[] {'d', 'e', 'f'});
+  }
+
+  private void wrappedOutputBufferForwardsToDelegate(final byte[] bytes) throws IOException {
+    final OutputStream outputStream =
+        valve.wrapResponse(response).getResponse().getOutputStream();
+    outputStream.write(bytes);
+    outputStream.flush();
+
+    final ArgumentCaptor<ByteBuffer> byteBuffer = ArgumentCaptor.forClass(ByteBuffer.class);
+
+    final InOrder inOrder = inOrder(outputBuffer);
+    inOrder.verify(outputBuffer).doWrite(byteBuffer.capture());
+    inOrder.verifyNoMoreInteractions();
+
+    final OutputBuffer wrappedOutputBuffer = getOutputBuffer(coyoteResponse);
+    assertThat(wrappedOutputBuffer).isInstanceOf(Tomcat9CommitSessionOutputBuffer.class);
+    assertThat(((Tomcat9CommitSessionOutputBuffer) wrappedOutputBuffer).getDelegate())
+        .isNotInstanceOf(Tomcat9CommitSessionOutputBuffer.class);
+
+    assertThat(byteBuffer.getValue().array()).contains(bytes);
+  }
+
+}
diff --git a/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/AbstractCommitSessionValve.java b/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/AbstractCommitSessionValve.java
new file mode 100644
index 0000000..fece1af
--- /dev/null
+++ b/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/AbstractCommitSessionValve.java
@@ -0,0 +1,83 @@
+/*
+ * 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 {
+    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);
+        if (session.isValid()) {
+          deltaSessionManager.removeTouchedSession(session.getId());
+          session.commit();
+          if (log.isDebugEnabled()) {
+            log.debug(session + ": Committed.");
+          }
+        } else {
+          if (log.isDebugEnabled()) {
+            log.debug(session + ": Not valid so not committing.");
+          }
+        }
+      }
+    }
+  }
+
+  abstract Response wrapResponse(final Response response);
+
+}
diff --git a/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/CommitSessionValve.java b/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/CommitSessionValve.java
deleted file mode 100644
index 1da58b7..0000000
--- a/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/CommitSessionValve.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * 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 java.io.IOException;
-
-import javax.servlet.ServletException;
-
-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 class CommitSessionValve extends ValveBase {
-
-  private static final Log log = LogFactory.getLog(CommitSessionValve.class);
-
-  protected static final String info =
-      "org.apache.geode.modules.session.catalina.CommitSessionValve/1.0";
-
-  CommitSessionValve() {
-    log.info("Initialized");
-  }
-
-  @Override
-  public void invoke(Request request, Response response) throws IOException, ServletException {
-    // Get the Manager
-    Manager manager = request.getContext().getManager();
-    DeltaSessionFacade session;
-
-    // Invoke the next Valve
-    try {
-      getNext().invoke(request, response);
-    } finally {
-      // Commit and if the correct Manager was found
-      if (manager instanceof DeltaSessionManager) {
-        session = (DeltaSessionFacade) request.getSession(false);
-        DeltaSessionManager dsm = ((DeltaSessionManager) manager);
-        if (session != null) {
-          if (session.isValid()) {
-            dsm.removeTouchedSession(session.getId());
-            session.commit();
-            if (dsm.getTheContext().getLogger().isDebugEnabled()) {
-              dsm.getTheContext().getLogger().debug(session + ": Committed.");
-            }
-          } else {
-            if (dsm.getTheContext().getLogger().isDebugEnabled()) {
-              dsm.getTheContext().getLogger().debug(session + ": Not valid so not committing.");
-            }
-          }
-        }
-      }
-    }
-  }
-}
diff --git a/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/DeltaSessionManager.java b/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/DeltaSessionManager.java
index 2af36fe..86103df 100644
--- a/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/DeltaSessionManager.java
+++ b/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/DeltaSessionManager.java
@@ -63,7 +63,8 @@ import org.apache.geode.modules.util.ContextMapper;
 import org.apache.geode.modules.util.RegionConfiguration;
 import org.apache.geode.modules.util.RegionHelper;
 
-public abstract class DeltaSessionManager extends ManagerBase
+public abstract class DeltaSessionManager<CommitSessionValveT extends AbstractCommitSessionValve>
+    extends ManagerBase
     implements Lifecycle, PropertyChangeListener, SessionManager {
 
   static final String catalinaBaseSystemProperty = "catalina.base";
@@ -91,7 +92,7 @@ public abstract class DeltaSessionManager extends ManagerBase
 
   private Valve jvmRouteBinderValve;
 
-  private Valve commitSessionValve;
+  private CommitSessionValveT commitSessionValve;
 
   private SessionCache sessionCache;
 
@@ -601,10 +602,12 @@ public abstract class DeltaSessionManager extends ManagerBase
     if (getLogger().isDebugEnabled()) {
       getLogger().debug(this + ": Registering CommitSessionValve");
     }
-    commitSessionValve = new CommitSessionValve();
+    commitSessionValve = createCommitSessionValve();
     getPipeline().addValve(commitSessionValve);
   }
 
+  protected abstract CommitSessionValveT createCommitSessionValve();
+
   protected void unregisterCommitSessionValve() {
     if (getLogger().isDebugEnabled()) {
       getLogger().debug(this + ": Unregistering CommitSessionValve");
diff --git a/extensions/geode-modules-tomcat8/src/main/java/org/apache/geode/modules/session/catalina/DeltaSession8.java b/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/SessionCommitter.java
similarity index 60%
copy from extensions/geode-modules-tomcat8/src/main/java/org/apache/geode/modules/session/catalina/DeltaSession8.java
copy to extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/SessionCommitter.java
index a17fdde..5af9aa2 100644
--- a/extensions/geode-modules-tomcat8/src/main/java/org/apache/geode/modules/session/catalina/DeltaSession8.java
+++ b/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/SessionCommitter.java
@@ -12,28 +12,16 @@
  * or implied. See the License for the specific language governing permissions and limitations under
  * the License.
  */
-package org.apache.geode.modules.session.catalina;
-
-import org.apache.catalina.Manager;
 
+package org.apache.geode.modules.session.catalina;
 
-@SuppressWarnings("serial")
-public class DeltaSession8 extends DeltaSession {
-  /**
-   * Construct a new <code>Session</code> associated with no <code>Manager</code>. The
-   * <code>Manager</code> will be assigned later using {@link #setOwner(Object)}.
-   */
-  @SuppressWarnings("unused")
-  public DeltaSession8() {
-    super();
-  }
+/**
+ * Lambda interface for committing session data.
+ */
+interface SessionCommitter {
 
   /**
-   * Construct a new Session associated with the specified Manager.
-   *
-   * @param manager The manager with which this Session is associated
+   * Invoked to commit session data.
    */
-  DeltaSession8(Manager manager) {
-    super(manager);
-  }
+  void commit();
 }
diff --git a/extensions/geode-modules-tomcat8/src/main/java/org/apache/geode/modules/session/catalina/DeltaSession8.java b/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/Tomcat6CommitSessionValve.java
similarity index 59%
copy from extensions/geode-modules-tomcat8/src/main/java/org/apache/geode/modules/session/catalina/DeltaSession8.java
copy to extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/Tomcat6CommitSessionValve.java
index a17fdde..b27fe65 100644
--- a/extensions/geode-modules-tomcat8/src/main/java/org/apache/geode/modules/session/catalina/DeltaSession8.java
+++ b/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/Tomcat6CommitSessionValve.java
@@ -12,28 +12,16 @@
  * or implied. See the License for the specific language governing permissions and limitations under
  * the License.
  */
-package org.apache.geode.modules.session.catalina;
 
-import org.apache.catalina.Manager;
+package org.apache.geode.modules.session.catalina;
 
+import org.apache.catalina.connector.Response;
 
-@SuppressWarnings("serial")
-public class DeltaSession8 extends DeltaSession {
-  /**
-   * Construct a new <code>Session</code> associated with no <code>Manager</code>. The
-   * <code>Manager</code> will be assigned later using {@link #setOwner(Object)}.
-   */
-  @SuppressWarnings("unused")
-  public DeltaSession8() {
-    super();
-  }
+@Deprecated
+public final class Tomcat6CommitSessionValve extends AbstractCommitSessionValve {
 
-  /**
-   * Construct a new Session associated with the specified Manager.
-   *
-   * @param manager The manager with which this Session is associated
-   */
-  DeltaSession8(Manager manager) {
-    super(manager);
+  @Override
+  protected Response wrapResponse(Response response) {
+    return response;
   }
 }
diff --git a/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/Tomcat6DeltaSessionManager.java b/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/Tomcat6DeltaSessionManager.java
index 555f09e..1abceb9 100644
--- a/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/Tomcat6DeltaSessionManager.java
+++ b/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/Tomcat6DeltaSessionManager.java
@@ -21,7 +21,7 @@ import org.apache.catalina.util.LifecycleSupport;
  * @deprecated Tomcat 6 has reached its end of life and support for Tomcat 6 will be removed
  *             from a future Geode release.
  */
-public class Tomcat6DeltaSessionManager extends DeltaSessionManager {
+public class Tomcat6DeltaSessionManager extends DeltaSessionManager<Tomcat6CommitSessionValve> {
 
   /**
    * The <code>LifecycleSupport</code> for this component.
@@ -131,4 +131,9 @@ public class Tomcat6DeltaSessionManager extends DeltaSessionManager {
   public void removeLifecycleListener(LifecycleListener listener) {
     this.lifecycle.removeLifecycleListener(listener);
   }
+
+  @Override
+  protected Tomcat6CommitSessionValve createCommitSessionValve() {
+    return new Tomcat6CommitSessionValve();
+  }
 }
diff --git a/geode-assembly/geode-assembly-test/build.gradle b/geode-assembly/geode-assembly-test/build.gradle
index 40c01cb..a53fdb1 100755
--- a/geode-assembly/geode-assembly-test/build.gradle
+++ b/geode-assembly/geode-assembly-test/build.gradle
@@ -25,9 +25,11 @@ dependencies {
   compileOnly(project(':extensions:geode-modules-test'))
   compileOnly(project(':geode-core'))
   compileOnly(project(':geode-pulse'))
+  compileOnly(project(':geode-junit'))
   implementation(project(':geode-logging'))
   implementation(project(':geode-membership'))
   implementation('javax.servlet:javax.servlet-api')
+  implementation('org.apache.commons:commons-lang3')
   compileOnly(project(':geode-tcp-server'))
   compileOnly('com.fasterxml.jackson.core:jackson-databind')
   compileOnly('commons-io:commons-io')
diff --git a/geode-assembly/src/integrationTest/resources/assembly_content.txt b/geode-assembly/src/integrationTest/resources/assembly_content.txt
index 8d9c4e6..1b275d1 100644
--- a/geode-assembly/src/integrationTest/resources/assembly_content.txt
+++ b/geode-assembly/src/integrationTest/resources/assembly_content.txt
@@ -840,7 +840,11 @@ javadoc/org/apache/geode/modules/session/catalina/AbstractCacheLifecycleListener
 javadoc/org/apache/geode/modules/session/catalina/AbstractSessionCache.html
 javadoc/org/apache/geode/modules/session/catalina/ClientServerCacheLifecycleListener.html
 javadoc/org/apache/geode/modules/session/catalina/ClientServerSessionCache.html
-javadoc/org/apache/geode/modules/session/catalina/CommitSessionValve.html
+javadoc/org/apache/geode/modules/session/catalina/AbstractCommitSessionValve.html
+javadoc/org/apache/geode/modules/session/catalina/Tomcat6CommitSessionValve.html
+javadoc/org/apache/geode/modules/session/catalina/Tomcat7CommitSessionValve.html
+javadoc/org/apache/geode/modules/session/catalina/Tomcat8CommitSessionValve.html
+javadoc/org/apache/geode/modules/session/catalina/Tomcat9CommitSessionValve.html
 javadoc/org/apache/geode/modules/session/catalina/DeltaSession.html
 javadoc/org/apache/geode/modules/session/catalina/DeltaSession7.html
 javadoc/org/apache/geode/modules/session/catalina/DeltaSession8.html

[geode] 09/11: GEODE-8513: Remove (de)serialization of local sessions. (#5532)

Posted by sa...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

sabbey37 pushed a commit to branch support/1.13
in repository https://gitbox.apache.org/repos/asf/geode.git

commit 29bb5a2f94bcd5e5ab4c11ba211d2f564e75f165
Author: Jacob Barrett <jb...@pivotal.io>
AuthorDate: Tue Sep 29 09:57:53 2020 -0700

    GEODE-8513: Remove (de)serialization of local sessions. (#5532)
    
    * Removes query that resulted in casting issue in antlr.
    * Clears all locally cached entries.
    * Remove dead code and tests.
    
    (cherry picked from commit d4b9ecd8569281f257e384d397422e7ef4336fb9)
---
 .../catalina/AbstractDeltaSessionManagerTest.java  | 223 +------------
 .../session/catalina/DeltaSessionManager.java      | 354 +--------------------
 2 files changed, 14 insertions(+), 563 deletions(-)

diff --git a/extensions/geode-modules-test/src/main/java/org/apache/geode/modules/session/catalina/AbstractDeltaSessionManagerTest.java b/extensions/geode-modules-test/src/main/java/org/apache/geode/modules/session/catalina/AbstractDeltaSessionManagerTest.java
index d5fea45..c28256c 100644
--- a/extensions/geode-modules-test/src/main/java/org/apache/geode/modules/session/catalina/AbstractDeltaSessionManagerTest.java
+++ b/extensions/geode-modules-test/src/main/java/org/apache/geode/modules/session/catalina/AbstractDeltaSessionManagerTest.java
@@ -17,50 +17,28 @@ package org.apache.geode.modules.session.catalina;
 
 import static org.apache.geode.modules.util.RegionConfiguration.DEFAULT_MAX_INACTIVE_INTERVAL;
 import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.anyInt;
 import static org.mockito.ArgumentMatchers.anyString;
-import static org.mockito.Mockito.doNothing;
 import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.doThrow;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
-import static org.mockito.Mockito.withSettings;
 
 import java.beans.PropertyChangeEvent;
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
 import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
 import java.util.HashSet;
 import java.util.Set;
 
 import javax.servlet.http.HttpSession;
 
 import org.apache.catalina.Context;
-import org.apache.catalina.Loader;
 import org.apache.catalina.Session;
-import org.apache.catalina.session.StandardSession;
 import org.apache.juli.logging.Log;
 import org.junit.Test;
 
 import org.apache.geode.cache.Cache;
 import org.apache.geode.cache.Region;
-import org.apache.geode.cache.query.FunctionDomainException;
-import org.apache.geode.cache.query.NameResolutionException;
-import org.apache.geode.cache.query.Query;
-import org.apache.geode.cache.query.QueryInvocationTargetException;
-import org.apache.geode.cache.query.SelectResults;
-import org.apache.geode.cache.query.TypeMismatchException;
-import org.apache.geode.cache.query.internal.InternalQueryService;
-import org.apache.geode.cache.query.internal.LinkedResultSet;
 import org.apache.geode.internal.cache.GemFireCacheImpl;
 import org.apache.geode.modules.session.catalina.internal.DeltaSessionStatistics;
 
@@ -217,142 +195,15 @@ public abstract class AbstractDeltaSessionManagerTest<DeltaSessionManagerT exten
   }
 
   @Test
-  public void loadActivatesAndAddsSingleSessionWithValidIdAndMoreRecentAccessTime()
-      throws IOException, ClassNotFoundException {
-    final String contextPath = "contextPath";
-    final String expectedStoreDir = "";
-    final DeltaSession newSession = mock(DeltaSession.class);
-    final DeltaSession existingSession = mock(DeltaSession.class);
-
-    prepareMocksForLoadTest(contextPath, newSession, existingSession, expectedStoreDir);
-
-    manager.load();
-
-    verify(newSession).activate();
-    verify(manager).add(newSession);
-  }
-
-  @Test
-  public void loadLogsWarningAndDoesNotAddSessionWhenSessionStoreNotFound()
-      throws IOException, ClassNotFoundException {
-    final String contextPath = "contextPath";
-    final String expectedStoreDir = "";
-    final DeltaSession newSession = mock(DeltaSession.class);
-    final DeltaSession existingSession = mock(DeltaSession.class);
-
-    prepareMocksForLoadTest(contextPath, newSession, existingSession, expectedStoreDir);
-
-    doReturn(null).when(manager).getFileAtPath(any(), any());
-
-    manager.load();
-
-    verify(logger).debug("No session store file found");
-    verify(manager, times(0)).add(any());
-  }
-
-  @Test
-  public void loadDoesNotAddSessionToManagerWithValidIdAndLessRecentAccessTime()
-      throws IOException, ClassNotFoundException {
-    final String contextPath = "contextPath";
-    final String expectedStoreDir = "";
-    final DeltaSession newSession = mock(DeltaSession.class);
-    final DeltaSession existingSession = mock(DeltaSession.class);
-
-    prepareMocksForLoadTest(contextPath, newSession, existingSession, expectedStoreDir);
-
-    when(existingSession.getLastAccessedTime()).thenReturn(2L);
-
-    manager.load();
-
-    verify(newSession, times(0)).activate();
-    verify(manager, times(0)).add(newSession);
-  }
-
-  @Test
-  public void unloadWritesSingleSessionToDiskWhenIdIsValid()
-      throws IOException, NameResolutionException, TypeMismatchException,
-      QueryInvocationTargetException, FunctionDomainException {
-    final String sessionId = "sessionId";
-    final DeltaSession session = mock(DeltaSession.class);
-    final FileOutputStream fos = mock(FileOutputStream.class);
-    final BufferedOutputStream bos = mock(BufferedOutputStream.class);
-    final ObjectOutputStream oos = mock(ObjectOutputStream.class);
-
-    prepareMocksForUnloadTest(sessionId, fos, bos, oos, session);
-
-    manager.unload();
-
-    verify((StandardSession) session).writeObjectData(oos);
-  }
-
-  @Test
-  public void unloadDoesNotWriteSessionToDiskAndClosesOutputStreamsWhenOutputStreamThrowsIOException()
-      throws IOException, NameResolutionException, TypeMismatchException,
-      QueryInvocationTargetException, FunctionDomainException {
-    final String sessionId = "sessionId";
-    final DeltaSession session = mock(DeltaSession.class);
-    final FileOutputStream fos = mock(FileOutputStream.class);
-    final BufferedOutputStream bos = mock(BufferedOutputStream.class);
-    final ObjectOutputStream oos = mock(ObjectOutputStream.class);
-
-    prepareMocksForUnloadTest(sessionId, fos, bos, oos, session);
-
-    final String exceptionMessage = "Output Stream IOException";
-
-    final IOException exception = new IOException(exceptionMessage);
-
-    doThrow(exception).when(manager).getObjectOutputStream(bos);
-
-    assertThatThrownBy(() -> manager.unload()).isInstanceOf(IOException.class)
-        .hasMessage(exceptionMessage);
-
-    verify((StandardSession) session, times(0)).writeObjectData(oos);
-    verify(bos).close();
-    verify(fos).close();
-  }
-
-  @Test
-  public void unloadDoesNotWriteSessionToDiskAndClosesOutputStreamsWhenSessionIsWrongClass()
-      throws IOException, NameResolutionException, TypeMismatchException,
-      QueryInvocationTargetException, FunctionDomainException {
-    final String sessionId = "sessionId";
-    final DeltaSession session = mock(DeltaSession.class);
-    final FileOutputStream fos = mock(FileOutputStream.class);
-    final BufferedOutputStream bos = mock(BufferedOutputStream.class);
-    final ObjectOutputStream oos = mock(ObjectOutputStream.class);
-
-    prepareMocksForUnloadTest(sessionId, fos, bos, oos, session);
-
-    final Session invalidSession =
-        mock(Session.class, withSettings().extraInterfaces(DeltaSessionInterface.class));
-
-    doReturn(invalidSession).when(manager).findSession(sessionId);
-
-    assertThatThrownBy(() -> manager.unload()).isInstanceOf(IOException.class);
-
-    verify((StandardSession) session, times(0)).writeObjectData(oos);
-    verify(oos).close();
-  }
-
-  @Test
   public void successfulUnloadWithClientServerSessionCachePerformsLocalDestroy()
-      throws IOException, NameResolutionException, TypeMismatchException,
-      QueryInvocationTargetException, FunctionDomainException {
-    final String sessionId = "sessionId";
-    final DeltaSession session = mock(DeltaSession.class);
-    final FileOutputStream fos = mock(FileOutputStream.class);
-    final BufferedOutputStream bos = mock(BufferedOutputStream.class);
-    final ObjectOutputStream oos = mock(ObjectOutputStream.class);
-
-    prepareMocksForUnloadTest(sessionId, fos, bos, oos, session);
-
+      throws IOException {
+    when(sessionCache.getCache()).thenReturn(cache);
+    when(context.getPath()).thenReturn("contextPath");
     when(sessionCache.isClientServer()).thenReturn(true);
-    when(session.getId()).thenReturn(sessionId);
 
     manager.unload();
 
-    verify((StandardSession) session).writeObjectData(oos);
-    verify(operatingRegion).localDestroy(sessionId);
+    verify(operatingRegion).localClear();
   }
 
   @Test
@@ -403,70 +254,4 @@ public abstract class AbstractDeltaSessionManagerTest<DeltaSessionManagerT exten
     verify(manager).setMaxInactiveInterval(oldValue);
   }
 
-  public void prepareMocksForUnloadTest(final String sessionId, final FileOutputStream fos,
-      final BufferedOutputStream bos, final ObjectOutputStream oos,
-      final DeltaSession session)
-      throws NameResolutionException, TypeMismatchException, QueryInvocationTargetException,
-      FunctionDomainException, IOException {
-    final String regionName = "regionName";
-    final String contextPath = "contextPath";
-    final String catalinaBaseSystemProp = "Catalina/Base";
-    final String systemFileSeparator = "/";
-    final String expectedStoreDir = catalinaBaseSystemProp + systemFileSeparator + "temp";
-
-    final InternalQueryService queryService = mock(InternalQueryService.class);
-    final Query query = mock(Query.class);
-    final File store = mock(File.class);
-    final SelectResults results = new LinkedResultSet();
-
-    when(sessionCache.getCache()).thenReturn(cache);
-    when(context.getPath()).thenReturn(contextPath);
-    when(cache.getQueryService()).thenReturn(queryService);
-    when(queryService.newQuery(anyString())).thenReturn(query);
-    when(query.execute()).thenReturn(results);
-    doReturn(catalinaBaseSystemProp).when(manager)
-        .getSystemPropertyValue(DeltaSessionManager.catalinaBaseSystemProperty);
-    doReturn(systemFileSeparator).when(manager)
-        .getSystemPropertyValue(DeltaSessionManager.fileSeparatorSystemProperty);
-    doReturn(store).when(manager).getFileAtPath(expectedStoreDir, contextPath);
-    doReturn(fos).when(manager).getFileOutputStream(store);
-    doReturn(bos).when(manager).getBufferedOutputStream(fos);
-    doReturn(oos).when(manager).getObjectOutputStream(bos);
-    doReturn(regionName).when(manager).getRegionName();
-    doReturn(session).when(manager).findSession(sessionId);
-    doNothing().when(manager).writeToObjectOutputStream(any(), any());
-
-    results.add(sessionId);
-  }
-
-  public void prepareMocksForLoadTest(final String contextPath, final DeltaSession newSession,
-      final DeltaSession existingSession, String expectedStoreDir)
-      throws IOException, ClassNotFoundException {
-    final String catalinaBaseSystemProp = "Catalina/Base";
-    final String systemFileSeparator = "/";
-    expectedStoreDir = catalinaBaseSystemProp + systemFileSeparator + "temp";
-    final String newSessionId = "newSessionId";
-
-    final File store = mock(File.class);
-    final FileInputStream fis = mock(FileInputStream.class);
-    final BufferedInputStream bis = mock(BufferedInputStream.class);
-    final ObjectInputStream ois = mock(ObjectInputStream.class);
-    final Loader loader = mock(Loader.class);
-
-    when(context.getPath()).thenReturn(contextPath);
-    when(context.getLoader()).thenReturn(loader);
-    when(newSession.getId()).thenReturn(newSessionId);
-    when(newSession.getLastAccessedTime()).thenReturn(1L);
-    when(newSession.isValid()).thenReturn(true);
-    when(existingSession.getLastAccessedTime()).thenReturn(0L);
-    doReturn(catalinaBaseSystemProp).when(manager).getSystemPropertyValue("catalina.base");
-    doReturn(systemFileSeparator).when(manager).getSystemPropertyValue("file.separator");
-    doReturn(store).when(manager).getFileAtPath(expectedStoreDir, contextPath);
-    doReturn(fis).when(manager).getFileInputStream(store);
-    doReturn(bis).when(manager).getBufferedInputStream(fis);
-    doReturn(ois).when(manager).getObjectInputStream(bis);
-    doReturn(1).when(manager).getSessionCountFromObjectInputStream(ois);
-    doReturn(newSession).when(manager).getNewSession();
-    doReturn(existingSession).when(operatingRegion).get(newSessionId);
-  }
 }
diff --git a/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/DeltaSessionManager.java b/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/DeltaSessionManager.java
index 40b2b14..a42b0d8 100644
--- a/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/DeltaSessionManager.java
+++ b/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/DeltaSessionManager.java
@@ -14,25 +14,12 @@
  */
 package org.apache.geode.modules.session.catalina;
 
-import static org.apache.geode.cache.Region.SEPARATOR;
-import static org.apache.geode.util.internal.UncheckedUtils.uncheckedCast;
-
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
 import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashSet;
 import java.util.Iterator;
-import java.util.List;
 import java.util.Set;
 import java.util.Timer;
 import java.util.TimerTask;
@@ -40,28 +27,19 @@ import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicInteger;
 
-import javax.servlet.http.HttpSession;
-
 import org.apache.catalina.Container;
 import org.apache.catalina.Context;
 import org.apache.catalina.Lifecycle;
-import org.apache.catalina.Loader;
 import org.apache.catalina.Pipeline;
 import org.apache.catalina.Session;
 import org.apache.catalina.Valve;
 import org.apache.catalina.session.ManagerBase;
 import org.apache.catalina.session.StandardSession;
-import org.apache.catalina.util.CustomObjectInputStream;
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
 
 import org.apache.geode.cache.Cache;
 import org.apache.geode.cache.CacheFactory;
-import org.apache.geode.cache.EntryNotFoundException;
-import org.apache.geode.cache.Region;
-import org.apache.geode.cache.query.Query;
-import org.apache.geode.cache.query.QueryService;
-import org.apache.geode.cache.query.SelectResults;
 import org.apache.geode.internal.cache.GemFireCacheImpl;
 import org.apache.geode.modules.session.catalina.internal.DeltaSessionStatistics;
 import org.apache.geode.modules.util.ContextMapper;
@@ -589,13 +567,12 @@ public abstract class DeltaSessionManager<CommitSessionValveT extends AbstractCo
 
   @Override
   public void load() throws ClassNotFoundException, IOException {
-    doLoad();
     ContextMapper.addContext(getContextName(), this);
   }
 
   @Override
   public void unload() throws IOException {
-    doUnload();
+    clearLocalCache();
     ContextMapper.removeContext(getContextName());
   }
 
@@ -693,333 +670,22 @@ public abstract class DeltaSessionManager<CommitSessionValveT extends AbstractCo
   }
 
   /**
-   * Save any currently active sessions in the appropriate persistence mechanism, if any. If
-   * persistence is not supported, this method returns without doing anything.
-   *
-   * @throws IOException if an input/output error occurs
+   * Clear the local cache to avoid ClassCastException if container is being reloaded.
    */
-  private void doUnload() throws IOException {
-    QueryService querySvc = getSessionCache().getCache().getQueryService();
-    Context context = getTheContext();
-
-    if (context == null) {
-      return;
-    }
-
-    String regionName;
-    if (getRegionName().startsWith(SEPARATOR)) {
-      regionName = getRegionName();
-    } else {
-      regionName = SEPARATOR + getRegionName();
-    }
-
-    Query query = querySvc.newQuery("select s.id from " + regionName
-        + " as s where s.contextName = '" + context.getPath() + "'");
-
-    if (getLogger().isDebugEnabled()) {
-      getLogger().debug("Query: " + query.getQueryString());
-    }
-
-    SelectResults<String> results;
-    try {
-      results = uncheckedCast(query.execute());
-    } catch (Exception ex) {
-      getLogger().error("Unable to perform query during doUnload", ex);
-      return;
-    }
-
-    if (results.isEmpty()) {
-      getLogger().debug("No sessions to unload for context " + context.getPath());
-      return; // nothing to do
-    }
-
-    // Open an output stream to the specified pathname, if any
-    File store = sessionStore(context.getPath());
-    if (store == null) {
-      return;
-    }
-    if (getLogger().isDebugEnabled()) {
-      getLogger().debug("Unloading sessions to " + store.getAbsolutePath());
-    }
-    FileOutputStream fos = null;
-    BufferedOutputStream bos = null;
-    final ObjectOutputStream oos;
-    boolean error = false;
-    try {
-      fos = getFileOutputStream(store);
-      bos = getBufferedOutputStream(fos);
-      oos = getObjectOutputStream(bos);
-    } catch (IOException e) {
-      error = true;
-      getLogger().error("Exception unloading sessions", e);
-      throw e;
-    } finally {
-      if (error) {
-        if (bos != null) {
-          try {
-            bos.close();
-          } catch (IOException ioe) {
-            // Ignore
-          }
-        }
-        if (fos != null) {
-          try {
-            fos.close();
-          } catch (IOException ioe) {
-            // Ignore
-          }
-        }
-      }
-    }
-
-    ArrayList<DeltaSessionInterface> list = new ArrayList<>();
-    for (final String id : results) {
-      DeltaSessionInterface session = (DeltaSessionInterface) findSession(id);
-      if (session != null) {
-        list.add(session);
-      }
-    }
+  private void clearLocalCache() {
+    final Log logger = getLogger();
+    final boolean debugEnabled = logger.isDebugEnabled();
 
-    // Write the number of active sessions, followed by the details
-    if (getLogger().isDebugEnabled()) {
-      getLogger().debug("Unloading " + list.size() + " sessions");
-    }
-    try {
-      writeToObjectOutputStream(oos, list);
-      for (DeltaSessionInterface session : list) {
-        if (session instanceof StandardSession) {
-          StandardSession standardSession = (StandardSession) session;
-          standardSession.passivate();
-          standardSession.writeObjectData(oos);
-        } else {
-          // All DeltaSessionInterfaces as of Geode 1.0 should be based on StandardSession
-          throw new IOException("Session should be of type StandardSession");
-        }
-      }
-    } catch (IOException e) {
-      getLogger().error("Exception unloading sessions", e);
-      try {
-        oos.close();
-      } catch (IOException f) {
-        // Ignore
-      }
-      throw e;
-    }
-
-    // Flush and close the output stream
-    try {
-      oos.flush();
-    } finally {
-      try {
-        oos.close();
-      } catch (IOException f) {
-        // Ignore
-      }
-    }
-
-    // Locally destroy the sessions we just wrote
     if (getSessionCache().isClientServer()) {
-      for (DeltaSessionInterface session : list) {
-        if (getLogger().isDebugEnabled()) {
-          getLogger().debug("Locally destroying session " + session.getId());
-        }
-        try {
-          getSessionCache().getOperatingRegion().localDestroy(session.getId());
-        } catch (EntryNotFoundException ex) {
-          // This can be thrown if an entry is evicted during or immediately after a session is
-          // written
-          // to disk. This isn't a problem, but the resulting exception messages can be confusing in
-          // testing
-        }
-      }
-    }
-
-    if (getLogger().isDebugEnabled()) {
-      getLogger().debug("Unloading complete");
-    }
-  }
-
-  /**
-   * Load any currently active sessions that were previously unloaded to the appropriate persistence
-   * mechanism, if any. If persistence is not supported, this method returns without doing
-   * anything.
-   *
-   * @throws ClassNotFoundException if a serialized class cannot be found during the reload
-   * @throws IOException if an input/output error occurs
-   */
-  private void doLoad() throws ClassNotFoundException, IOException {
-    Context context = getTheContext();
-    if (context == null) {
-      return;
-    }
-
-    // Open an input stream to the specified pathname, if any
-    File store = sessionStore(context.getPath());
-    if (store == null) {
-      getLogger().debug("No session store file found");
-      return;
-    }
-    if (getLogger().isDebugEnabled()) {
-      getLogger().debug("Loading sessions from " + store.getAbsolutePath());
-    }
-    FileInputStream fis = null;
-    BufferedInputStream bis = null;
-    ObjectInputStream ois;
-    Loader loader = null;
-    ClassLoader classLoader = null;
-    try {
-      fis = getFileInputStream(store);
-      bis = getBufferedInputStream(fis);
-      if (getTheContext() != null) {
-        loader = getTheContext().getLoader();
-      }
-      if (loader != null) {
-        classLoader = loader.getClassLoader();
-      }
-      if (classLoader != null) {
-        if (getLogger().isDebugEnabled()) {
-          getLogger().debug("Creating custom object input stream for class loader");
-        }
-        ois = new CustomObjectInputStream(bis, classLoader);
-      } else {
-        if (getLogger().isDebugEnabled()) {
-          getLogger().debug("Creating standard object input stream");
-        }
-        ois = getObjectInputStream(bis);
-      }
-    } catch (FileNotFoundException e) {
-      if (getLogger().isDebugEnabled()) {
-        getLogger().debug("No persisted data file found");
-      }
-      return;
-    } catch (IOException e) {
-      getLogger().error("Exception loading sessions", e);
-      try {
-        fis.close();
-      } catch (IOException f) {
-        // Ignore
-      }
-      try {
-        bis.close();
-      } catch (IOException f) {
-        // Ignore
-      }
-      throw e;
-    }
-
-    // Load the previously unloaded active sessions
-    try {
-      int n = getSessionCountFromObjectInputStream(ois);
-      if (getLogger().isDebugEnabled()) {
-        getLogger().debug("Loading " + n + " persisted sessions");
-      }
-      for (int i = 0; i < n; i++) {
-        StandardSession session = getNewSession();
-        session.readObjectData(ois);
-        session.setManager(this);
-
-        final Region<String, HttpSession> region = getSessionCache().getOperatingRegion();
-        final DeltaSessionInterface existingSession =
-            (DeltaSessionInterface) region.get(session.getId());
-        // Check whether the existing session is newer
-        if (existingSession != null
-            && existingSession.getLastAccessedTime() > session.getLastAccessedTime()) {
-          if (getLogger().isDebugEnabled()) {
-            getLogger().debug("Loaded session " + session.getId() + " is older than cached copy");
-          }
-          continue;
-        }
-
-        // Check whether the new session has already expired
-        if (!session.isValid()) {
-          if (getLogger().isDebugEnabled()) {
-            getLogger().debug("Loaded session " + session.getId() + " is invalid");
-          }
-          continue;
-        }
-
-        getLogger().debug("Loading session " + session.getId());
-        session.activate();
-        add(session);
-      }
-    } catch (ClassNotFoundException | IOException e) {
-      getLogger().error(e);
-      try {
-        ois.close();
-      } catch (IOException f) {
-        // Ignore
-      }
-      throw e;
-    } finally {
-      // Close the input stream
-      try {
-        ois.close();
-      } catch (IOException f) {
-        // ignored
-      }
-
-      // Delete the persistent storage file
-      if (store.exists()) {
-        if (!store.delete()) {
-          getLogger().warn("Couldn't delete persistent storage file " + store.getAbsolutePath());
-        }
+      if (debugEnabled) {
+        logger.debug("Locally clearing sessions.");
       }
+      getSessionCache().getOperatingRegion().localClear();
     }
-  }
 
-  /**
-   * Return a File object representing the pathname to our persistence file, if any.
-   */
-  private File sessionStore(String ctxPath) {
-    String storeDir = getSystemPropertyValue(catalinaBaseSystemProperty);
-    if (storeDir == null || storeDir.isEmpty()) {
-      storeDir = getSystemPropertyValue(javaTempDirSystemProperty);
-    } else {
-      storeDir += getSystemPropertyValue(fileSeparatorSystemProperty) + "temp";
+    if (debugEnabled) {
+      logger.debug("Unloading complete");
     }
-
-    return getFileAtPath(storeDir, ctxPath);
-  }
-
-  String getSystemPropertyValue(String propertyKey) {
-    return System.getProperty(propertyKey);
-  }
-
-  File getFileAtPath(String storeDir, String ctxPath) {
-    return (new File(storeDir, ctxPath.replaceAll("/", "_") + ".sessions.ser"));
-  }
-
-  FileInputStream getFileInputStream(File file) throws FileNotFoundException {
-    return new FileInputStream(file.getAbsolutePath());
-  }
-
-  BufferedInputStream getBufferedInputStream(FileInputStream fis) {
-    return new BufferedInputStream(fis);
-  }
-
-  ObjectInputStream getObjectInputStream(BufferedInputStream bis) throws IOException {
-    return new ObjectInputStream(bis);
-  }
-
-  FileOutputStream getFileOutputStream(File file) throws FileNotFoundException {
-    return new FileOutputStream(file.getAbsolutePath());
-  }
-
-  BufferedOutputStream getBufferedOutputStream(FileOutputStream fos) {
-    return new BufferedOutputStream(fos);
-  }
-
-  ObjectOutputStream getObjectOutputStream(BufferedOutputStream bos) throws IOException {
-    return new ObjectOutputStream(bos);
-  }
-
-  void writeToObjectOutputStream(ObjectOutputStream oos, List<?> listToWrite) throws IOException {
-    oos.writeObject(listToWrite.size());
-  }
-
-  int getSessionCountFromObjectInputStream(ObjectInputStream ois)
-      throws IOException, ClassNotFoundException {
-    return (Integer) ois.readObject();
   }
 
   @Override

[geode] 02/11: Revert "GEODE-8513: Remove (de)serialization of local sessions."

Posted by sa...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

sabbey37 pushed a commit to branch support/1.13
in repository https://gitbox.apache.org/repos/asf/geode.git

commit de2238da9d8db2fbfe8cd9f5832ce90e093e3560
Author: Sarah <sa...@pivotal.io>
AuthorDate: Mon Apr 12 09:22:21 2021 -0400

    Revert "GEODE-8513: Remove (de)serialization of local sessions."
    
    This reverts commit 247d373b8ee678e6cb3699047a5a0dcfc81f6d51.
---
 .../catalina/DeltaSessionManagerJUnitTest.java     | 223 ++++++++++++-
 .../session/catalina/DeltaSessionManager.java      | 356 ++++++++++++++++++++-
 2 files changed, 565 insertions(+), 14 deletions(-)

diff --git a/extensions/geode-modules-test/src/main/java/org/apache/geode/modules/session/catalina/DeltaSessionManagerJUnitTest.java b/extensions/geode-modules-test/src/main/java/org/apache/geode/modules/session/catalina/DeltaSessionManagerJUnitTest.java
index 835575b..fec8571 100644
--- a/extensions/geode-modules-test/src/main/java/org/apache/geode/modules/session/catalina/DeltaSessionManagerJUnitTest.java
+++ b/extensions/geode-modules-test/src/main/java/org/apache/geode/modules/session/catalina/DeltaSessionManagerJUnitTest.java
@@ -17,28 +17,50 @@ package org.apache.geode.modules.session.catalina;
 
 import static org.apache.geode.modules.util.RegionConfiguration.DEFAULT_MAX_INACTIVE_INTERVAL;
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.anyInt;
 import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.Mockito.doNothing;
 import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.doThrow;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
+import static org.mockito.Mockito.withSettings;
 
 import java.beans.PropertyChangeEvent;
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
 import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
 import java.util.HashSet;
 import java.util.Set;
 
 import javax.servlet.http.HttpSession;
 
 import org.apache.catalina.Context;
+import org.apache.catalina.Loader;
 import org.apache.catalina.Session;
+import org.apache.catalina.session.StandardSession;
 import org.apache.juli.logging.Log;
 import org.junit.Test;
 
 import org.apache.geode.cache.Cache;
 import org.apache.geode.cache.Region;
+import org.apache.geode.cache.query.FunctionDomainException;
+import org.apache.geode.cache.query.NameResolutionException;
+import org.apache.geode.cache.query.Query;
+import org.apache.geode.cache.query.QueryInvocationTargetException;
+import org.apache.geode.cache.query.SelectResults;
+import org.apache.geode.cache.query.TypeMismatchException;
+import org.apache.geode.cache.query.internal.InternalQueryService;
+import org.apache.geode.cache.query.internal.LinkedResultSet;
 import org.apache.geode.internal.cache.GemFireCacheImpl;
 import org.apache.geode.modules.session.catalina.internal.DeltaSessionStatistics;
 
@@ -195,15 +217,142 @@ public abstract class DeltaSessionManagerJUnitTest {
   }
 
   @Test
+  public void loadActivatesAndAddsSingleSessionWithValidIdAndMoreRecentAccessTime()
+      throws IOException, ClassNotFoundException {
+    String contextPath = "contextPath";
+    String expectedStoreDir = "";
+    DeltaSession newSession = mock(DeltaSession.class);
+    DeltaSession existingSession = mock(DeltaSession.class);
+
+    prepareMocksForLoadTest(contextPath, newSession, existingSession, expectedStoreDir);
+
+    manager.load();
+
+    verify(newSession).activate();
+    verify(manager).add(newSession);
+  }
+
+  @Test
+  public void loadLogsWarningAndDoesNotAddSessionWhenSessionStoreNotFound()
+      throws IOException, ClassNotFoundException {
+    String contextPath = "contextPath";
+    String expectedStoreDir = "";
+    DeltaSession newSession = mock(DeltaSession.class);
+    DeltaSession existingSession = mock(DeltaSession.class);
+
+    prepareMocksForLoadTest(contextPath, newSession, existingSession, expectedStoreDir);
+
+    doReturn(null).when(manager).getFileAtPath(any(), any());
+
+    manager.load();
+
+    verify(logger).debug("No session store file found");
+    verify(manager, times(0)).add(any());
+  }
+
+  @Test
+  public void loadDoesNotAddSessionToManagerWithValidIdAndLessRecentAccessTime()
+      throws IOException, ClassNotFoundException {
+    String contextPath = "contextPath";
+    String expectedStoreDir = "";
+    DeltaSession newSession = mock(DeltaSession.class);
+    DeltaSession existingSession = mock(DeltaSession.class);
+
+    prepareMocksForLoadTest(contextPath, newSession, existingSession, expectedStoreDir);
+
+    when(existingSession.getLastAccessedTime()).thenReturn(2L);
+
+    manager.load();
+
+    verify(newSession, times(0)).activate();
+    verify(manager, times(0)).add(newSession);
+  }
+
+  @Test
+  public void unloadWritesSingleSessionToDiskWhenIdIsValid()
+      throws IOException, NameResolutionException, TypeMismatchException,
+      QueryInvocationTargetException, FunctionDomainException {
+    String sessionId = "sessionId";
+    DeltaSession session = mock(DeltaSession.class);
+    FileOutputStream fos = mock(FileOutputStream.class);
+    BufferedOutputStream bos = mock(BufferedOutputStream.class);
+    ObjectOutputStream oos = mock(ObjectOutputStream.class);
+
+    prepareMocksForUnloadTest(sessionId, fos, bos, oos, session);
+
+    manager.unload();
+
+    verify((StandardSession) session).writeObjectData(oos);
+  }
+
+  @Test
+  public void unloadDoesNotWriteSessionToDiskAndClosesOutputStreamsWhenOutputStreamThrowsIOException()
+      throws IOException, NameResolutionException, TypeMismatchException,
+      QueryInvocationTargetException, FunctionDomainException {
+    String sessionId = "sessionId";
+    DeltaSession session = mock(DeltaSession.class);
+    FileOutputStream fos = mock(FileOutputStream.class);
+    BufferedOutputStream bos = mock(BufferedOutputStream.class);
+    ObjectOutputStream oos = mock(ObjectOutputStream.class);
+
+    prepareMocksForUnloadTest(sessionId, fos, bos, oos, session);
+
+    String exceptionMessage = "Output Stream IOException";
+
+    IOException exception = new IOException(exceptionMessage);
+
+    doThrow(exception).when(manager).getObjectOutputStream(bos);
+
+    assertThatThrownBy(() -> manager.unload()).isInstanceOf(IOException.class)
+        .hasMessage(exceptionMessage);
+
+    verify((StandardSession) session, times(0)).writeObjectData(oos);
+    verify(bos).close();
+    verify(fos).close();
+  }
+
+  @Test
+  public void unloadDoesNotWriteSessionToDiskAndClosesOutputStreamsWhenSessionIsWrongClass()
+      throws IOException, NameResolutionException, TypeMismatchException,
+      QueryInvocationTargetException, FunctionDomainException {
+    String sessionId = "sessionId";
+    DeltaSession session = mock(DeltaSession.class);
+    FileOutputStream fos = mock(FileOutputStream.class);
+    BufferedOutputStream bos = mock(BufferedOutputStream.class);
+    ObjectOutputStream oos = mock(ObjectOutputStream.class);
+
+    prepareMocksForUnloadTest(sessionId, fos, bos, oos, session);
+
+    Session invalidSession =
+        mock(Session.class, withSettings().extraInterfaces(DeltaSessionInterface.class));
+
+    doReturn(invalidSession).when(manager).findSession(sessionId);
+
+    assertThatThrownBy(() -> manager.unload()).isInstanceOf(IOException.class);
+
+    verify((StandardSession) session, times(0)).writeObjectData(oos);
+    verify(oos).close();
+  }
+
+  @Test
   public void successfulUnloadWithClientServerSessionCachePerformsLocalDestroy()
-      throws IOException {
-    when(sessionCache.getCache()).thenReturn(cache);
-    when(context.getPath()).thenReturn("contextPath");
+      throws IOException, NameResolutionException, TypeMismatchException,
+      QueryInvocationTargetException, FunctionDomainException {
+    String sessionId = "sessionId";
+    DeltaSession session = mock(DeltaSession.class);
+    FileOutputStream fos = mock(FileOutputStream.class);
+    BufferedOutputStream bos = mock(BufferedOutputStream.class);
+    ObjectOutputStream oos = mock(ObjectOutputStream.class);
+
+    prepareMocksForUnloadTest(sessionId, fos, bos, oos, session);
+
     when(sessionCache.isClientServer()).thenReturn(true);
+    when(session.getId()).thenReturn(sessionId);
 
     manager.unload();
 
-    verify(operatingRegion).localClear();
+    verify((StandardSession) session).writeObjectData(oos);
+    verify(operatingRegion).localDestroy(sessionId);
   }
 
   @Test
@@ -253,4 +402,70 @@ public abstract class DeltaSessionManagerJUnitTest {
 
     verify(manager).setMaxInactiveInterval(oldValue);
   }
+
+  public void prepareMocksForUnloadTest(String sessionId, FileOutputStream fos,
+      BufferedOutputStream bos, ObjectOutputStream oos, DeltaSession session)
+      throws NameResolutionException, TypeMismatchException, QueryInvocationTargetException,
+      FunctionDomainException, IOException {
+    String regionName = "regionName";
+    String contextPath = "contextPath";
+    String catalinaBaseSystemProp = "Catalina/Base";
+    String systemFileSeparator = "/";
+    String expectedStoreDir = catalinaBaseSystemProp + systemFileSeparator + "temp";
+
+    InternalQueryService queryService = mock(InternalQueryService.class);
+    Query query = mock(Query.class);
+    File store = mock(File.class);
+    SelectResults results = new LinkedResultSet();
+
+    when(sessionCache.getCache()).thenReturn(cache);
+    when(context.getPath()).thenReturn(contextPath);
+    when(cache.getQueryService()).thenReturn(queryService);
+    when(queryService.newQuery(anyString())).thenReturn(query);
+    when(query.execute()).thenReturn(results);
+    doReturn(catalinaBaseSystemProp).when(manager)
+        .getSystemPropertyValue(DeltaSessionManager.catalinaBaseSystemProperty);
+    doReturn(systemFileSeparator).when(manager)
+        .getSystemPropertyValue(DeltaSessionManager.fileSeparatorSystemProperty);
+    doReturn(store).when(manager).getFileAtPath(expectedStoreDir, contextPath);
+    doReturn(fos).when(manager).getFileOutputStream(store);
+    doReturn(bos).when(manager).getBufferedOutputStream(fos);
+    doReturn(oos).when(manager).getObjectOutputStream(bos);
+    doReturn(regionName).when(manager).getRegionName();
+    doReturn(session).when(manager).findSession(sessionId);
+    doNothing().when(manager).writeToObjectOutputStream(any(), any());
+
+    results.add(sessionId);
+  }
+
+  public void prepareMocksForLoadTest(String contextPath, DeltaSession newSession,
+      DeltaSession existingSession, String expectedStoreDir)
+      throws IOException, ClassNotFoundException {
+    String catalinaBaseSystemProp = "Catalina/Base";
+    String systemFileSeparator = "/";
+    expectedStoreDir = catalinaBaseSystemProp + systemFileSeparator + "temp";
+    String newSessionId = "newSessionId";
+
+    File store = mock(File.class);
+    FileInputStream fis = mock(FileInputStream.class);
+    BufferedInputStream bis = mock(BufferedInputStream.class);
+    ObjectInputStream ois = mock(ObjectInputStream.class);
+    Loader loader = mock(Loader.class);
+
+    when(context.getPath()).thenReturn(contextPath);
+    when(context.getLoader()).thenReturn(loader);
+    when(newSession.getId()).thenReturn(newSessionId);
+    when(newSession.getLastAccessedTime()).thenReturn(1L);
+    when(newSession.isValid()).thenReturn(true);
+    when(existingSession.getLastAccessedTime()).thenReturn(0L);
+    doReturn(catalinaBaseSystemProp).when(manager).getSystemPropertyValue("catalina.base");
+    doReturn(systemFileSeparator).when(manager).getSystemPropertyValue("file.separator");
+    doReturn(store).when(manager).getFileAtPath(expectedStoreDir, contextPath);
+    doReturn(fis).when(manager).getFileInputStream(store);
+    doReturn(bis).when(manager).getBufferedInputStream(fis);
+    doReturn(ois).when(manager).getObjectInputStream(bis);
+    doReturn(1).when(manager).getSessionCountFromObjectInputStream(ois);
+    doReturn(newSession).when(manager).getNewSession();
+    doReturn(existingSession).when(operatingRegion).get(newSessionId);
+  }
 }
diff --git a/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/DeltaSessionManager.java b/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/DeltaSessionManager.java
index 0c6f1fd..e8fb0e2 100644
--- a/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/DeltaSessionManager.java
+++ b/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/DeltaSessionManager.java
@@ -16,10 +16,20 @@ package org.apache.geode.modules.session.catalina;
 
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
 import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashSet;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Set;
 import java.util.Timer;
 import java.util.TimerTask;
@@ -30,16 +40,23 @@ import java.util.concurrent.atomic.AtomicInteger;
 import org.apache.catalina.Container;
 import org.apache.catalina.Context;
 import org.apache.catalina.Lifecycle;
+import org.apache.catalina.Loader;
 import org.apache.catalina.Pipeline;
 import org.apache.catalina.Session;
 import org.apache.catalina.Valve;
 import org.apache.catalina.session.ManagerBase;
 import org.apache.catalina.session.StandardSession;
+import org.apache.catalina.util.CustomObjectInputStream;
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
 
 import org.apache.geode.cache.Cache;
 import org.apache.geode.cache.CacheFactory;
+import org.apache.geode.cache.EntryNotFoundException;
+import org.apache.geode.cache.Region;
+import org.apache.geode.cache.query.Query;
+import org.apache.geode.cache.query.QueryService;
+import org.apache.geode.cache.query.SelectResults;
 import org.apache.geode.internal.cache.GemFireCacheImpl;
 import org.apache.geode.modules.session.catalina.internal.DeltaSessionStatistics;
 import org.apache.geode.modules.util.ContextMapper;
@@ -553,12 +570,13 @@ public abstract class DeltaSessionManager extends ManagerBase
 
   @Override
   public void load() throws ClassNotFoundException, IOException {
+    doLoad();
     ContextMapper.addContext(getContextName(), this);
   }
 
   @Override
   public void unload() throws IOException {
-    clearLocalCache();
+    doUnload();
     ContextMapper.removeContext(getContextName());
   }
 
@@ -654,22 +672,340 @@ public abstract class DeltaSessionManager extends ManagerBase
   }
 
   /**
-   * Clear the local cache to avoid ClassCastException if container is being reloaded.
+   * Save any currently active sessions in the appropriate persistence mechanism, if any. If
+   * persistence is not supported, this method returns without doing anything.
+   *
+   * @throws IOException if an input/output error occurs
    */
-  private void clearLocalCache() {
-    final Log logger = getLogger();
-    final boolean debugEnabled = logger.isDebugEnabled();
+  private void doUnload() throws IOException {
+    QueryService querySvc = getSessionCache().getCache().getQueryService();
+    Context context = getTheContext();
+
+    if (context == null) {
+      return;
+    }
+
+    String regionName;
+    if (getRegionName().startsWith("/")) {
+      regionName = getRegionName();
+    } else {
+      regionName = "/" + getRegionName();
+    }
+
+    Query query = querySvc.newQuery("select s.id from " + regionName
+        + " as s where s.contextName = '" + context.getPath() + "'");
+
+    if (getLogger().isDebugEnabled()) {
+      getLogger().debug("Query: " + query.getQueryString());
+    }
+
+    SelectResults results;
+    try {
+      results = (SelectResults) query.execute();
+    } catch (Exception ex) {
+      getLogger().error("Unable to perform query during doUnload", ex);
+      return;
+    }
+
+    if (results.isEmpty()) {
+      getLogger().debug("No sessions to unload for context " + context.getPath());
+      return; // nothing to do
+    }
+
+    // Open an output stream to the specified pathname, if any
+    File store = sessionStore(context.getPath());
+    if (store == null) {
+      return;
+    }
+    if (getLogger().isDebugEnabled()) {
+      getLogger().debug("Unloading sessions to " + store.getAbsolutePath());
+    }
+    FileOutputStream fos = null;
+    BufferedOutputStream bos = null;
+    ObjectOutputStream oos = null;
+    boolean error = false;
+    try {
+      fos = getFileOutputStream(store);
+      bos = getBufferedOutputStream(fos);
+      oos = getObjectOutputStream(bos);
+    } catch (IOException e) {
+      error = true;
+      getLogger().error("Exception unloading sessions", e);
+      throw e;
+    } finally {
+      if (error) {
+        if (oos != null) {
+          try {
+            oos.close();
+          } catch (IOException ioe) {
+            // Ignore
+          }
+        }
+        if (bos != null) {
+          try {
+            bos.close();
+          } catch (IOException ioe) {
+            // Ignore
+          }
+        }
+        if (fos != null) {
+          try {
+            fos.close();
+          } catch (IOException ioe) {
+            // Ignore
+          }
+        }
+      }
+    }
+
+    ArrayList<DeltaSessionInterface> list = new ArrayList<>();
+    @SuppressWarnings("unchecked")
+    Iterator<String> elements = (Iterator<String>) results.iterator();
+    while (elements.hasNext()) {
+      String id = elements.next();
+      DeltaSessionInterface session = (DeltaSessionInterface) findSession(id);
+      if (session != null) {
+        list.add(session);
+      }
+    }
+
+    // Write the number of active sessions, followed by the details
+    if (getLogger().isDebugEnabled())
+      getLogger().debug("Unloading " + list.size() + " sessions");
+    try {
+      writeToObjectOutputStream(oos, list);
+      for (DeltaSessionInterface session : list) {
+        if (session instanceof StandardSession) {
+          StandardSession standardSession = (StandardSession) session;
+          standardSession.passivate();
+          standardSession.writeObjectData(oos);
+        } else {
+          // All DeltaSessionInterfaces as of Geode 1.0 should be based on StandardSession
+          throw new IOException("Session should be of type StandardSession");
+        }
+      }
+    } catch (IOException e) {
+      getLogger().error("Exception unloading sessions", e);
+      try {
+        oos.close();
+      } catch (IOException f) {
+        // Ignore
+      }
+      throw e;
+    }
 
+    // Flush and close the output stream
+    try {
+      oos.flush();
+    } finally {
+      try {
+        oos.close();
+      } catch (IOException f) {
+        // Ignore
+      }
+    }
+
+    // Locally destroy the sessions we just wrote
     if (getSessionCache().isClientServer()) {
-      if (debugEnabled) {
-        logger.debug("Locally clearing sessions.");
+      for (DeltaSessionInterface session : list) {
+        if (getLogger().isDebugEnabled()) {
+          getLogger().debug("Locally destroying session " + session.getId());
+        }
+        try {
+          getSessionCache().getOperatingRegion().localDestroy(session.getId());
+        } catch (EntryNotFoundException ex) {
+          // This can be thrown if an entry is evicted during or immediately after a session is
+          // written
+          // to disk. This isn't a problem, but the resulting exception messages can be confusing in
+          // testing
+        }
       }
-      getSessionCache().getOperatingRegion().localClear();
     }
 
-    if (debugEnabled) {
-      logger.debug("Unloading complete");
+    if (getLogger().isDebugEnabled()) {
+      getLogger().debug("Unloading complete");
+    }
+  }
+
+  /**
+   * Load any currently active sessions that were previously unloaded to the appropriate persistence
+   * mechanism, if any. If persistence is not supported, this method returns without doing anything.
+   *
+   * @throws ClassNotFoundException if a serialized class cannot be found during the reload
+   * @throws IOException if an input/output error occurs
+   */
+  private void doLoad() throws ClassNotFoundException, IOException {
+    Context context = getTheContext();
+    if (context == null) {
+      return;
     }
+
+    // Open an input stream to the specified pathname, if any
+    File store = sessionStore(context.getPath());
+    if (store == null) {
+      getLogger().debug("No session store file found");
+      return;
+    }
+    if (getLogger().isDebugEnabled()) {
+      getLogger().debug("Loading sessions from " + store.getAbsolutePath());
+    }
+    FileInputStream fis = null;
+    BufferedInputStream bis = null;
+    ObjectInputStream ois;
+    Loader loader = null;
+    ClassLoader classLoader = null;
+    try {
+      fis = getFileInputStream(store);
+      bis = getBufferedInputStream(fis);
+      if (getTheContext() != null) {
+        loader = getTheContext().getLoader();
+      }
+      if (loader != null) {
+        classLoader = loader.getClassLoader();
+      }
+      if (classLoader != null) {
+        if (getLogger().isDebugEnabled()) {
+          getLogger().debug("Creating custom object input stream for class loader");
+        }
+        ois = new CustomObjectInputStream(bis, classLoader);
+      } else {
+        if (getLogger().isDebugEnabled()) {
+          getLogger().debug("Creating standard object input stream");
+        }
+        ois = getObjectInputStream(bis);
+      }
+    } catch (FileNotFoundException e) {
+      if (getLogger().isDebugEnabled()) {
+        getLogger().debug("No persisted data file found");
+      }
+      return;
+    } catch (IOException e) {
+      getLogger().error("Exception loading sessions", e);
+      try {
+        fis.close();
+      } catch (IOException f) {
+        // Ignore
+      }
+      try {
+        bis.close();
+      } catch (IOException f) {
+        // Ignore
+      }
+      throw e;
+    }
+
+    // Load the previously unloaded active sessions
+    try {
+      int n = getSessionCountFromObjectInputStream(ois);
+      if (getLogger().isDebugEnabled()) {
+        getLogger().debug("Loading " + n + " persisted sessions");
+      }
+      for (int i = 0; i < n; i++) {
+        StandardSession session = getNewSession();
+        session.readObjectData(ois);
+        session.setManager(this);
+
+        Region region = getSessionCache().getOperatingRegion();
+        DeltaSessionInterface existingSession = (DeltaSessionInterface) region.get(session.getId());
+        // Check whether the existing session is newer
+        if (existingSession != null
+            && existingSession.getLastAccessedTime() > session.getLastAccessedTime()) {
+          if (getLogger().isDebugEnabled()) {
+            getLogger().debug("Loaded session " + session.getId() + " is older than cached copy");
+          }
+          continue;
+        }
+
+        // Check whether the new session has already expired
+        if (!session.isValid()) {
+          if (getLogger().isDebugEnabled()) {
+            getLogger().debug("Loaded session " + session.getId() + " is invalid");
+          }
+          continue;
+        }
+
+        getLogger().debug("Loading session " + session.getId());
+        session.activate();
+        add(session);
+      }
+    } catch (ClassNotFoundException | IOException e) {
+      getLogger().error(e);
+      try {
+        ois.close();
+      } catch (IOException f) {
+        // Ignore
+      }
+      throw e;
+    } finally {
+      // Close the input stream
+      try {
+        ois.close();
+      } catch (IOException f) {
+        // ignored
+      }
+
+      // Delete the persistent storage file
+      if (store.exists()) {
+        if (!store.delete()) {
+          getLogger().warn("Couldn't delete persistent storage file " + store.getAbsolutePath());
+        }
+      }
+    }
+  }
+
+  /**
+   * Return a File object representing the pathname to our persistence file, if any.
+   */
+  private File sessionStore(String ctxPath) {
+    String storeDir = getSystemPropertyValue(catalinaBaseSystemProperty);
+    if (storeDir == null || storeDir.isEmpty()) {
+      storeDir = getSystemPropertyValue(javaTempDirSystemProperty);
+    } else {
+      storeDir += getSystemPropertyValue(fileSeparatorSystemProperty) + "temp";
+    }
+
+    return getFileAtPath(storeDir, ctxPath);
+  }
+
+  String getSystemPropertyValue(String propertyKey) {
+    return System.getProperty(propertyKey);
+  }
+
+  File getFileAtPath(String storeDir, String ctxPath) {
+    return (new File(storeDir, ctxPath.replaceAll("/", "_") + ".sessions.ser"));
+  }
+
+  FileInputStream getFileInputStream(File file) throws FileNotFoundException {
+    return new FileInputStream(file.getAbsolutePath());
+  }
+
+  BufferedInputStream getBufferedInputStream(FileInputStream fis) {
+    return new BufferedInputStream(fis);
+  }
+
+  ObjectInputStream getObjectInputStream(BufferedInputStream bis) throws IOException {
+    return new ObjectInputStream(bis);
+  }
+
+  FileOutputStream getFileOutputStream(File file) throws FileNotFoundException {
+    return new FileOutputStream(file.getAbsolutePath());
+  }
+
+  BufferedOutputStream getBufferedOutputStream(FileOutputStream fos) {
+    return new BufferedOutputStream(fos);
+  }
+
+  ObjectOutputStream getObjectOutputStream(BufferedOutputStream bos) throws IOException {
+    return new ObjectOutputStream(bos);
+  }
+
+  void writeToObjectOutputStream(ObjectOutputStream oos, List listToWrite) throws IOException {
+    oos.writeObject(listToWrite.size());
+  }
+
+  int getSessionCountFromObjectInputStream(ObjectInputStream ois)
+      throws IOException, ClassNotFoundException {
+    return (Integer) ois.readObject();
   }
 
   @Override

[geode] 11/11: GEODE-8781: Added ReconnectListener to PeerToPeerSessionCache

Posted by sa...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

sabbey37 pushed a commit to branch support/1.13
in repository https://gitbox.apache.org/repos/asf/geode.git

commit 31d2613189f623373fb997e88af9fca7746c2a0f
Author: Barry Oglesby <bo...@users.noreply.github.com>
AuthorDate: Mon Dec 14 12:07:45 2020 -0800

    GEODE-8781: Added ReconnectListener to PeerToPeerSessionCache
    
    (cherry picked from commit bda0d3fbf13ebdf37db8d710cf7f4d4b892a1646)
---
 .../modules/session/catalina/DeltaSessionManager.java |  6 +++++-
 .../session/catalina/PeerToPeerSessionCache.java      | 19 +++++++++++++++++++
 2 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/DeltaSessionManager.java b/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/DeltaSessionManager.java
index a42b0d8..997c424 100644
--- a/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/DeltaSessionManager.java
+++ b/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/DeltaSessionManager.java
@@ -551,7 +551,11 @@ public abstract class DeltaSessionManager<CommitSessionValveT extends AbstractCo
     TimerTask task = new TimerTask() {
       @Override
       public void run() {
-        int currentActiveSessions = getSessionCache().size();
+        int currentActiveSessions = 0;
+        try {
+          currentActiveSessions = getSessionCache().size();
+        } catch (Exception ignore) {
+        }
         if (currentActiveSessions > getMaxActive()) {
           setMaxActive(currentActiveSessions);
           if (getLogger().isDebugEnabled()) {
diff --git a/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/PeerToPeerSessionCache.java b/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/PeerToPeerSessionCache.java
index d5031c1..04e197d 100644
--- a/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/PeerToPeerSessionCache.java
+++ b/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/PeerToPeerSessionCache.java
@@ -27,6 +27,8 @@ import org.apache.geode.cache.execute.Execution;
 import org.apache.geode.cache.execute.Function;
 import org.apache.geode.cache.execute.FunctionService;
 import org.apache.geode.cache.execute.ResultCollector;
+import org.apache.geode.distributed.internal.InternalDistributedSystem;
+import org.apache.geode.internal.cache.InternalCache;
 import org.apache.geode.modules.session.catalina.callback.LocalSessionCacheLoader;
 import org.apache.geode.modules.session.catalina.callback.LocalSessionCacheWriter;
 import org.apache.geode.modules.session.catalina.callback.SessionExpirationCacheListener;
@@ -47,6 +49,7 @@ public class PeerToPeerSessionCache extends AbstractSessionCache {
   public PeerToPeerSessionCache(SessionManager sessionManager, Cache cache) {
     super(sessionManager);
     this.cache = cache;
+    addReconnectListener();
   }
 
   @Override
@@ -242,4 +245,20 @@ public class PeerToPeerSessionCache extends AbstractSessionCache {
   Execution getExecutionForFunctionOnMembersWithArguments(Object[] arguments) {
     return FunctionService.onMembers().setArguments(arguments);
   }
+
+  private void addReconnectListener() {
+    InternalDistributedSystem.addReconnectListener(
+        new InternalDistributedSystem.ReconnectListener() {
+          @Override
+          public void onReconnect(InternalDistributedSystem oldSystem,
+              InternalDistributedSystem newSystem) {
+            reinitialize(newSystem.getCache());
+          }
+        });
+  }
+
+  private void reinitialize(InternalCache reconnectedCache) {
+    this.cache = reconnectedCache;
+    initialize();
+  }
 }

[geode] 08/11: GEODE-8217: Deserialize attribute before update and remove. (#5256)

Posted by sa...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

sabbey37 pushed a commit to branch support/1.13
in repository https://gitbox.apache.org/repos/asf/geode.git

commit 7095050b299886ea07f8587668d814b10187375a
Author: Jacob Barrett <jb...@pivotal.io>
AuthorDate: Thu Jun 25 13:57:17 2020 -0700

    GEODE-8217: Deserialize attribute before update and remove. (#5256)
    
    When preferDeserializedForm is true we deserialize the previous attributes before update or remove.
    
    Deprecates preferDeserializedForm since when false it's unclear when you will get serialized or unserialized forms of attributes.
    
    (cherry picked from commit 9cc61bf2c0cb91f1a6b551fef6984214e23730e2)
---
 .../AbstractDeltaSessionIntegrationTest.java       | 110 +++++++
 .../catalina/AbstractDeltaSessionManagerTest.java  |   4 +-
 .../catalina/AbstractDeltaSessionTest.java}        |  57 ++--
 .../session/catalina/DeltaSession7Test.java}       |  25 +-
 .../session/catalina/DeltaSession7Test.java        | 147 +++++++++
 .../catalina/Tomcat7DeltaSessionManagerTest.java   |   3 +-
 .../session/catalina/DeltaSession8Test.java}       |  25 +-
 .../session/catalina/DeltaSession8Test.java        | 147 +++++++++
 .../catalina/Tomcat8DeltaSessionManagerTest.java   |   3 +-
 .../session/catalina/DeltaSession9Test.java}       |  23 +-
 .../session/catalina/DeltaSession9Test.java        | 147 +++++++++
 .../catalina/Tomcat9DeltaSessionManagerTest.java   |   3 +-
 .../modules/session/catalina/DeltaSession.java     | 346 ++++++++++++---------
 .../session/catalina/DeltaSessionManager.java      | 163 +++++-----
 ....java => DeltaSessionManagerConfiguration.java} |  46 ++-
 .../session/catalina/JvmRouteBinderValve.java      |  10 +-
 .../modules/session/catalina/SessionManager.java   |   4 +
 .../catalina/Tomcat6CommitSessionValve.java        |   3 +-
 .../callback/SessionExpirationCacheListener.java   |   2 +-
 .../session/AccessAttributeValueListener.java}     |  20 +-
 .../src/main/webapp/WEB-INF/web.xml                |   4 +
 .../apache/geode/session/tests/CargoTestBase.java  |  41 ++-
 .../org/apache/geode/session/tests/LogChecker.java | 126 ++++++++
 23 files changed, 1156 insertions(+), 303 deletions(-)

diff --git a/extensions/geode-modules-test/src/main/java/org/apache/geode/modules/session/catalina/AbstractDeltaSessionIntegrationTest.java b/extensions/geode-modules-test/src/main/java/org/apache/geode/modules/session/catalina/AbstractDeltaSessionIntegrationTest.java
new file mode 100644
index 0000000..5008b17
--- /dev/null
+++ b/extensions/geode-modules-test/src/main/java/org/apache/geode/modules/session/catalina/AbstractDeltaSessionIntegrationTest.java
@@ -0,0 +1,110 @@
+/*
+ * 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.cache.RegionShortcut.PARTITION;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyNoMoreInteractions;
+import static org.mockito.Mockito.when;
+
+import java.io.IOException;
+
+import javax.servlet.http.HttpSession;
+import javax.servlet.http.HttpSessionAttributeListener;
+import javax.servlet.http.HttpSessionBindingEvent;
+
+import org.apache.catalina.Context;
+import org.apache.juli.logging.Log;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.mockito.ArgumentCaptor;
+
+import org.apache.geode.cache.Region;
+import org.apache.geode.internal.util.BlobHelper;
+import org.apache.geode.modules.session.catalina.callback.SessionExpirationCacheListener;
+import org.apache.geode.modules.session.catalina.internal.DeltaSessionStatistics;
+import org.apache.geode.test.junit.rules.ServerStarterRule;
+
+public abstract class AbstractDeltaSessionIntegrationTest<DeltaSessionManagerT extends DeltaSessionManager<?>, DeltaSessionT extends DeltaSession> {
+  protected static final String KEY = "key1";
+  protected static final String REGION_NAME = "sessions";
+
+  protected Region<String, HttpSession> region;
+  protected final DeltaSessionManagerT manager;
+  protected final Context context = mock(Context.class);
+
+  @Rule
+  public ServerStarterRule server = new ServerStarterRule().withAutoStart();
+
+  protected AbstractDeltaSessionIntegrationTest(final DeltaSessionManagerT manager) {
+    this.manager = manager;
+  }
+
+  @Before
+  public void before() {
+    region = server.getCache()
+        .<String, HttpSession>createRegionFactory(PARTITION)
+        .addCacheListener(new SessionExpirationCacheListener())
+        .create(REGION_NAME);
+
+    when(manager.getLogger()).thenReturn(mock(Log.class));
+    when(manager.getRegionName()).thenReturn(REGION_NAME);
+    when(manager.getSessionCache()).thenReturn(mock(SessionCache.class));
+    when(manager.getSessionCache().getOperatingRegion()).thenReturn(region);
+    whenGetPreferDeserializedForm(manager);
+
+    final DeltaSessionStatistics stats = mock(DeltaSessionStatistics.class);
+    when(manager.getStatistics()).thenReturn(stats);
+  }
+
+  @SuppressWarnings("deprecation")
+  private void whenGetPreferDeserializedForm(DeltaSessionManager<?> manager) {
+    when(manager.getPreferDeserializedForm()).thenReturn(true);
+  }
+
+  protected abstract DeltaSessionT newSession(final DeltaSessionManagerT manager);
+
+  @Test
+  public void serializedAttributesNotLeakedWhenSessionInvalidated() throws IOException {
+    final HttpSessionAttributeListener listener = mock(HttpSessionAttributeListener.class);
+    when(context.getApplicationEventListeners()).thenReturn(new Object[] {listener});
+
+    final DeltaSessionT session = spy(newSession(manager));
+    session.setId(KEY, false);
+    session.setValid(true);
+    session.setOwner(manager);
+
+    final String name = "attribute";
+    final Object value1 = "value1";
+    final byte[] serializedValue1 = BlobHelper.serializeToBlob(value1);
+    // simulates initial deserialized state with serialized attribute values.
+    session.getAttributes().put(name, serializedValue1);
+
+    region.put(session.getId(), session);
+
+    session.invalidate();
+
+    final ArgumentCaptor<HttpSessionBindingEvent> event =
+        ArgumentCaptor.forClass(HttpSessionBindingEvent.class);
+    verify(listener).attributeRemoved(event.capture());
+    verifyNoMoreInteractions(listener);
+    assertThat(event.getValue().getValue()).isEqualTo(value1);
+  }
+}
diff --git a/extensions/geode-modules-test/src/main/java/org/apache/geode/modules/session/catalina/AbstractDeltaSessionManagerTest.java b/extensions/geode-modules-test/src/main/java/org/apache/geode/modules/session/catalina/AbstractDeltaSessionManagerTest.java
index ff976b1..d5fea45 100644
--- a/extensions/geode-modules-test/src/main/java/org/apache/geode/modules/session/catalina/AbstractDeltaSessionManagerTest.java
+++ b/extensions/geode-modules-test/src/main/java/org/apache/geode/modules/session/catalina/AbstractDeltaSessionManagerTest.java
@@ -64,9 +64,9 @@ import org.apache.geode.cache.query.internal.LinkedResultSet;
 import org.apache.geode.internal.cache.GemFireCacheImpl;
 import org.apache.geode.modules.session.catalina.internal.DeltaSessionStatistics;
 
-public abstract class AbstractDeltaSessionManagerTest {
+public abstract class AbstractDeltaSessionManagerTest<DeltaSessionManagerT extends DeltaSessionManager<?>> {
 
-  protected DeltaSessionManager manager;
+  protected DeltaSessionManagerT manager;
   protected AbstractSessionCache sessionCache;
   protected Cache cache;
   protected Log logger;
diff --git a/extensions/geode-modules/src/test/java/org/apache/geode/modules/session/catalina/DeltaSessionTest.java b/extensions/geode-modules-test/src/main/java/org/apache/geode/modules/session/catalina/AbstractDeltaSessionTest.java
similarity index 79%
rename from extensions/geode-modules/src/test/java/org/apache/geode/modules/session/catalina/DeltaSessionTest.java
rename to extensions/geode-modules-test/src/main/java/org/apache/geode/modules/session/catalina/AbstractDeltaSessionTest.java
index fc0c159..1d0fc94 100644
--- a/extensions/geode-modules/src/test/java/org/apache/geode/modules/session/catalina/DeltaSessionTest.java
+++ b/extensions/geode-modules-test/src/main/java/org/apache/geode/modules/session/catalina/AbstractDeltaSessionTest.java
@@ -15,6 +15,7 @@
 
 package org.apache.geode.modules.session.catalina;
 
+import static org.apache.geode.util.internal.UncheckedUtils.uncheckedCast;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
 import static org.mockito.ArgumentMatchers.any;
@@ -46,23 +47,24 @@ import org.apache.geode.internal.util.BlobHelper;
 import org.apache.geode.modules.session.catalina.internal.DeltaSessionAttributeEvent;
 import org.apache.geode.modules.session.catalina.internal.DeltaSessionStatistics;
 
-public class DeltaSessionTest {
+public abstract class AbstractDeltaSessionTest<SessionT extends DeltaSession> {
 
-  private final DeltaSessionManager manager = mock(DeltaSessionManager.class);
-  private final Region<String, HttpSession> sessionRegion = mock(Region.class);
+  protected final DeltaSessionManager<?> manager = mock(DeltaSessionManager.class);
+  private final Region<String, HttpSession> sessionRegion = uncheckedCast(mock(Region.class));
   private final SessionCache sessionCache = mock(ClientServerSessionCache.class);
-  DeltaSessionStatistics stats = mock(DeltaSessionStatistics.class);
-  private final String sessionRegionName = "sessionRegionName";
-  private final String contextName = "contextName";
+  private final DeltaSessionStatistics stats = mock(DeltaSessionStatistics.class);
   private final Log logger = mock(Log.class);
 
   @Before
   public void setup() {
+    String sessionRegionName = "sessionRegionName";
     when(manager.getRegionName()).thenReturn(sessionRegionName);
     when(manager.getSessionCache()).thenReturn(sessionCache);
     when(manager.getLogger()).thenReturn(logger);
-    when(manager.getContextName()).thenReturn(contextName);
+    when(manager.getContextName()).thenReturn("contextName");
     when(manager.getStatistics()).thenReturn(stats);
+    when(manager.isBackingCacheAvailable()).thenReturn(true);
+    setupDeprecated();
     // For Client/Server behavior and some PeerToPeer use cases the session region and operating
     // regions
     // will be the same.
@@ -70,25 +72,31 @@ public class DeltaSessionTest {
     when(logger.isDebugEnabled()).thenReturn(true);
   }
 
+  @SuppressWarnings("deprecation")
+  protected void setupDeprecated() {
+    when(manager.getPreferDeserializedForm()).thenReturn(true);
+  }
+
+  protected abstract SessionT newDeltaSession(Manager manager);
+
   @Test
   public void sessionConstructionThrowsIllegalArgumentExceptionIfProvidedManagerIsNotDeltaSessionManager() {
     final Manager invalidManager = mock(Manager.class);
 
-    assertThatThrownBy(() -> new DeltaSession(invalidManager))
+    assertThatThrownBy(() -> newDeltaSession(invalidManager))
         .isInstanceOf(IllegalArgumentException.class)
         .hasMessageContaining("The Manager must be an AbstractManager");
   }
 
   @Test
   public void sessionConstructionDoesNotThrowExceptionWithValidArgument() {
-    final DeltaSession session = new DeltaSession(manager);
-
+    newDeltaSession(manager);
     verify(logger).debug(anyString());
   }
 
   @Test
   public void getSessionCreatesFacadeWhenFacadeIsNullAndPackageProtectionDisabled() {
-    final DeltaSession session = new DeltaSession(manager);
+    final DeltaSession session = newDeltaSession(manager);
 
     final HttpSession returnedSession = session.getSession();
 
@@ -97,7 +105,7 @@ public class DeltaSessionTest {
 
   @Test
   public void getSessionCreatesFacadeWhenFacadeIsNullAndPackageProtectionEnabled() {
-    final DeltaSession session = spy(new DeltaSession(manager));
+    final DeltaSession session = spy(newDeltaSession(manager));
     final DeltaSessionFacade facade = mock(DeltaSessionFacade.class);
     doReturn(true).when(session).isPackageProtectionEnabled();
     doReturn(facade).when(session).getNewFacade(any(DeltaSession.class));
@@ -109,7 +117,7 @@ public class DeltaSessionTest {
 
   @Test
   public void processExpiredIncrementsStatisticsCountForExpiredSessions() {
-    final DeltaSession session = spy(new DeltaSession(manager));
+    final DeltaSession session = spy(newDeltaSession(manager));
 
     doNothing().when((StandardSession) session).expire(false);
     session.processExpired();
@@ -124,8 +132,8 @@ public class DeltaSessionTest {
     final List<DeltaSessionAttributeEvent> events = new ArrayList<>();
     events.add(event1);
     events.add(event2);
-    final Region<String, DeltaSessionInterface> region = mock(Region.class);
-    final DeltaSession session = spy(new DeltaSession(manager));
+    final Region<String, DeltaSessionInterface> region = uncheckedCast(mock(Region.class));
+    final DeltaSession session = spy(newDeltaSession(manager));
 
     session.applyAttributeEvents(region, events);
 
@@ -139,11 +147,11 @@ public class DeltaSessionTest {
 
   @Test
   public void commitThrowsIllegalStateExceptionWhenCalledOnInvalidSession() {
-    final DeltaSession session = spy(new DeltaSession(manager));
+    final DeltaSession session = spy(newDeltaSession(manager));
     final String sessionId = "invalidatedSession";
     doReturn(sessionId).when(session).getId();
 
-    assertThatThrownBy(() -> session.commit()).isInstanceOf(IllegalStateException.class)
+    assertThatThrownBy(session::commit).isInstanceOf(IllegalStateException.class)
         .hasMessage("commit: Session " + sessionId + " already invalidated");
   }
 
@@ -151,7 +159,7 @@ public class DeltaSessionTest {
   public void getSizeInBytesReturnsProperValueForMultipleAttributes() {
     final String attrName1 = "attrName1";
     final String attrName2 = "attrName2";
-    final List attrList = new ArrayList<String>();
+    final List<String> attrList = new ArrayList<>();
     attrList.add(attrName1);
     attrList.add(attrName2);
 
@@ -161,7 +169,7 @@ public class DeltaSessionTest {
     final byte[] value2 = {0, 0, 0, 0, 0};
     final int totalSize = value1.length + value2.length;
 
-    final DeltaSession session = spy(new DeltaSession(manager));
+    final DeltaSession session = spy(newDeltaSession(manager));
     doReturn(attrNames).when(session).getAttributeNames();
     doReturn(value1).when(session).getAttributeWithoutDeserialize(attrName1);
     doReturn(value2).when(session).getAttributeWithoutDeserialize(attrName2);
@@ -177,7 +185,7 @@ public class DeltaSessionTest {
     final String exceptionMessaage = "Serialization failed.";
     final IOException exception = new IOException(exceptionMessaage);
 
-    final DeltaSession session = spy(new DeltaSession(manager));
+    final DeltaSession session = spy(newDeltaSession(manager));
     doThrow(exception).when(session).serializeViaBlobHelper(obj);
     session.serialize(obj);
 
@@ -189,17 +197,10 @@ public class DeltaSessionTest {
     final Object obj = "unserialized object";
     final byte[] serializedObj = BlobHelper.serializeToBlob(obj);
 
-    final DeltaSession session = spy(new DeltaSession(manager));
+    final DeltaSession session = spy(newDeltaSession(manager));
     final byte[] result = session.serialize(obj);
 
     assertThat(result).isEqualTo(serializedObj);
   }
 
-  // @Test
-  // public void testToData() throws IOException {
-  // DeltaSession session = spy(new DeltaSession(manager));
-  // DataOutput out = mock(DataOutput.class);
-  //
-  // session.toData(out);
-  // }
 }
diff --git a/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/Tomcat6CommitSessionValve.java b/extensions/geode-modules-tomcat7/src/integrationTest/java/org/apache/geode/modules/session/catalina/DeltaSession7Test.java
similarity index 62%
copy from extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/Tomcat6CommitSessionValve.java
copy to extensions/geode-modules-tomcat7/src/integrationTest/java/org/apache/geode/modules/session/catalina/DeltaSession7Test.java
index b27fe65..7af5a91 100644
--- a/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/Tomcat6CommitSessionValve.java
+++ b/extensions/geode-modules-tomcat7/src/integrationTest/java/org/apache/geode/modules/session/catalina/DeltaSession7Test.java
@@ -12,16 +12,29 @@
  * or implied. See the License for the specific language governing permissions and limitations under
  * the License.
  */
-
 package org.apache.geode.modules.session.catalina;
 
-import org.apache.catalina.connector.Response;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+
 
-@Deprecated
-public final class Tomcat6CommitSessionValve extends AbstractCommitSessionValve {
+public class DeltaSession7Test
+    extends AbstractDeltaSessionIntegrationTest<Tomcat7DeltaSessionManager, DeltaSession7> {
+
+  public DeltaSession7Test() {
+    super(mock(Tomcat7DeltaSessionManager.class));
+  }
 
   @Override
-  protected Response wrapResponse(Response response) {
-    return response;
+  public void before() {
+    super.before();
+    when(manager.getContainer()).thenReturn(context);
   }
+
+  @Override
+  protected DeltaSession7 newSession(Tomcat7DeltaSessionManager manager) {
+    return new DeltaSession7(manager);
+  }
+
 }
diff --git a/extensions/geode-modules-tomcat7/src/test/java/org/apache/geode/modules/session/catalina/DeltaSession7Test.java b/extensions/geode-modules-tomcat7/src/test/java/org/apache/geode/modules/session/catalina/DeltaSession7Test.java
new file mode 100644
index 0000000..dd53c9c
--- /dev/null
+++ b/extensions/geode-modules-tomcat7/src/test/java/org/apache/geode/modules/session/catalina/DeltaSession7Test.java
@@ -0,0 +1,147 @@
+/*
+ * 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.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyNoMoreInteractions;
+import static org.mockito.Mockito.when;
+
+import java.io.IOException;
+
+import javax.servlet.http.HttpSessionAttributeListener;
+import javax.servlet.http.HttpSessionBindingEvent;
+
+import org.apache.catalina.Context;
+import org.apache.catalina.Manager;
+import org.apache.juli.logging.Log;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.ArgumentCaptor;
+
+import org.apache.geode.internal.util.BlobHelper;
+
+public class DeltaSession7Test extends AbstractDeltaSessionTest<DeltaSession7> {
+  final HttpSessionAttributeListener listener = mock(HttpSessionAttributeListener.class);
+
+  @Before
+  @Override
+  public void setup() {
+    super.setup();
+
+    final Context context = mock(Context.class);
+    when(manager.getContainer()).thenReturn(context);
+    when(context.getApplicationEventListeners()).thenReturn(new Object[] {listener});
+    when(context.getLogger()).thenReturn(mock(Log.class));
+  }
+
+  @Override
+  protected DeltaSession7 newDeltaSession(Manager manager) {
+    return new DeltaSession7(manager);
+  }
+
+  @Test
+  public void serializedAttributesNotLeakedInAttributeReplaceEvent() throws IOException {
+    final DeltaSession7 session = spy(new DeltaSession7(manager));
+    session.setValid(true);
+    final String name = "attribute";
+    final Object value1 = "value1";
+    final byte[] serializedValue1 = BlobHelper.serializeToBlob(value1);
+    // simulates initial deserialized state with serialized attribute values.
+    session.getAttributes().put(name, serializedValue1);
+
+    final Object value2 = "value2";
+    session.setAttribute(name, value2);
+
+    final ArgumentCaptor<HttpSessionBindingEvent> event =
+        ArgumentCaptor.forClass(HttpSessionBindingEvent.class);
+    verify(listener).attributeReplaced(event.capture());
+    verifyNoMoreInteractions(listener);
+    assertThat(event.getValue().getValue()).isEqualTo(value1);
+  }
+
+  @Test
+  public void serializedAttributesNotLeakedInAttributeRemovedEvent() throws IOException {
+    final DeltaSession7 session = spy(new DeltaSession7(manager));
+    session.setValid(true);
+    final String name = "attribute";
+    final Object value1 = "value1";
+    final byte[] serializedValue1 = BlobHelper.serializeToBlob(value1);
+    // simulates initial deserialized state with serialized attribute values.
+    session.getAttributes().put(name, serializedValue1);
+
+    session.removeAttribute(name);
+
+    final ArgumentCaptor<HttpSessionBindingEvent> event =
+        ArgumentCaptor.forClass(HttpSessionBindingEvent.class);
+    verify(listener).attributeRemoved(event.capture());
+    verifyNoMoreInteractions(listener);
+    assertThat(event.getValue().getValue()).isEqualTo(value1);
+  }
+
+  @Test
+  public void serializedAttributesLeakedInAttributeReplaceEventWhenPreferDeserializedFormFalse()
+      throws IOException {
+    setPreferDeserializedFormFalse();
+
+    final DeltaSession7 session = spy(new DeltaSession7(manager));
+    session.setValid(true);
+    final String name = "attribute";
+    final Object value1 = "value1";
+    final byte[] serializedValue1 = BlobHelper.serializeToBlob(value1);
+    // simulates initial deserialized state with serialized attribute values.
+    session.getAttributes().put(name, serializedValue1);
+
+    final Object value2 = "value2";
+    session.setAttribute(name, value2);
+
+    final ArgumentCaptor<HttpSessionBindingEvent> event =
+        ArgumentCaptor.forClass(HttpSessionBindingEvent.class);
+    verify(listener).attributeReplaced(event.capture());
+    verifyNoMoreInteractions(listener);
+    assertThat(event.getValue().getValue()).isInstanceOf(byte[].class);
+  }
+
+  @Test
+  public void serializedAttributesLeakedInAttributeRemovedEventWhenPreferDeserializedFormFalse()
+      throws IOException {
+    setPreferDeserializedFormFalse();
+
+    final DeltaSession7 session = spy(new DeltaSession7(manager));
+    session.setValid(true);
+    final String name = "attribute";
+    final Object value1 = "value1";
+    final byte[] serializedValue1 = BlobHelper.serializeToBlob(value1);
+    // simulates initial deserialized state with serialized attribute values.
+    session.getAttributes().put(name, serializedValue1);
+
+    session.removeAttribute(name);
+
+    final ArgumentCaptor<HttpSessionBindingEvent> event =
+        ArgumentCaptor.forClass(HttpSessionBindingEvent.class);
+    verify(listener).attributeRemoved(event.capture());
+    verifyNoMoreInteractions(listener);
+    assertThat(event.getValue().getValue()).isInstanceOf(byte[].class);
+  }
+
+  @SuppressWarnings("deprecation")
+  protected void setPreferDeserializedFormFalse() {
+    when(manager.getPreferDeserializedForm()).thenReturn(false);
+  }
+
+}
diff --git a/extensions/geode-modules-tomcat7/src/test/java/org/apache/geode/modules/session/catalina/Tomcat7DeltaSessionManagerTest.java b/extensions/geode-modules-tomcat7/src/test/java/org/apache/geode/modules/session/catalina/Tomcat7DeltaSessionManagerTest.java
index e6fd534..20983fc 100644
--- a/extensions/geode-modules-tomcat7/src/test/java/org/apache/geode/modules/session/catalina/Tomcat7DeltaSessionManagerTest.java
+++ b/extensions/geode-modules-tomcat7/src/test/java/org/apache/geode/modules/session/catalina/Tomcat7DeltaSessionManagerTest.java
@@ -34,7 +34,8 @@ import org.junit.Test;
 
 import org.apache.geode.internal.cache.GemFireCacheImpl;
 
-public class Tomcat7DeltaSessionManagerTest extends AbstractDeltaSessionManagerTest {
+public class Tomcat7DeltaSessionManagerTest
+    extends AbstractDeltaSessionManagerTest<Tomcat7DeltaSessionManager> {
   private Pipeline pipeline;
 
   @Before
diff --git a/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/Tomcat6CommitSessionValve.java b/extensions/geode-modules-tomcat8/src/integrationTest/java/org/apache/geode/modules/session/catalina/DeltaSession8Test.java
similarity index 62%
copy from extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/Tomcat6CommitSessionValve.java
copy to extensions/geode-modules-tomcat8/src/integrationTest/java/org/apache/geode/modules/session/catalina/DeltaSession8Test.java
index b27fe65..dd8c705 100644
--- a/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/Tomcat6CommitSessionValve.java
+++ b/extensions/geode-modules-tomcat8/src/integrationTest/java/org/apache/geode/modules/session/catalina/DeltaSession8Test.java
@@ -12,16 +12,29 @@
  * or implied. See the License for the specific language governing permissions and limitations under
  * the License.
  */
-
 package org.apache.geode.modules.session.catalina;
 
-import org.apache.catalina.connector.Response;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+
 
-@Deprecated
-public final class Tomcat6CommitSessionValve extends AbstractCommitSessionValve {
+public class DeltaSession8Test
+    extends AbstractDeltaSessionIntegrationTest<Tomcat8DeltaSessionManager, DeltaSession8> {
+
+  public DeltaSession8Test() {
+    super(mock(Tomcat8DeltaSessionManager.class));
+  }
 
   @Override
-  protected Response wrapResponse(Response response) {
-    return response;
+  public void before() {
+    super.before();
+    when(manager.getContext()).thenReturn(context);
   }
+
+  @Override
+  protected DeltaSession8 newSession(Tomcat8DeltaSessionManager manager) {
+    return new DeltaSession8(manager);
+  }
+
 }
diff --git a/extensions/geode-modules-tomcat8/src/test/java/org/apache/geode/modules/session/catalina/DeltaSession8Test.java b/extensions/geode-modules-tomcat8/src/test/java/org/apache/geode/modules/session/catalina/DeltaSession8Test.java
new file mode 100644
index 0000000..d85dd74
--- /dev/null
+++ b/extensions/geode-modules-tomcat8/src/test/java/org/apache/geode/modules/session/catalina/DeltaSession8Test.java
@@ -0,0 +1,147 @@
+/*
+ * 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.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyNoMoreInteractions;
+import static org.mockito.Mockito.when;
+
+import java.io.IOException;
+
+import javax.servlet.http.HttpSessionAttributeListener;
+import javax.servlet.http.HttpSessionBindingEvent;
+
+import org.apache.catalina.Context;
+import org.apache.catalina.Manager;
+import org.apache.juli.logging.Log;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.ArgumentCaptor;
+
+import org.apache.geode.internal.util.BlobHelper;
+
+public class DeltaSession8Test extends AbstractDeltaSessionTest<DeltaSession8> {
+  final HttpSessionAttributeListener listener = mock(HttpSessionAttributeListener.class);
+
+  @Before
+  @Override
+  public void setup() {
+    super.setup();
+
+    final Context context = mock(Context.class);
+    when(manager.getContext()).thenReturn(context);
+    when(context.getApplicationEventListeners()).thenReturn(new Object[] {listener});
+    when(context.getLogger()).thenReturn(mock(Log.class));
+  }
+
+  @Override
+  protected DeltaSession8 newDeltaSession(Manager manager) {
+    return new DeltaSession8(manager);
+  }
+
+  @Test
+  public void serializedAttributesNotLeakedInAttributeReplaceEvent() throws IOException {
+    final DeltaSession8 session = spy(new DeltaSession8(manager));
+    session.setValid(true);
+    final String name = "attribute";
+    final Object value1 = "value1";
+    final byte[] serializedValue1 = BlobHelper.serializeToBlob(value1);
+    // simulates initial deserialized state with serialized attribute values.
+    session.getAttributes().put(name, serializedValue1);
+
+    final Object value2 = "value2";
+    session.setAttribute(name, value2);
+
+    final ArgumentCaptor<HttpSessionBindingEvent> event =
+        ArgumentCaptor.forClass(HttpSessionBindingEvent.class);
+    verify(listener).attributeReplaced(event.capture());
+    verifyNoMoreInteractions(listener);
+    assertThat(event.getValue().getValue()).isEqualTo(value1);
+  }
+
+  @Test
+  public void serializedAttributesNotLeakedInAttributeRemovedEvent() throws IOException {
+    final DeltaSession8 session = spy(new DeltaSession8(manager));
+    session.setValid(true);
+    final String name = "attribute";
+    final Object value1 = "value1";
+    final byte[] serializedValue1 = BlobHelper.serializeToBlob(value1);
+    // simulates initial deserialized state with serialized attribute values.
+    session.getAttributes().put(name, serializedValue1);
+
+    session.removeAttribute(name);
+
+    final ArgumentCaptor<HttpSessionBindingEvent> event =
+        ArgumentCaptor.forClass(HttpSessionBindingEvent.class);
+    verify(listener).attributeRemoved(event.capture());
+    verifyNoMoreInteractions(listener);
+    assertThat(event.getValue().getValue()).isEqualTo(value1);
+  }
+
+  @Test
+  public void serializedAttributesLeakedInAttributeReplaceEventWhenPreferDeserializedFormFalse()
+      throws IOException {
+    setPreferDeserializedFormFalse();
+
+    final DeltaSession8 session = spy(new DeltaSession8(manager));
+    session.setValid(true);
+    final String name = "attribute";
+    final Object value1 = "value1";
+    final byte[] serializedValue1 = BlobHelper.serializeToBlob(value1);
+    // simulates initial deserialized state with serialized attribute values.
+    session.getAttributes().put(name, serializedValue1);
+
+    final Object value2 = "value2";
+    session.setAttribute(name, value2);
+
+    final ArgumentCaptor<HttpSessionBindingEvent> event =
+        ArgumentCaptor.forClass(HttpSessionBindingEvent.class);
+    verify(listener).attributeReplaced(event.capture());
+    verifyNoMoreInteractions(listener);
+    assertThat(event.getValue().getValue()).isInstanceOf(byte[].class);
+  }
+
+  @Test
+  public void serializedAttributesLeakedInAttributeRemovedEventWhenPreferDeserializedFormFalse()
+      throws IOException {
+    setPreferDeserializedFormFalse();
+
+    final DeltaSession8 session = spy(new DeltaSession8(manager));
+    session.setValid(true);
+    final String name = "attribute";
+    final Object value1 = "value1";
+    final byte[] serializedValue1 = BlobHelper.serializeToBlob(value1);
+    // simulates initial deserialized state with serialized attribute values.
+    session.getAttributes().put(name, serializedValue1);
+
+    session.removeAttribute(name);
+
+    final ArgumentCaptor<HttpSessionBindingEvent> event =
+        ArgumentCaptor.forClass(HttpSessionBindingEvent.class);
+    verify(listener).attributeRemoved(event.capture());
+    verifyNoMoreInteractions(listener);
+    assertThat(event.getValue().getValue()).isInstanceOf(byte[].class);
+  }
+
+  @SuppressWarnings("deprecation")
+  protected void setPreferDeserializedFormFalse() {
+    when(manager.getPreferDeserializedForm()).thenReturn(false);
+  }
+
+}
diff --git a/extensions/geode-modules-tomcat8/src/test/java/org/apache/geode/modules/session/catalina/Tomcat8DeltaSessionManagerTest.java b/extensions/geode-modules-tomcat8/src/test/java/org/apache/geode/modules/session/catalina/Tomcat8DeltaSessionManagerTest.java
index c293be3..ccb2e1e 100644
--- a/extensions/geode-modules-tomcat8/src/test/java/org/apache/geode/modules/session/catalina/Tomcat8DeltaSessionManagerTest.java
+++ b/extensions/geode-modules-tomcat8/src/test/java/org/apache/geode/modules/session/catalina/Tomcat8DeltaSessionManagerTest.java
@@ -33,7 +33,8 @@ import org.junit.Test;
 
 import org.apache.geode.internal.cache.GemFireCacheImpl;
 
-public class Tomcat8DeltaSessionManagerTest extends AbstractDeltaSessionManagerTest {
+public class Tomcat8DeltaSessionManagerTest
+    extends AbstractDeltaSessionManagerTest<Tomcat8DeltaSessionManager> {
   private Pipeline pipeline;
 
   @Before
diff --git a/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/Tomcat6CommitSessionValve.java b/extensions/geode-modules-tomcat9/src/integrationTest/java/org/apache/geode/modules/session/catalina/DeltaSession9Test.java
similarity index 62%
copy from extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/Tomcat6CommitSessionValve.java
copy to extensions/geode-modules-tomcat9/src/integrationTest/java/org/apache/geode/modules/session/catalina/DeltaSession9Test.java
index b27fe65..34d4716 100644
--- a/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/Tomcat6CommitSessionValve.java
+++ b/extensions/geode-modules-tomcat9/src/integrationTest/java/org/apache/geode/modules/session/catalina/DeltaSession9Test.java
@@ -12,16 +12,27 @@
  * or implied. See the License for the specific language governing permissions and limitations under
  * the License.
  */
-
 package org.apache.geode.modules.session.catalina;
 
-import org.apache.catalina.connector.Response;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class DeltaSession9Test
+    extends AbstractDeltaSessionIntegrationTest<Tomcat9DeltaSessionManager, DeltaSession9> {
 
-@Deprecated
-public final class Tomcat6CommitSessionValve extends AbstractCommitSessionValve {
+  public DeltaSession9Test() {
+    super(mock(Tomcat9DeltaSessionManager.class));
+  }
 
   @Override
-  protected Response wrapResponse(Response response) {
-    return response;
+  public void before() {
+    super.before();
+    when(manager.getContext()).thenReturn(context);
   }
+
+  @Override
+  protected DeltaSession9 newSession(Tomcat9DeltaSessionManager manager) {
+    return new DeltaSession9(manager);
+  }
+
 }
diff --git a/extensions/geode-modules-tomcat9/src/test/java/org/apache/geode/modules/session/catalina/DeltaSession9Test.java b/extensions/geode-modules-tomcat9/src/test/java/org/apache/geode/modules/session/catalina/DeltaSession9Test.java
new file mode 100644
index 0000000..94b2ef5
--- /dev/null
+++ b/extensions/geode-modules-tomcat9/src/test/java/org/apache/geode/modules/session/catalina/DeltaSession9Test.java
@@ -0,0 +1,147 @@
+/*
+ * 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.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyNoMoreInteractions;
+import static org.mockito.Mockito.when;
+
+import java.io.IOException;
+
+import javax.servlet.http.HttpSessionAttributeListener;
+import javax.servlet.http.HttpSessionBindingEvent;
+
+import org.apache.catalina.Context;
+import org.apache.catalina.Manager;
+import org.apache.juli.logging.Log;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.ArgumentCaptor;
+
+import org.apache.geode.internal.util.BlobHelper;
+
+public class DeltaSession9Test extends AbstractDeltaSessionTest<DeltaSession9> {
+  final HttpSessionAttributeListener listener = mock(HttpSessionAttributeListener.class);
+
+  @Before
+  @Override
+  public void setup() {
+    super.setup();
+
+    final Context context = mock(Context.class);
+    when(manager.getContext()).thenReturn(context);
+    when(context.getApplicationEventListeners()).thenReturn(new Object[] {listener});
+    when(context.getLogger()).thenReturn(mock(Log.class));
+  }
+
+  @Override
+  protected DeltaSession9 newDeltaSession(Manager manager) {
+    return new DeltaSession9(manager);
+  }
+
+  @Test
+  public void serializedAttributesNotLeakedInAttributeReplaceEvent() throws IOException {
+    final DeltaSession9 session = spy(new DeltaSession9(manager));
+    session.setValid(true);
+    final String name = "attribute";
+    final Object value1 = "value1";
+    final byte[] serializedValue1 = BlobHelper.serializeToBlob(value1);
+    // simulates initial deserialized state with serialized attribute values.
+    session.getAttributes().put(name, serializedValue1);
+
+    final Object value2 = "value2";
+    session.setAttribute(name, value2);
+
+    final ArgumentCaptor<HttpSessionBindingEvent> event =
+        ArgumentCaptor.forClass(HttpSessionBindingEvent.class);
+    verify(listener).attributeReplaced(event.capture());
+    verifyNoMoreInteractions(listener);
+    assertThat(event.getValue().getValue()).isEqualTo(value1);
+  }
+
+  @Test
+  public void serializedAttributesNotLeakedInAttributeRemovedEvent() throws IOException {
+    final DeltaSession9 session = spy(new DeltaSession9(manager));
+    session.setValid(true);
+    final String name = "attribute";
+    final Object value1 = "value1";
+    final byte[] serializedValue1 = BlobHelper.serializeToBlob(value1);
+    // simulates initial deserialized state with serialized attribute values.
+    session.getAttributes().put(name, serializedValue1);
+
+    session.removeAttribute(name);
+
+    final ArgumentCaptor<HttpSessionBindingEvent> event =
+        ArgumentCaptor.forClass(HttpSessionBindingEvent.class);
+    verify(listener).attributeRemoved(event.capture());
+    verifyNoMoreInteractions(listener);
+    assertThat(event.getValue().getValue()).isEqualTo(value1);
+  }
+
+  @Test
+  public void serializedAttributesLeakedInAttributeReplaceEventWhenPreferDeserializedFormFalse()
+      throws IOException {
+    setPreferDeserializedFormFalse();
+
+    final DeltaSession9 session = spy(new DeltaSession9(manager));
+    session.setValid(true);
+    final String name = "attribute";
+    final Object value1 = "value1";
+    final byte[] serializedValue1 = BlobHelper.serializeToBlob(value1);
+    // simulates initial deserialized state with serialized attribute values.
+    session.getAttributes().put(name, serializedValue1);
+
+    final Object value2 = "value2";
+    session.setAttribute(name, value2);
+
+    final ArgumentCaptor<HttpSessionBindingEvent> event =
+        ArgumentCaptor.forClass(HttpSessionBindingEvent.class);
+    verify(listener).attributeReplaced(event.capture());
+    verifyNoMoreInteractions(listener);
+    assertThat(event.getValue().getValue()).isInstanceOf(byte[].class);
+  }
+
+  @Test
+  public void serializedAttributesLeakedInAttributeRemovedEventWhenPreferDeserializedFormFalse()
+      throws IOException {
+    setPreferDeserializedFormFalse();
+
+    final DeltaSession9 session = spy(new DeltaSession9(manager));
+    session.setValid(true);
+    final String name = "attribute";
+    final Object value1 = "value1";
+    final byte[] serializedValue1 = BlobHelper.serializeToBlob(value1);
+    // simulates initial deserialized state with serialized attribute values.
+    session.getAttributes().put(name, serializedValue1);
+
+    session.removeAttribute(name);
+
+    final ArgumentCaptor<HttpSessionBindingEvent> event =
+        ArgumentCaptor.forClass(HttpSessionBindingEvent.class);
+    verify(listener).attributeRemoved(event.capture());
+    verifyNoMoreInteractions(listener);
+    assertThat(event.getValue().getValue()).isInstanceOf(byte[].class);
+  }
+
+  @SuppressWarnings("deprecation")
+  protected void setPreferDeserializedFormFalse() {
+    when(manager.getPreferDeserializedForm()).thenReturn(false);
+  }
+
+}
diff --git a/extensions/geode-modules-tomcat9/src/test/java/org/apache/geode/modules/session/catalina/Tomcat9DeltaSessionManagerTest.java b/extensions/geode-modules-tomcat9/src/test/java/org/apache/geode/modules/session/catalina/Tomcat9DeltaSessionManagerTest.java
index 5cdeb058..728b68d 100644
--- a/extensions/geode-modules-tomcat9/src/test/java/org/apache/geode/modules/session/catalina/Tomcat9DeltaSessionManagerTest.java
+++ b/extensions/geode-modules-tomcat9/src/test/java/org/apache/geode/modules/session/catalina/Tomcat9DeltaSessionManagerTest.java
@@ -33,7 +33,8 @@ import org.junit.Test;
 
 import org.apache.geode.internal.cache.GemFireCacheImpl;
 
-public class Tomcat9DeltaSessionManagerTest extends AbstractDeltaSessionManagerTest {
+public class Tomcat9DeltaSessionManagerTest
+    extends AbstractDeltaSessionManagerTest<Tomcat9DeltaSessionManager> {
   private Pipeline pipeline;
 
   @Before
diff --git a/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/DeltaSession.java b/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/DeltaSession.java
index 4e5e969..1968550 100644
--- a/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/DeltaSession.java
+++ b/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/DeltaSession.java
@@ -14,6 +14,8 @@
  */
 package org.apache.geode.modules.session.catalina;
 
+import static org.apache.geode.util.internal.UncheckedUtils.uncheckedCast;
+
 import java.io.DataInput;
 import java.io.DataOutput;
 import java.io.IOException;
@@ -36,6 +38,7 @@ import org.apache.catalina.ha.session.SerializablePrincipal;
 import org.apache.catalina.realm.GenericPrincipal;
 import org.apache.catalina.security.SecurityUtil;
 import org.apache.catalina.session.StandardSession;
+import org.apache.juli.logging.Log;
 
 import org.apache.geode.DataSerializable;
 import org.apache.geode.DataSerializer;
@@ -55,7 +58,7 @@ import org.apache.geode.modules.session.catalina.internal.DeltaSessionUpdateAttr
 public class DeltaSession extends StandardSession
     implements DataSerializable, Delta, GatewayDelta, Sizeable, DeltaSessionInterface {
 
-  private transient Region<String, HttpSession> operatingRegion;
+  private transient Region<String, DeltaSessionInterface> operatingRegion;
 
   private String sessionRegionName;
 
@@ -69,17 +72,21 @@ public class DeltaSession extends StandardSession
 
   private final transient Object changeLock = new Object();
 
-  private final List<DeltaSessionAttributeEvent> eventQueue = new ArrayList<>();
+  private final ArrayList<DeltaSessionAttributeEvent> eventQueue = new ArrayList<>();
 
   private transient GatewayDeltaEvent currentGatewayDeltaEvent;
 
   private transient boolean expired = false;
 
+  /**
+   * @deprecated No replacement. Always prefer deserialized form.
+   */
+  @Deprecated
   private transient boolean preferDeserializedForm = true;
 
   private byte[] serializedPrincipal;
 
-  private static Field cachedField;
+  private static final Field cachedField;
 
   static {
     try {
@@ -112,7 +119,6 @@ public class DeltaSession extends StandardSession
    * Return the <code>HttpSession</code> for which this object is the facade.
    */
   @Override
-  @SuppressWarnings("unchecked")
   public HttpSession getSession() {
     if (facade == null) {
       if (isPackageProtectionEnabled()) {
@@ -127,27 +133,29 @@ public class DeltaSession extends StandardSession
 
   @Override
   public Principal getPrincipal() {
-    if (this.principal == null && this.serializedPrincipal != null) {
-      SerializablePrincipal sp;
+    final DeltaSessionManager<?> deltaSessionManager = getDeltaSessionManager();
+
+    if (principal == null && serializedPrincipal != null) {
+      final Log logger = deltaSessionManager.getLogger();
+
+      final SerializablePrincipal sp;
       try {
-        sp = (SerializablePrincipal) BlobHelper.deserializeBlob(this.serializedPrincipal);
+        sp = (SerializablePrincipal) BlobHelper.deserializeBlob(serializedPrincipal);
       } catch (Exception e) {
-        String builder = this
-            + ": Serialized principal contains a byte[] that cannot be deserialized due to the following exception";
-        ((DeltaSessionManager) getManager()).getLogger().warn(builder, e);
+        logger.warn(this
+            + ": Serialized principal contains a byte[] that cannot be deserialized due to the following exception",
+            e);
         return null;
       }
-      this.principal =
-          sp.getPrincipal(((DeltaSessionManager) this.manager).getTheContext().getRealm());
-      if (getManager() != null) {
-        DeltaSessionManager mgr = (DeltaSessionManager) getManager();
-        if (mgr.getLogger().isDebugEnabled()) {
-          mgr.getLogger().debug(this + ": Deserialized principal: " + this.principal);
-          // mgr.logCurrentStack();
-        }
+
+      principal = sp.getPrincipal(deltaSessionManager.getTheContext().getRealm());
+
+      if (logger.isDebugEnabled()) {
+        logger.debug(this + ": Deserialized principal: " + principal);
       }
     }
-    return this.principal;
+
+    return principal;
   }
 
   @Override
@@ -158,46 +166,43 @@ public class DeltaSession extends StandardSession
     if (getManager() != null) {
       // TODO convert this to a delta
       getManager().add(this);
-      DeltaSessionManager mgr = (DeltaSessionManager) getManager();
-      if (mgr.getLogger().isDebugEnabled()) {
-        mgr.getLogger().debug(this + ": Cached principal: " + principal);
-        // mgr.logCurrentStack();
+      final Log logger = getDeltaSessionManager().getLogger();
+      if (logger.isDebugEnabled()) {
+        logger.debug(this + ": Cached principal: " + principal);
       }
     }
   }
 
   private byte[] getSerializedPrincipal() {
-    if (this.serializedPrincipal == null) {
-      if (this.principal != null && this.principal instanceof GenericPrincipal) {
-        GenericPrincipal gp = (GenericPrincipal) this.principal;
+    if (serializedPrincipal == null) {
+      if (principal != null && principal instanceof GenericPrincipal) {
+        GenericPrincipal gp = (GenericPrincipal) principal;
         SerializablePrincipal sp = SerializablePrincipal.createPrincipal(gp);
-        this.serializedPrincipal = serialize(sp);
+        serializedPrincipal = serialize(sp);
         if (manager != null) {
-          DeltaSessionManager mgr = (DeltaSessionManager) getManager();
-          if (mgr.getLogger().isDebugEnabled()) {
-            mgr.getLogger().debug(this + ": Serialized principal: " + sp);
-            // mgr.logCurrentStack();
+          final Log logger = getDeltaSessionManager().getLogger();
+          if (logger.isDebugEnabled()) {
+            logger.debug(this + ": Serialized principal: " + sp);
           }
         }
       }
     }
-    return this.serializedPrincipal;
+    return serializedPrincipal;
   }
 
-  private Region<String, HttpSession> getOperatingRegion() {
+  private Region<String, DeltaSessionInterface> getOperatingRegion() {
     // This region shouldn't be null when it is needed.
     // It should have been set by the setOwner method.
-    return this.operatingRegion;
+    return operatingRegion;
   }
 
   boolean isCommitEnabled() {
-    DeltaSessionManager mgr = (DeltaSessionManager) getManager();
-    return mgr.isCommitValveEnabled();
+    return getDeltaSessionManager().isCommitValveEnabled();
   }
 
   @Override
   public GatewayDeltaEvent getCurrentGatewayDeltaEvent() {
-    return this.currentGatewayDeltaEvent;
+    return currentGatewayDeltaEvent;
   }
 
   @Override
@@ -208,29 +213,34 @@ public class DeltaSession extends StandardSession
   @Override
   public void setOwner(Object manager) {
     if (manager instanceof DeltaSessionManager) {
-      DeltaSessionManager sessionManager = (DeltaSessionManager) manager;
+      DeltaSessionManager<?> sessionManager = (DeltaSessionManager<?>) manager;
       this.manager = sessionManager;
       initializeRegion(sessionManager);
-      this.hasDelta = false;
-      this.applyRemotely = false;
-      this.enableGatewayDeltaReplication = sessionManager.getEnableGatewayDeltaReplication();
-      this.preferDeserializedForm = sessionManager.getPreferDeserializedForm();
+      hasDelta = false;
+      applyRemotely = false;
+      enableGatewayDeltaReplication = sessionManager.getEnableGatewayDeltaReplication();
+      setOwnerDeprecated(sessionManager);
 
       // Initialize transient variables
-      if (this.listeners == null) {
-        this.listeners = new ArrayList();
+      if (listeners == null) {
+        listeners = new ArrayList<>();
       }
 
-      if (this.notes == null) {
-        this.notes = new Hashtable();
+      if (notes == null) {
+        notes = new Hashtable<>();
       }
 
-      contextName = ((DeltaSessionManager) manager).getContextName();
+      contextName = sessionManager.getContextName();
     } else {
       throw new IllegalArgumentException(this + ": The Manager must be an AbstractManager");
     }
   }
 
+  @SuppressWarnings("deprecation")
+  private void setOwnerDeprecated(DeltaSessionManager<?> sessionManager) {
+    preferDeserializedForm = sessionManager.getPreferDeserializedForm();
+  }
+
   private void checkBackingCacheAvailable() {
     if (!((SessionManager) getManager()).isBackingCacheAvailable()) {
       throw new IllegalStateException("No backing cache server is available.");
@@ -242,12 +252,15 @@ public class DeltaSession extends StandardSession
 
     checkBackingCacheAvailable();
 
-    synchronized (this.changeLock) {
+    synchronized (changeLock) {
       // Serialize the value
       byte[] serializedValue = serialize(value);
 
       // Store the attribute locally
-      if (this.preferDeserializedForm) {
+      if (preferDeserializedForm) {
+        if (notify) {
+          deserializeAttributeInternal(name);
+        }
         super.setAttribute(name, value, true);
       } else {
         super.setAttribute(name, serializedValue, true);
@@ -262,7 +275,6 @@ public class DeltaSession extends StandardSession
           new DeltaSessionUpdateAttributeEvent(name, serializedValue);
       queueAttributeEvent(event, true);
 
-
       // Distribute the update
       if (!isCommitEnabled()) {
         putInRegion(getOperatingRegion(), true, null);
@@ -276,9 +288,13 @@ public class DeltaSession extends StandardSession
     if (expired) {
       return;
     }
-    synchronized (this.changeLock) {
+    synchronized (changeLock) {
+      if (notify && preferDeserializedForm) {
+        deserializeAttributeInternal(name);
+      }
+
       // Remove the attribute locally
-      super.removeAttribute(name, true);
+      super.removeAttribute(name, notify);
 
       // Create the destroy attribute message
       DeltaSessionAttributeEvent event = new DeltaSessionDestroyAttributeEvent(name);
@@ -292,34 +308,70 @@ public class DeltaSession extends StandardSession
   }
 
   @Override
+  protected void removeAttributeInternal(String name, boolean notify) {
+    if (notify && preferDeserializedForm) {
+      deserializeAttributeInternal(name);
+    }
+
+    super.removeAttributeInternal(name, notify);
+  }
+
+  protected Object getAttributeInternal(final String name) {
+    if (null == name) {
+      return null;
+    }
+    return getAttributes().get(name);
+  }
+
+  protected void setAttributeInternal(String name, Object value) {
+    if (null == name) {
+      return;
+    }
+    getAttributes().put(name, value);
+  }
+
+  @Override
   public Object getAttribute(String name) {
     checkBackingCacheAvailable();
-    Object value = super.getAttribute(name);
+    Object value = deserializeAttribute(name, super.getAttribute(name), preferDeserializedForm);
+
+    // Touch the session region if necessary. This is an asynchronous operation
+    // that prevents the session region from prematurely expiring a session that
+    // is only getting attributes.
+    getDeltaSessionManager().addSessionToTouch(getId());
+
+    return value;
+  }
+
+  protected void deserializeAttributeInternal(final String name) {
+    deserializeAttribute(name, getAttributeInternal(name), true);
+  }
 
+  private Object deserializeAttribute(final String name, final Object value, final boolean store) {
     // If the attribute is a byte[] (meaning it came from the server),
     // deserialize it and add it to attributes map before returning it.
     if (value instanceof byte[]) {
       try {
-        value = BlobHelper.deserializeBlob((byte[]) value);
-      } catch (Exception e) {
-        String builder = this + ": Attribute named " + name
-            + " contains a byte[] that cannot be deserialized due to the following exception";
-        ((DeltaSessionManager) getManager()).getLogger().warn(
-            builder, e);
-      }
-      if (this.preferDeserializedForm) {
-        localUpdateAttribute(name, value);
+        final Object deserialized = BlobHelper.deserializeBlob((byte[]) value);
+        if (store) {
+          setAttributeInternal(name, deserialized);
+        }
+        return deserialized;
+      } catch (final Exception e) {
+        getDeltaSessionManager().getLogger().warn(
+            this + ": Attribute named " + name
+                + " contains a byte[] that cannot be deserialized due to the following exception",
+            e);
       }
     }
 
-    // Touch the session region if necessary. This is an asynchronous operation
-    // that prevents the session region from prematurely expiring a session that
-    // is only getting attributes.
-    ((DeltaSessionManager) getManager()).addSessionToTouch(getId());
-
     return value;
   }
 
+  private DeltaSessionManager<?> getDeltaSessionManager() {
+    return (DeltaSessionManager<?>) getManager();
+  }
+
   Object getAttributeWithoutDeserialize(String name) {
     return super.getAttribute(name);
   }
@@ -327,15 +379,14 @@ public class DeltaSession extends StandardSession
   @Override
   public void invalidate() {
     super.invalidate();
-    // getOperatingRegion().destroy(this.id, true); // already done in super (remove)
-    ((DeltaSessionManager) getManager()).getStatistics().incSessionsInvalidated();
+    getDeltaSessionManager().getStatistics().incSessionsInvalidated();
   }
 
   @Override
   public void processExpired() {
-    DeltaSessionManager manager = (DeltaSessionManager) getManager();
+    DeltaSessionManager<?> manager = getDeltaSessionManager();
     if (manager != null && manager.getLogger() != null && manager.getLogger().isDebugEnabled()) {
-      ((DeltaSessionManager) getManager()).getLogger().debug(this + ": Expired");
+      getDeltaSessionManager().getLogger().debug(this + ": Expired");
     }
 
     // Set expired (so region.destroy is not called again)
@@ -353,7 +404,7 @@ public class DeltaSession extends StandardSession
   @Override
   public void expire(boolean notify) {
     if (notify) {
-      getOperatingRegion().destroy(this.getId(), this);
+      getOperatingRegion().destroy(getId(), this);
     } else {
       super.expire(false);
     }
@@ -366,7 +417,7 @@ public class DeltaSession extends StandardSession
 
   @Override
   public void localUpdateAttribute(String name, Object value) {
-    if (this.manager == null) {
+    if (manager == null) {
       // Name cannot be null
       if (name == null) {
         throw new IllegalArgumentException(sm.getString("standardSession.setAttribute.namenull"));
@@ -387,7 +438,8 @@ public class DeltaSession extends StandardSession
       // Replace or add this attribute
       getAttributes().put(name, value);
     } else {
-      super.setAttribute(name, value, false); // don't do notification since this is a replication
+      // don't do notification since this is a replication
+      super.setAttribute(name, value, false);
     }
   }
 
@@ -407,18 +459,18 @@ public class DeltaSession extends StandardSession
     putInRegion(region, false, true);
   }
 
-  private void initializeRegion(DeltaSessionManager sessionManager) {
+  private void initializeRegion(DeltaSessionManager<?> sessionManager) {
     // Get the session region name
-    this.sessionRegionName = sessionManager.getRegionName();
+    sessionRegionName = sessionManager.getRegionName();
 
     // Get the operating region.
     // If a P2P manager is used, then this will be a local region fronting the
     // session region if local cache is enabled; otherwise, it will be the
     // session region itself.
     // If a CS manager is used, it will be the session proxy region.
-    this.operatingRegion = sessionManager.getSessionCache().getOperatingRegion();
+    operatingRegion = uncheckedCast(sessionManager.getSessionCache().getOperatingRegion());
     if (sessionManager.getLogger().isDebugEnabled()) {
-      sessionManager.getLogger().debug(this + ": Set operating region: " + this.operatingRegion);
+      sessionManager.getLogger().debug(this + ": Set operating region: " + operatingRegion);
     }
   }
 
@@ -429,56 +481,55 @@ public class DeltaSession extends StandardSession
       // If the manager has enabled gateway delta replication and is a P2P
       // manager, the GatewayDeltaForwardCacheListener will be invoked in this
       // VM. Add the event to the currentDelta.
-      DeltaSessionManager mgr = (DeltaSessionManager) this.manager;
-      if (this.enableGatewayDeltaReplication && mgr.isPeerToPeer()) {
+      if (enableGatewayDeltaReplication && getDeltaSessionManager().isPeerToPeer()) {
         // If commit is not enabled, add the event to the current batch; else,
         // the current batch will be initialized to the events in the queue will
         // be added at commit time.
         if (!isCommitEnabled()) {
           List<DeltaSessionAttributeEvent> events = new ArrayList<>();
           events.add(event);
-          this.currentGatewayDeltaEvent =
-              new DeltaSessionAttributeEventBatch(this.sessionRegionName, this.id, events);
+          currentGatewayDeltaEvent =
+              new DeltaSessionAttributeEventBatch(sessionRegionName, id, events);
         }
       }
     }
     addEventToEventQueue(event);
   }
 
-  @SuppressWarnings("unchecked")
-  private void putInRegion(Region region, boolean applyRemotely, Object callbackArgument) {
-    this.hasDelta = true;
+  private void putInRegion(Region<String, DeltaSessionInterface> region, boolean applyRemotely,
+      Object callbackArgument) {
+    hasDelta = true;
     this.applyRemotely = applyRemotely;
-    region.put(this.id, this, callbackArgument);
-    this.eventQueue.clear();
+    region.put(id, this, callbackArgument);
+    eventQueue.clear();
   }
 
   @Override
   public void commit() {
-    if (!isValidInternal())
+    if (!isValidInternal()) {
       throw new IllegalStateException("commit: Session " + getId() + " already invalidated");
+    }
     // (STRING_MANAGER.getString("deltaSession.commit.ise", getId()));
 
-    synchronized (this.changeLock) {
+    synchronized (changeLock) {
       // Jens - there used to be a check to only perform this if the queue is
       // empty, but we want this to always run so that the lastAccessedTime
       // will be updated even when no attributes have been changed.
-      DeltaSessionManager mgr = (DeltaSessionManager) this.manager;
-      if (this.enableGatewayDeltaReplication && mgr.isPeerToPeer()) {
+      if (enableGatewayDeltaReplication && getDeltaSessionManager().isPeerToPeer()) {
         setCurrentGatewayDeltaEvent(
-            new DeltaSessionAttributeEventBatch(this.sessionRegionName, this.id, this.eventQueue));
+            new DeltaSessionAttributeEventBatch(sessionRegionName, id, eventQueue));
       }
-      this.hasDelta = true;
-      this.applyRemotely = true;
+      hasDelta = true;
+      applyRemotely = true;
       putInRegion(getOperatingRegion(), true, null);
-      this.eventQueue.clear();
+      eventQueue.clear();
     }
   }
 
   @Override
   public void abort() {
-    synchronized (this.changeLock) {
-      this.eventQueue.clear();
+    synchronized (changeLock) {
+      eventQueue.clear();
     }
   }
 
@@ -488,7 +539,7 @@ public class DeltaSession extends StandardSession
 
   @Override
   public boolean getExpired() {
-    return this.expired;
+    return expired;
   }
 
   @Override
@@ -498,25 +549,25 @@ public class DeltaSession extends StandardSession
 
   @Override
   public boolean hasDelta() {
-    return this.hasDelta;
+    return hasDelta;
   }
 
   @Override
   public void toDelta(DataOutput out) throws IOException {
     // Write whether to apply the changes to another DS if necessary
-    out.writeBoolean(this.applyRemotely);
+    out.writeBoolean(applyRemotely);
 
     // Write the events
-    DataSerializer.writeArrayList((ArrayList) this.eventQueue, out);
+    DataSerializer.writeArrayList(eventQueue, out);
 
-    out.writeLong(this.lastAccessedTime);
-    out.writeInt(this.maxInactiveInterval);
+    out.writeLong(lastAccessedTime);
+    out.writeInt(maxInactiveInterval);
   }
 
   @Override
   public void fromDelta(DataInput in) throws IOException, InvalidDeltaException {
     // Read whether to apply the changes to another DS if necessary
-    this.applyRemotely = in.readBoolean();
+    applyRemotely = in.readBoolean();
 
     // Read the events
     List<DeltaSessionAttributeEvent> events;
@@ -528,8 +579,8 @@ public class DeltaSession extends StandardSession
 
     // This allows for backwards compatibility with 2.1 clients
     if (((InputStream) in).available() > 0) {
-      this.lastAccessedTime = in.readLong();
-      this.maxInactiveInterval = in.readInt();
+      lastAccessedTime = in.readLong();
+      maxInactiveInterval = in.readInt();
     }
 
     // Iterate and apply the events
@@ -538,9 +589,9 @@ public class DeltaSession extends StandardSession
     }
 
     // Add the events to the gateway delta region if necessary
-    if (this.enableGatewayDeltaReplication && this.applyRemotely) {
+    if (enableGatewayDeltaReplication && applyRemotely) {
       setCurrentGatewayDeltaEvent(
-          new DeltaSessionAttributeEventBatch(this.sessionRegionName, this.id, events));
+          new DeltaSessionAttributeEventBatch(sessionRegionName, id, events));
     }
 
     // Access it to set the last accessed time. End access it to set not new.
@@ -551,57 +602,57 @@ public class DeltaSession extends StandardSession
   @Override
   public void toData(DataOutput out) throws IOException {
     // Write the StandardSession state
-    DataSerializer.writeString(this.id, out);
-    out.writeLong(this.creationTime);
-    out.writeLong(this.lastAccessedTime);
-    out.writeLong(this.thisAccessedTime);
-    out.writeInt(this.maxInactiveInterval);
-    out.writeBoolean(this.isNew);
-    out.writeBoolean(this.isValid);
+    DataSerializer.writeString(id, out);
+    out.writeLong(creationTime);
+    out.writeLong(lastAccessedTime);
+    out.writeLong(thisAccessedTime);
+    out.writeInt(maxInactiveInterval);
+    out.writeBoolean(isNew);
+    out.writeBoolean(isValid);
     DataSerializer.writeObject(getSerializedAttributes(), out);
     DataSerializer.writeByteArray(getSerializedPrincipal(), out);
 
     // Write the DeltaSession state
-    out.writeBoolean(this.enableGatewayDeltaReplication);
-    DataSerializer.writeString(this.sessionRegionName, out);
+    out.writeBoolean(enableGatewayDeltaReplication);
+    DataSerializer.writeString(sessionRegionName, out);
 
-    DataSerializer.writeString(this.contextName, out);
+    DataSerializer.writeString(contextName, out);
   }
 
   @Override
   public void fromData(DataInput in) throws IOException, ClassNotFoundException {
     // Read the StandardSession state
-    this.id = DataSerializer.readString(in);
-    this.creationTime = in.readLong();
-    this.lastAccessedTime = in.readLong();
-    this.thisAccessedTime = in.readLong();
-    this.maxInactiveInterval = in.readInt();
-    this.isNew = in.readBoolean();
-    this.isValid = in.readBoolean();
+    id = DataSerializer.readString(in);
+    creationTime = in.readLong();
+    lastAccessedTime = in.readLong();
+    thisAccessedTime = in.readLong();
+    maxInactiveInterval = in.readInt();
+    isNew = in.readBoolean();
+    isValid = in.readBoolean();
     readInAttributes(in);
-    this.serializedPrincipal = DataSerializer.readByteArray(in);
+    serializedPrincipal = DataSerializer.readByteArray(in);
 
     // Read the DeltaSession state
-    this.enableGatewayDeltaReplication = in.readBoolean();
-    this.sessionRegionName = DataSerializer.readString(in);
+    enableGatewayDeltaReplication = in.readBoolean();
+    sessionRegionName = DataSerializer.readString(in);
 
     // This allows for backwards compatibility with 2.1 clients
     if (((InputStream) in).available() > 0) {
-      this.contextName = DataSerializer.readString(in);
+      contextName = DataSerializer.readString(in);
     }
 
     // Initialize the transients if necessary
-    if (this.listeners == null) {
-      this.listeners = new ArrayList();
+    if (listeners == null) {
+      listeners = new ArrayList<>();
     }
 
-    if (this.notes == null) {
-      this.notes = new Hashtable();
+    if (notes == null) {
+      notes = new Hashtable<>();
     }
   }
 
   private void readInAttributes(DataInput in) throws IOException, ClassNotFoundException {
-    ConcurrentHashMap map = DataSerializer.readObject(in);
+    ConcurrentHashMap<Object, Object> map = DataSerializer.readObject(in);
     try {
       Field field = getAttributesFieldObject();
       field.set(this, map);
@@ -616,17 +667,16 @@ public class DeltaSession extends StandardSession
   }
 
   private void logError(Exception e) {
-    if (getManager() != null) {
-      DeltaSessionManager mgr = (DeltaSessionManager) getManager();
-      mgr.getLogger().error(e);
+    final DeltaSessionManager<?> deltaSessionManager = getDeltaSessionManager();
+    if (deltaSessionManager != null) {
+      deltaSessionManager.getLogger().error(e);
     }
   }
 
   @Override
   public int getSizeInBytes() {
     int size = 0;
-    @SuppressWarnings("unchecked")
-    Enumeration<String> attributeNames = (Enumeration<String>) getAttributeNames();
+    Enumeration<String> attributeNames = uncheckedCast(getAttributeNames());
     while (attributeNames.hasMoreElements()) {
       // Don't use getAttribute() because we don't want to deserialize the value.
       Object value = getAttributeWithoutDeserialize(attributeNames.nextElement());
@@ -638,13 +688,11 @@ public class DeltaSession extends StandardSession
     return size;
   }
 
-  @SuppressWarnings({"unchecked", "rawtypes"})
   private Map<String, byte[]> getSerializedAttributes() {
     // Iterate the values and serialize them if necessary before sending them to the server. This
     // makes the application classes unnecessary on the server.
     Map<String, byte[]> serializedAttributes = new ConcurrentHashMap<>();
-    for (Object o : getAttributes().entrySet()) {
-      Map.Entry<String, Object> entry = (Map.Entry<String, Object>) o;
+    for (Map.Entry<String, Object> entry : getAttributes().entrySet()) {
       Object value = entry.getValue();
       byte[] serializedValue = value instanceof byte[] ? (byte[]) value : serialize(value);
       serializedAttributes.put(entry.getKey(), serializedValue);
@@ -652,10 +700,10 @@ public class DeltaSession extends StandardSession
     return serializedAttributes;
   }
 
-  protected Map getAttributes() {
+  protected Map<String, Object> getAttributes() {
     try {
       Field field = getAttributesFieldObject();
-      return (Map) field.get(this);
+      return uncheckedCast(field.get(this));
     } catch (IllegalAccessException e) {
       logError(e);
     }
@@ -669,7 +717,7 @@ public class DeltaSession extends StandardSession
     } catch (IOException e) {
       String builder = this + ": Object " + obj
           + " cannot be serialized due to the following exception";
-      ((DeltaSessionManager) getManager()).getLogger().warn(
+      getDeltaSessionManager().getLogger().warn(
           builder, e);
     }
     return serializedValue;
@@ -683,16 +731,16 @@ public class DeltaSession extends StandardSession
   @Override
   public String toString() {
     return "DeltaSession[" + "id=" + getId()
-        + "; context=" + this.contextName + "; sessionRegionName="
-        + this.sessionRegionName + "; operatingRegionName="
+        + "; context=" + contextName + "; sessionRegionName="
+        + sessionRegionName + "; operatingRegionName="
         + (getOperatingRegion() == null ? "unset" : getOperatingRegion().getFullPath())
         + "]";
   }
 
   // Helper methods to enable better unit testing
   DeltaSessionFacade getNewFacade(DeltaSessionInterface fSession) {
-    return (DeltaSessionFacade) AccessController.doPrivileged(
-        (PrivilegedAction) () -> new DeltaSessionFacade(fSession));
+    return AccessController.doPrivileged(
+        (PrivilegedAction<DeltaSessionFacade>) () -> new DeltaSessionFacade(fSession));
   }
 
   boolean isPackageProtectionEnabled() {
diff --git a/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/DeltaSessionManager.java b/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/DeltaSessionManager.java
index 86103df..40b2b14 100644
--- a/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/DeltaSessionManager.java
+++ b/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/DeltaSessionManager.java
@@ -14,6 +14,9 @@
  */
 package org.apache.geode.modules.session.catalina;
 
+import static org.apache.geode.cache.Region.SEPARATOR;
+import static org.apache.geode.util.internal.UncheckedUtils.uncheckedCast;
+
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
 import java.io.BufferedInputStream;
@@ -37,6 +40,8 @@ import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicInteger;
 
+import javax.servlet.http.HttpSession;
+
 import org.apache.catalina.Container;
 import org.apache.catalina.Context;
 import org.apache.catalina.Lifecycle;
@@ -63,9 +68,9 @@ import org.apache.geode.modules.util.ContextMapper;
 import org.apache.geode.modules.util.RegionConfiguration;
 import org.apache.geode.modules.util.RegionHelper;
 
-public abstract class DeltaSessionManager<CommitSessionValveT extends AbstractCommitSessionValve>
+public abstract class DeltaSessionManager<CommitSessionValveT extends AbstractCommitSessionValve<?>>
     extends ManagerBase
-    implements Lifecycle, PropertyChangeListener, SessionManager {
+    implements Lifecycle, PropertyChangeListener, SessionManager, DeltaSessionManagerConfiguration {
 
   static final String catalinaBaseSystemProperty = "catalina.base";
   static final String javaTempDirSystemProperty = "java.io.tmpdir";
@@ -73,7 +78,7 @@ public abstract class DeltaSessionManager<CommitSessionValveT extends AbstractCo
   /**
    * The number of rejected sessions.
    */
-  private AtomicInteger rejectedSessions;
+  private final AtomicInteger rejectedSessions;
 
   /**
    * The maximum number of active Sessions allowed, or -1 for no limit.
@@ -106,6 +111,10 @@ public abstract class DeltaSessionManager<CommitSessionValveT extends AbstractCo
 
   private static final boolean DEFAULT_ENABLE_COMMIT_VALVE_FAILFAST = false;
 
+  /**
+   * @deprecated No replacement. Always prefer deserialized form.
+   */
+  @Deprecated
   private static final boolean DEFAULT_PREFER_DESERIALIZED_FORM = true;
 
   /*
@@ -117,7 +126,7 @@ public abstract class DeltaSessionManager<CommitSessionValveT extends AbstractCo
   protected String regionName = DEFAULT_REGION_NAME;
 
   private String regionAttributesId; // the default is different for client-server and
-                                     // peer-to-peer
+  // peer-to-peer
 
   private Boolean enableLocalCache; // the default is different for client-server and peer-to-peer
 
@@ -129,6 +138,10 @@ public abstract class DeltaSessionManager<CommitSessionValveT extends AbstractCo
 
   private boolean enableDebugListener = DEFAULT_ENABLE_DEBUG_LISTENER;
 
+  /**
+   * @deprecated No replacement. Always prefer deserialized form.
+   */
+  @Deprecated
   private boolean preferDeserializedForm = DEFAULT_PREFER_DESERIALIZED_FORM;
 
   private Timer timer;
@@ -142,16 +155,17 @@ public abstract class DeltaSessionManager<CommitSessionValveT extends AbstractCo
       Long.getLong("gemfiremodules.sessionTimerTaskDelay", 10000);
 
   public DeltaSessionManager() {
-    this.rejectedSessions = new AtomicInteger(0);
+    rejectedSessions = new AtomicInteger(0);
     // Create the set to store sessions to be touched after get attribute requests
-    this.sessionsToTouch = Collections.newSetFromMap(new ConcurrentHashMap<>());
+    sessionsToTouch = Collections.newSetFromMap(new ConcurrentHashMap<>());
   }
 
   @Override
   public String getRegionName() {
-    return this.regionName;
+    return regionName;
   }
 
+  @Override
   public void setRegionName(String regionName) {
     this.regionName = regionName;
   }
@@ -166,15 +180,15 @@ public abstract class DeltaSessionManager<CommitSessionValveT extends AbstractCo
     // This property will be null if it hasn't been set in the context.xml file.
     // Since its default is dependent on the session cache, get the default from
     // the session cache.
-    if (this.regionAttributesId == null) {
-      this.regionAttributesId = getSessionCache().getDefaultRegionAttributesId();
+    if (regionAttributesId == null) {
+      regionAttributesId = getSessionCache().getDefaultRegionAttributesId();
     }
-    return this.regionAttributesId;
+    return regionAttributesId;
   }
 
-  @SuppressWarnings("unused")
+  @Override
   public void setRegionAttributesId(String regionType) {
-    this.regionAttributesId = regionType;
+    regionAttributesId = regionType;
   }
 
   @Override
@@ -182,23 +196,23 @@ public abstract class DeltaSessionManager<CommitSessionValveT extends AbstractCo
     // This property will be null if it hasn't been set in the context.xml file.
     // Since its default is dependent on the session cache, get the default from
     // the session cache.
-    if (this.enableLocalCache == null) {
-      this.enableLocalCache = getSessionCache().getDefaultEnableLocalCache();
+    if (enableLocalCache == null) {
+      enableLocalCache = getSessionCache().getDefaultEnableLocalCache();
     }
-    return this.enableLocalCache;
+    return enableLocalCache;
   }
 
-  @SuppressWarnings("unused")
+  @Override
   public void setEnableLocalCache(boolean enableLocalCache) {
     this.enableLocalCache = enableLocalCache;
   }
 
-  @SuppressWarnings("unused")
+  @Override
   public int getMaxActiveSessions() {
-    return this.maxActiveSessions;
+    return maxActiveSessions;
   }
 
-  @SuppressWarnings("unused")
+  @Override
   public void setMaxActiveSessions(int maxActiveSessions) {
     int oldMaxActiveSessions = this.maxActiveSessions;
     this.maxActiveSessions = maxActiveSessions;
@@ -212,7 +226,7 @@ public abstract class DeltaSessionManager<CommitSessionValveT extends AbstractCo
     return false; // disabled
   }
 
-  @SuppressWarnings("unused")
+  @Override
   public void setEnableGatewayDeltaReplication(boolean enableGatewayDeltaReplication) {
     // this.enableGatewayDeltaReplication = enableGatewayDeltaReplication;
     // Disabled. Keeping the method for backward compatibility.
@@ -220,41 +234,42 @@ public abstract class DeltaSessionManager<CommitSessionValveT extends AbstractCo
 
   @Override
   public boolean getEnableGatewayReplication() {
-    return this.enableGatewayReplication;
+    return enableGatewayReplication;
   }
 
-  @SuppressWarnings("unused")
+  @Override
   public void setEnableGatewayReplication(boolean enableGatewayReplication) {
     this.enableGatewayReplication = enableGatewayReplication;
   }
 
   @Override
   public boolean getEnableDebugListener() {
-    return this.enableDebugListener;
+    return enableDebugListener;
   }
 
-  @SuppressWarnings("unused")
+  @Override
   public void setEnableDebugListener(boolean enableDebugListener) {
     this.enableDebugListener = enableDebugListener;
   }
 
   @Override
   public boolean isCommitValveEnabled() {
-    return this.enableCommitValve;
+    return enableCommitValve;
   }
 
+  @Override
   public void setEnableCommitValve(boolean enable) {
-    this.enableCommitValve = enable;
+    enableCommitValve = enable;
   }
 
   @Override
   public boolean isCommitValveFailfastEnabled() {
-    return this.enableCommitValveFailfast;
+    return enableCommitValveFailfast;
   }
 
-  @SuppressWarnings("unused")
+  @Override
   public void setEnableCommitValveFailfast(boolean enable) {
-    this.enableCommitValveFailfast = enable;
+    enableCommitValveFailfast = enable;
   }
 
   @Override
@@ -262,14 +277,27 @@ public abstract class DeltaSessionManager<CommitSessionValveT extends AbstractCo
     return sessionCache.isBackingCacheAvailable();
   }
 
-  @SuppressWarnings("unused")
+  /**
+   * @deprecated No replacement. Always prefer deserialized form.
+   */
+  @Deprecated
+  @Override
   public void setPreferDeserializedForm(boolean enable) {
-    this.preferDeserializedForm = enable;
+    log.warn("Use of deprecated preferDeserializedForm property to be removed in future release.");
+    if (!enable) {
+      log.warn(
+          "Use of HttpSessionAttributeListener may result in serialized form in HttpSessionBindingEvent.");
+    }
+    preferDeserializedForm = enable;
   }
 
+  /**
+   * @deprecated No replacement. Always prefer deserialized form.
+   */
+  @Deprecated
   @Override
   public boolean getPreferDeserializedForm() {
-    return this.preferDeserializedForm;
+    return preferDeserializedForm;
   }
 
   @Override
@@ -286,7 +314,7 @@ public abstract class DeltaSessionManager<CommitSessionValveT extends AbstractCo
   }
 
   public SessionCache getSessionCache() {
-    return this.sessionCache;
+    return sessionCache;
   }
 
   public DeltaSessionStatistics getStatistics() {
@@ -297,7 +325,6 @@ public abstract class DeltaSessionManager<CommitSessionValveT extends AbstractCo
     return getSessionCache().isPeerToPeer();
   }
 
-  @SuppressWarnings("unused")
   public boolean isClientServer() {
     return getSessionCache().isClientServer();
   }
@@ -330,7 +357,7 @@ public abstract class DeltaSessionManager<CommitSessionValveT extends AbstractCo
   }
 
   @Override
-  public Session findSession(String id) throws IOException {
+  public Session findSession(String id) {
     if (id == null) {
       return null;
     }
@@ -386,7 +413,7 @@ public abstract class DeltaSessionManager<CommitSessionValveT extends AbstractCo
     }
 
     // Create the appropriate session cache
-    this.sessionCache = cache.isClient() ? new ClientServerSessionCache(this, cache)
+    sessionCache = cache.isClient() ? new ClientServerSessionCache(this, cache)
         : new PeerToPeerSessionCache(this, cache);
 
     // Initialize the session cache
@@ -394,7 +421,7 @@ public abstract class DeltaSessionManager<CommitSessionValveT extends AbstractCo
   }
 
   void initSessionCache() {
-    this.sessionCache.initialize();
+    sessionCache.initialize();
   }
 
   Cache getAnyCacheInstance() {
@@ -408,11 +435,6 @@ public abstract class DeltaSessionManager<CommitSessionValveT extends AbstractCo
 
   @Override
   public void remove(Session session) {
-    remove(session, false);
-  }
-
-  public void remove(Session session, @SuppressWarnings("unused") boolean update) {
-    // super.remove(session);
     // Remove the session from the region if necessary.
     // It will have already been removed if it expired implicitly.
     DeltaSessionInterface ds = (DeltaSessionInterface) session;
@@ -451,7 +473,7 @@ public abstract class DeltaSessionManager<CommitSessionValveT extends AbstractCo
 
   @Override
   public int getRejectedSessions() {
-    return this.rejectedSessions.get();
+    return rejectedSessions.get();
   }
 
   @Override
@@ -498,20 +520,20 @@ public abstract class DeltaSessionManager<CommitSessionValveT extends AbstractCo
    * expiration.
    */
   void addSessionToTouch(String sessionId) {
-    this.sessionsToTouch.add(sessionId);
+    sessionsToTouch.add(sessionId);
   }
 
   protected Set<String> getSessionsToTouch() {
-    return this.sessionsToTouch;
+    return sessionsToTouch;
   }
 
-  boolean removeTouchedSession(String sessionId) {
-    return this.sessionsToTouch.remove(sessionId);
+  void removeTouchedSession(String sessionId) {
+    sessionsToTouch.remove(sessionId);
   }
 
   protected void scheduleTimerTasks() {
     // Create the timer
-    this.timer = new Timer("Timer for " + toString(), true);
+    timer = new Timer("Timer for " + toString(), true);
 
     // Schedule the task to handle sessions to be touched
     scheduleTouchSessionsTask();
@@ -538,12 +560,12 @@ public abstract class DeltaSessionManager<CommitSessionValveT extends AbstractCo
         }
       }
     };
-    this.timer.schedule(task, TIMER_TASK_DELAY, TIMER_TASK_PERIOD);
+    timer.schedule(task, TIMER_TASK_DELAY, TIMER_TASK_PERIOD);
   }
 
   protected void cancelTimer() {
     if (timer != null) {
-      this.timer.cancel();
+      timer.cancel();
     }
   }
 
@@ -562,7 +584,7 @@ public abstract class DeltaSessionManager<CommitSessionValveT extends AbstractCo
       }
     };
 
-    this.timer.schedule(task, TIMER_TASK_DELAY, TIMER_TASK_PERIOD);
+    timer.schedule(task, TIMER_TASK_DELAY, TIMER_TASK_PERIOD);
   }
 
   @Override
@@ -685,10 +707,10 @@ public abstract class DeltaSessionManager<CommitSessionValveT extends AbstractCo
     }
 
     String regionName;
-    if (getRegionName().startsWith("/")) {
+    if (getRegionName().startsWith(SEPARATOR)) {
       regionName = getRegionName();
     } else {
-      regionName = "/" + getRegionName();
+      regionName = SEPARATOR + getRegionName();
     }
 
     Query query = querySvc.newQuery("select s.id from " + regionName
@@ -698,9 +720,9 @@ public abstract class DeltaSessionManager<CommitSessionValveT extends AbstractCo
       getLogger().debug("Query: " + query.getQueryString());
     }
 
-    SelectResults results;
+    SelectResults<String> results;
     try {
-      results = (SelectResults) query.execute();
+      results = uncheckedCast(query.execute());
     } catch (Exception ex) {
       getLogger().error("Unable to perform query during doUnload", ex);
       return;
@@ -721,7 +743,7 @@ public abstract class DeltaSessionManager<CommitSessionValveT extends AbstractCo
     }
     FileOutputStream fos = null;
     BufferedOutputStream bos = null;
-    ObjectOutputStream oos = null;
+    final ObjectOutputStream oos;
     boolean error = false;
     try {
       fos = getFileOutputStream(store);
@@ -733,13 +755,6 @@ public abstract class DeltaSessionManager<CommitSessionValveT extends AbstractCo
       throw e;
     } finally {
       if (error) {
-        if (oos != null) {
-          try {
-            oos.close();
-          } catch (IOException ioe) {
-            // Ignore
-          }
-        }
         if (bos != null) {
           try {
             bos.close();
@@ -758,10 +773,7 @@ public abstract class DeltaSessionManager<CommitSessionValveT extends AbstractCo
     }
 
     ArrayList<DeltaSessionInterface> list = new ArrayList<>();
-    @SuppressWarnings("unchecked")
-    Iterator<String> elements = (Iterator<String>) results.iterator();
-    while (elements.hasNext()) {
-      String id = elements.next();
+    for (final String id : results) {
       DeltaSessionInterface session = (DeltaSessionInterface) findSession(id);
       if (session != null) {
         list.add(session);
@@ -769,8 +781,9 @@ public abstract class DeltaSessionManager<CommitSessionValveT extends AbstractCo
     }
 
     // Write the number of active sessions, followed by the details
-    if (getLogger().isDebugEnabled())
+    if (getLogger().isDebugEnabled()) {
       getLogger().debug("Unloading " + list.size() + " sessions");
+    }
     try {
       writeToObjectOutputStream(oos, list);
       for (DeltaSessionInterface session : list) {
@@ -828,7 +841,8 @@ public abstract class DeltaSessionManager<CommitSessionValveT extends AbstractCo
 
   /**
    * Load any currently active sessions that were previously unloaded to the appropriate persistence
-   * mechanism, if any. If persistence is not supported, this method returns without doing anything.
+   * mechanism, if any. If persistence is not supported, this method returns without doing
+   * anything.
    *
    * @throws ClassNotFoundException if a serialized class cannot be found during the reload
    * @throws IOException if an input/output error occurs
@@ -904,8 +918,9 @@ public abstract class DeltaSessionManager<CommitSessionValveT extends AbstractCo
         session.readObjectData(ois);
         session.setManager(this);
 
-        Region region = getSessionCache().getOperatingRegion();
-        DeltaSessionInterface existingSession = (DeltaSessionInterface) region.get(session.getId());
+        final Region<String, HttpSession> region = getSessionCache().getOperatingRegion();
+        final DeltaSessionInterface existingSession =
+            (DeltaSessionInterface) region.get(session.getId());
         // Check whether the existing session is newer
         if (existingSession != null
             && existingSession.getLastAccessedTime() > session.getLastAccessedTime()) {
@@ -998,7 +1013,7 @@ public abstract class DeltaSessionManager<CommitSessionValveT extends AbstractCo
     return new ObjectOutputStream(bos);
   }
 
-  void writeToObjectOutputStream(ObjectOutputStream oos, List listToWrite) throws IOException {
+  void writeToObjectOutputStream(ObjectOutputStream oos, List<?> listToWrite) throws IOException {
     oos.writeObject(listToWrite.size());
   }
 
@@ -1010,8 +1025,8 @@ public abstract class DeltaSessionManager<CommitSessionValveT extends AbstractCo
   @Override
   public String toString() {
     return getClass().getSimpleName() + "[" + "container="
-        + getTheContext() + "; regionName=" + this.regionName
-        + "; regionAttributesId=" + this.regionAttributesId + "]";
+        + getTheContext() + "; regionName=" + regionName
+        + "; regionAttributesId=" + regionAttributesId + "]";
   }
 
   String getContextName() {
diff --git a/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/SessionManager.java b/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/DeltaSessionManagerConfiguration.java
similarity index 57%
copy from extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/SessionManager.java
copy to extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/DeltaSessionManagerConfiguration.java
index 52337c1..361f3ae 100644
--- a/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/SessionManager.java
+++ b/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/DeltaSessionManagerConfiguration.java
@@ -12,35 +12,63 @@
  * or implied. See the License for the specific language governing permissions and limitations under
  * the License.
  */
+
 package org.apache.geode.modules.session.catalina;
 
-import org.apache.juli.logging.Log;
+/**
+ * Method used by Catalina XML configuration.
+ */
+@SuppressWarnings("unused")
+interface DeltaSessionManagerConfiguration {
 
-public interface SessionManager {
+  void setRegionName(String regionName);
 
   String getRegionName();
 
+  void setEnableLocalCache(boolean enableLocalCache);
+
+  boolean getEnableLocalCache();
+
+  void setMaxActiveSessions(int maxActiveSessions);
+
+  int getMaxActiveSessions();
+
+  void setRegionAttributesId(String regionType);
+
   String getRegionAttributesId();
 
-  int getMaxInactiveInterval();
+  void setEnableGatewayDeltaReplication(boolean enableGatewayDeltaReplication);
+
+  boolean getEnableGatewayDeltaReplication();
+
+  void setEnableGatewayReplication(boolean enableGatewayReplication);
 
   boolean getEnableGatewayReplication();
 
-  boolean getEnableGatewayDeltaReplication();
+  void setEnableDebugListener(boolean enableDebugListener);
 
   boolean getEnableDebugListener();
 
-  boolean getEnableLocalCache();
-
   boolean isCommitValveEnabled();
 
+  void setEnableCommitValve(boolean enable);
+
   boolean isCommitValveFailfastEnabled();
 
+  void setEnableCommitValveFailfast(boolean enable);
+
   boolean isBackingCacheAvailable();
 
-  boolean getPreferDeserializedForm();
+  /**
+   * @deprecated No replacement. Always prefer deserialized form.
+   */
+  @Deprecated
+  void setPreferDeserializedForm(boolean enable);
 
-  String getStatisticsName();
+  /**
+   * @deprecated No replacement. Always prefer deserialized form.
+   */
+  @Deprecated
+  boolean getPreferDeserializedForm();
 
-  Log getLogger();
 }
diff --git a/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/JvmRouteBinderValve.java b/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/JvmRouteBinderValve.java
index 47b70f8..012973c 100644
--- a/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/JvmRouteBinderValve.java
+++ b/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/JvmRouteBinderValve.java
@@ -64,15 +64,7 @@ public class JvmRouteBinderValve extends ValveBase {
           manager.getLogger().debug(builder);
         }
         // Get the original session
-        Session session = null;
-        try {
-          session = manager.findSession(sessionId);
-        } catch (IOException e) {
-          String builder = this + ": Caught exception attempting to find session "
-              + sessionId + " in " + manager;
-          manager.getLogger().warn(builder, e);
-        }
-
+        final Session session = manager.findSession(sessionId);
         if (session == null) {
           String builder = this + ": Did not find session " + sessionId
               + " to failover in " + manager;
diff --git a/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/SessionManager.java b/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/SessionManager.java
index 52337c1..998019f 100644
--- a/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/SessionManager.java
+++ b/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/SessionManager.java
@@ -38,6 +38,10 @@ public interface SessionManager {
 
   boolean isBackingCacheAvailable();
 
+  /**
+   * @deprecated no replacement. Always prefer deserialized form.
+   */
+  @Deprecated
   boolean getPreferDeserializedForm();
 
   String getStatisticsName();
diff --git a/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/Tomcat6CommitSessionValve.java b/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/Tomcat6CommitSessionValve.java
index b27fe65..adb0c88 100644
--- a/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/Tomcat6CommitSessionValve.java
+++ b/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/Tomcat6CommitSessionValve.java
@@ -18,7 +18,8 @@ package org.apache.geode.modules.session.catalina;
 import org.apache.catalina.connector.Response;
 
 @Deprecated
-public final class Tomcat6CommitSessionValve extends AbstractCommitSessionValve {
+public final class Tomcat6CommitSessionValve
+    extends AbstractCommitSessionValve<Tomcat6CommitSessionValve> {
 
   @Override
   protected Response wrapResponse(Response response) {
diff --git a/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/callback/SessionExpirationCacheListener.java b/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/callback/SessionExpirationCacheListener.java
index 3b62b31..eb93113 100644
--- a/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/callback/SessionExpirationCacheListener.java
+++ b/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/callback/SessionExpirationCacheListener.java
@@ -30,7 +30,7 @@ public class SessionExpirationCacheListener extends CacheListenerAdapter<String,
 
   @Override
   public void afterDestroy(EntryEvent<String, HttpSession> event) {
-    // A Session expired. If it was destroyed by GemFire expiration, process it.
+    // A Session expired. If it was destroyed by Geode expiration, process it.
     // If it was destroyed via Session.invalidate, ignore it since it has
     // already been processed.
     DeltaSessionInterface session = null;
diff --git a/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/Tomcat6CommitSessionValve.java b/extensions/session-testing-war/src/main/java/org/apache/geode/modules/session/AccessAttributeValueListener.java
similarity index 53%
copy from extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/Tomcat6CommitSessionValve.java
copy to extensions/session-testing-war/src/main/java/org/apache/geode/modules/session/AccessAttributeValueListener.java
index b27fe65..1a083ab 100644
--- a/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/Tomcat6CommitSessionValve.java
+++ b/extensions/session-testing-war/src/main/java/org/apache/geode/modules/session/AccessAttributeValueListener.java
@@ -12,16 +12,24 @@
  * or implied. See the License for the specific language governing permissions and limitations under
  * the License.
  */
+package org.apache.geode.modules.session;
 
-package org.apache.geode.modules.session.catalina;
+import javax.servlet.http.HttpSessionAttributeListener;
+import javax.servlet.http.HttpSessionBindingEvent;
 
-import org.apache.catalina.connector.Response;
+public class AccessAttributeValueListener implements HttpSessionAttributeListener {
+  @Override
+  public void attributeAdded(HttpSessionBindingEvent event) {
+    System.out.println("event created value is " + (String) event.getValue());
+  }
 
-@Deprecated
-public final class Tomcat6CommitSessionValve extends AbstractCommitSessionValve {
+  @Override
+  public void attributeRemoved(HttpSessionBindingEvent event) {
+    System.out.println("event removed value is " + (String) event.getValue());
+  }
 
   @Override
-  protected Response wrapResponse(Response response) {
-    return response;
+  public void attributeReplaced(HttpSessionBindingEvent event) {
+    System.out.println("event replaced value is " + (String) event.getValue());
   }
 }
diff --git a/extensions/session-testing-war/src/main/webapp/WEB-INF/web.xml b/extensions/session-testing-war/src/main/webapp/WEB-INF/web.xml
index 3746c08..42afa86 100644
--- a/extensions/session-testing-war/src/main/webapp/WEB-INF/web.xml
+++ b/extensions/session-testing-war/src/main/webapp/WEB-INF/web.xml
@@ -48,4 +48,8 @@ limitations under the License.
     <listener-class>org.apache.geode.modules.session.SessionCountingListener</listener-class>
   </listener>
 
+  <listener>
+    <listener-class>org.apache.geode.modules.session.AccessAttributeValueListener</listener-class>
+  </listener>
+
 </web-app>
diff --git a/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/CargoTestBase.java b/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/CargoTestBase.java
index 4ef5c78..8f487de 100644
--- a/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/CargoTestBase.java
+++ b/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/CargoTestBase.java
@@ -18,6 +18,7 @@ import static org.apache.geode.test.awaitility.GeodeAwaitility.await;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.junit.Assert.assertEquals;
 
+import java.io.File;
 import java.io.IOException;
 import java.net.URISyntaxException;
 import java.nio.file.Files;
@@ -210,6 +211,8 @@ public abstract class CargoTestBase {
     manager.stopContainer(0);
     manager.removeContainer(0);
     await().untilAsserted(() -> getKeyValueDataOnAllClients(key, value, resp.getSessionCookie()));
+
+    checkLogs();
   }
 
   /**
@@ -228,6 +231,8 @@ public abstract class CargoTestBase {
     client.invalidate();
 
     verifySessionIsRemoved(key);
+
+    checkLogs();
   }
 
   protected void verifySessionIsRemoved(String key) throws IOException, URISyntaxException {
@@ -256,6 +261,8 @@ public abstract class CargoTestBase {
       verifySessionIsRemoved(key);
       Thread.sleep(1000);
     });
+
+    checkLogs();
   }
 
   /**
@@ -279,6 +286,7 @@ public abstract class CargoTestBase {
     client.setMaxInactive(63);
     verifyMaxInactiveInterval(63);
 
+    checkLogs();
   }
 
   protected void verifyMaxInactiveInterval(int expected) throws IOException, URISyntaxException {
@@ -330,6 +338,8 @@ public abstract class CargoTestBase {
     });
 
     getKeyValueDataOnAllClients(key, value, workingResponse.getSessionCookie());
+
+    checkLogs();
   }
 
   /**
@@ -343,13 +353,13 @@ public abstract class CargoTestBase {
     String value = "Foo";
     client.setPort(Integer.parseInt(manager.getContainerPort(0)));
     Client.Response resp = client.set(key, value);
-    await().untilAsserted(() -> {
-      getKeyValueDataOnAllClients(key, value, resp.getSessionCookie());
-    });
+    await().untilAsserted(() -> getKeyValueDataOnAllClients(key, value, resp.getSessionCookie()));
     client.setPort(Integer.parseInt(manager.getContainerPort(0)));
     client.remove(key);
 
     getKeyValueDataOnAllClients(key, "", resp.getSessionCookie());
+
+    checkLogs();
   }
 
   /**
@@ -378,6 +388,31 @@ public abstract class CargoTestBase {
     await().untilAsserted(() -> getKeyValueDataOnAllClients(key, value, resp.getSessionCookie()));
   }
 
+  @Test
+  public void attributesCanBeReplaced() throws IOException, URISyntaxException {
+    manager.startAllInactiveContainers();
+    String key = "value_testSessionUpdate";
+    String value = "Foo";
+    String updateValue = "Bar";
+    client.setPort(Integer.parseInt(manager.getContainerPort(0)));
+    Client.Response response = client.set(key, value);
+    await()
+        .untilAsserted(() -> getKeyValueDataOnAllClients(key, value, response.getSessionCookie()));
+    client.setPort(Integer.parseInt(manager.getContainerPort(0)));
+    Client.Response updateResponse = client.set(key, updateValue);
+    await().untilAsserted(
+        () -> getKeyValueDataOnAllClients(key, updateValue, updateResponse.getSessionCookie()));
+
+    checkLogs();
+  }
+
+  private void checkLogs() {
+    for (int i = 0; i < manager.numContainers(); i++) {
+      File cargo_dir = manager.getContainer(i).cargoLogDir;
+      LogChecker.checkLogs(cargo_dir);
+    }
+  }
+
   private void announceTest(String status) {
     System.out.format("TEST %s %s.%s%n", status, getClass().getSimpleName(),
         testName.getMethodName());
diff --git a/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/LogChecker.java b/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/LogChecker.java
new file mode 100644
index 0000000..001487d
--- /dev/null
+++ b/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/LogChecker.java
@@ -0,0 +1,126 @@
+/*
+ * 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.session.tests;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.logging.log4j.Logger;
+
+import org.apache.geode.logging.internal.log4j.api.LogService;
+
+public class LogChecker {
+  private static List<String> suspectStrings;
+  private static List<String> excludeStrings;
+  private static Logger logger = LogService.getLogger();
+
+  static {
+    suspectStrings = new ArrayList<>();
+    suspectStrings.add(java.lang.ClassCastException.class.getName());
+    suspectStrings.add(java.lang.NullPointerException.class.getName());
+    excludeStrings = new ArrayList<>();
+    excludeStrings.add("[fine");
+  }
+
+  static void checkLogs(File dir) {
+    List<File> logsToCheck = getLogs(dir);
+    checkLogs(logsToCheck);
+  }
+
+  private static List<File> getLogs(File currentDir) {
+    logger.info("Getting all logs visible from " + currentDir);
+    List<File> logList = new ArrayList<>();
+    getLogs(currentDir, logList);
+    return logList;
+  }
+
+  private static void getLogs(File currentDir, List<File> logs) {
+    File[] dirContents = currentDir.listFiles();
+    if (dirContents == null) {
+      return;
+    }
+    for (File aFile : dirContents) {
+      if (aFile.isDirectory()) {
+        getLogs(aFile, logs);
+      } else {
+        String fileName = aFile.getName();
+        if (fileName.startsWith("container") && fileName.endsWith(".log")) {
+          logs.add(aFile);
+        } else if (fileName.startsWith("gemfire") && fileName.endsWith(".log")) {
+          logs.add(aFile);
+        }
+      }
+    }
+  }
+
+  private static void checkLogs(List<File> logsToCheck) {
+    BufferedReader reader = null;
+    String line;
+    for (File aFile : logsToCheck) {
+      logger.info("Checking " + aFile.getAbsolutePath());
+      try {
+        try {
+          reader = new BufferedReader(new FileReader(aFile.getAbsoluteFile()));
+        } catch (FileNotFoundException e) {
+          throw new RuntimeException(e);
+        }
+        line = readNextLine(reader);
+        while (line != null) {
+          if (contains(suspectStrings, line) && !contains(excludeStrings, line)) {
+            throw new RuntimeException(aFile.getAbsolutePath() + " contains " + line + "\n");
+          }
+          line = readNextLine(reader);
+        }
+      } finally {
+        close(reader);
+      }
+    }
+  }
+
+  private static String readNextLine(BufferedReader reader) {
+    String line;
+    try {
+      line = reader.readLine();
+      return line;
+    } catch (IOException e) {
+      logger.info("Caught " + e);
+      return null;
+    }
+  }
+
+  private static boolean contains(List<String> targetStrs, String aStr) {
+    for (String target : targetStrs) {
+      if (aStr.contains(target)) {
+        return true;
+      }
+    }
+    return false;
+  }
+
+  private static void close(BufferedReader reader) {
+    if (reader != null) {
+      try {
+        reader.close();
+      } catch (IOException e) {
+        logger.info("Caught " + e + " while closing " + reader);
+      }
+    }
+  }
+}

[geode] 05/11: GEODE-8221: Refactor tests to run in appropriate projects. (#5244)

Posted by sa...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

sabbey37 pushed a commit to branch support/1.13
in repository https://gitbox.apache.org/repos/asf/geode.git

commit 45d9f5cfdb9af0066a0c41c57bdfcedb69108f5d
Author: Jacob Barrett <jb...@pivotal.io>
AuthorDate: Thu Jun 11 16:55:54 2020 -0700

    GEODE-8221: Refactor tests to run in appropriate projects. (#5244)
    
    (cherry picked from commit cb5990cd437244bc0ac8abdc6e12552e686e7c7a)
---
 ...SessionsBase.java => AbstractSessionsTest.java} | 143 ++++-----
 ...t.java => AbstractDeltaSessionManagerTest.java} | 187 ++++++------
 .../ClientServerSessionCacheJUnitTest.java         | 334 ---------------------
 ...ionsJUnitTest.java => Tomcat7SessionsTest.java} |  10 +-
 ...st.java => Tomcat7DeltaSessionManagerTest.java} |   6 +-
 ...st.java => Tomcat8DeltaSessionManagerTest.java} |   2 +-
 ...st.java => Tomcat9DeltaSessionManagerTest.java} |   2 +-
 ...ionsJUnitTest.java => Tomcat6SessionsTest.java} |   4 +-
 .../catalina/AbstractSessionCacheTest.java}        |  26 +-
 .../catalina/ClientServerSessionCacheTest.java     | 301 ++++++++++++++++++-
 .../session/catalina/DeltaSessionFacadeTest.java}  |   6 +-
 .../session/catalina/DeltaSessionTest.java}        |  74 ++---
 .../catalina/PeerToPeerSessionCacheTest.java}      |  26 +-
 .../SessionExpirationCacheListenerTest.java}       |  10 +-
 .../DeltaSessionAttributeEventBatchTest.java}      |  17 +-
 .../DeltaSessionDestroyAttributeEventTest.java}    |   9 +-
 .../internal/DeltaSessionStatisticsTest.java}      |  11 +-
 .../DeltaSessionUpdateAttributeEventTest.java}     |  10 +-
 .../modules/util/CreateRegionFunctionTest.java}    |  17 +-
 ...TouchPartitionedRegionEntriesFunctionTest.java} |  16 +-
 .../TouchReplicatedRegionEntriesFunctionTest.java} |  20 +-
 21 files changed, 597 insertions(+), 634 deletions(-)

diff --git a/extensions/geode-modules-test/src/main/java/org/apache/geode/modules/session/TestSessionsBase.java b/extensions/geode-modules-test/src/main/java/org/apache/geode/modules/session/AbstractSessionsTest.java
similarity index 72%
rename from extensions/geode-modules-test/src/main/java/org/apache/geode/modules/session/TestSessionsBase.java
rename to extensions/geode-modules-test/src/main/java/org/apache/geode/modules/session/AbstractSessionsTest.java
index a46eec3..e30a15d 100644
--- a/extensions/geode-modules-test/src/main/java/org/apache/geode/modules/session/TestSessionsBase.java
+++ b/extensions/geode-modules-test/src/main/java/org/apache/geode/modules/session/AbstractSessionsTest.java
@@ -45,7 +45,7 @@ import org.apache.geode.cache.Region;
 import org.apache.geode.modules.session.catalina.DeltaSessionManager;
 import org.apache.geode.modules.session.catalina.PeerToPeerCacheLifecycleListener;
 
-public abstract class TestSessionsBase {
+public abstract class AbstractSessionsTest {
   protected static int port;
   private static EmbeddedTomcat server;
   private static StandardWrapper servlet;
@@ -53,13 +53,13 @@ public abstract class TestSessionsBase {
   protected static DeltaSessionManager sessionManager;
 
   // Set up the servers we need
-  protected static void setupServer(DeltaSessionManager manager) throws Exception {
+  protected static void setupServer(final DeltaSessionManager manager) throws Exception {
     FileUtils.copyDirectory(Paths.get("..", "resources", "integrationTest", "tomcat").toFile(),
         new File("./tomcat"));
     port = SocketUtils.findAvailableTcpPort();
     server = new EmbeddedTomcat(port, "JVM-1");
 
-    PeerToPeerCacheLifecycleListener p2pListener = new PeerToPeerCacheLifecycleListener();
+    final PeerToPeerCacheLifecycleListener p2pListener = new PeerToPeerCacheLifecycleListener();
     p2pListener.setProperty(MCAST_PORT, "0");
     p2pListener.setProperty(LOG_LEVEL, "config");
     server.getEmbedded().addLifecycleListener(p2pListener);
@@ -91,19 +91,20 @@ public abstract class TestSessionsBase {
     region.clear();
   }
 
-  private WebResponse setCallbackAndExecuteGet(Callback callback) throws IOException, SAXException {
+  private WebResponse setCallbackAndExecuteGet(final Callback callback)
+      throws IOException, SAXException {
     servlet.getServletContext().setAttribute("callback", callback);
 
-    WebConversation wc = new WebConversation();
-    WebRequest req = new GetMethodWebRequest(String.format("http://localhost:%d/test", port));
+    final WebConversation wc = new WebConversation();
+    final WebRequest req = new GetMethodWebRequest(String.format("http://localhost:%d/test", port));
     req.setParameter("cmd", QueryCommand.CALLBACK.name());
     req.setParameter("param", "callback");
 
     return wc.getResponse(req);
   }
 
-  private WebRequest prepareRequest(String key, String value) {
-    WebRequest req = new GetMethodWebRequest(String.format("http://localhost:%d/test", port));
+  private WebRequest prepareRequest(final String key, final String value) {
+    final WebRequest req = new GetMethodWebRequest(String.format("http://localhost:%d/test", port));
     req.setParameter("cmd", QueryCommand.SET.name());
     req.setParameter("param", key);
     req.setParameter("value", value);
@@ -116,11 +117,11 @@ public abstract class TestSessionsBase {
    */
   @Test
   public void testSanity() throws Exception {
-    WebConversation wc = new WebConversation();
-    WebRequest req = new GetMethodWebRequest(String.format("http://localhost:%d/test", port));
+    final WebConversation wc = new WebConversation();
+    final WebRequest req = new GetMethodWebRequest(String.format("http://localhost:%d/test", port));
     req.setParameter("cmd", QueryCommand.GET.name());
     req.setParameter("param", "null");
-    WebResponse response = wc.getResponse(req);
+    final WebResponse response = wc.getResponse(req);
 
     assertEquals("JSESSIONID", response.getNewCookieNames()[0]);
   }
@@ -133,12 +134,12 @@ public abstract class TestSessionsBase {
   @Test
   public void testCallback() throws Exception {
     final String helloWorld = "Hello World";
-    Callback c = (request, response) -> {
-      PrintWriter out = response.getWriter();
+    final Callback c = (request, response) -> {
+      final PrintWriter out = response.getWriter();
       out.write(helloWorld);
     };
 
-    WebResponse response = setCallbackAndExecuteGet(c);
+    final WebResponse response = setCallbackAndExecuteGet(c);
     assertEquals(helloWorld, response.getText());
   }
 
@@ -147,14 +148,14 @@ public abstract class TestSessionsBase {
    */
   @Test
   public void testIsNew() throws Exception {
-    Callback c = (request, response) -> {
-      HttpSession session = request.getSession();
+    final Callback c = (request, response) -> {
+      final HttpSession session = request.getSession();
       response.getWriter().write(Boolean.toString(session.isNew()));
     };
     servlet.getServletContext().setAttribute("callback", c);
 
-    WebConversation wc = new WebConversation();
-    WebRequest req = new GetMethodWebRequest(String.format("http://localhost:%d/test", port));
+    final WebConversation wc = new WebConversation();
+    final WebRequest req = new GetMethodWebRequest(String.format("http://localhost:%d/test", port));
 
     req.setParameter("cmd", QueryCommand.CALLBACK.name());
     req.setParameter("param", "callback");
@@ -172,13 +173,13 @@ public abstract class TestSessionsBase {
    */
   @Test
   public void testSessionPersists1() throws Exception {
-    String key = "value_testSessionPersists1";
-    String value = "Foo";
+    final String key = "value_testSessionPersists1";
+    final String value = "Foo";
 
-    WebConversation wc = new WebConversation();
-    WebRequest req = prepareRequest(key, value);
+    final WebConversation wc = new WebConversation();
+    final WebRequest req = prepareRequest(key, value);
     WebResponse response = wc.getResponse(req);
-    String sessionId = response.getNewCookieValue("JSESSIONID");
+    final String sessionId = response.getNewCookieValue("JSESSIONID");
 
     assertNotNull("No apparent session cookie", sessionId);
 
@@ -196,11 +197,11 @@ public abstract class TestSessionsBase {
    */
   @Test
   public void testInvalidate() throws Exception {
-    String key = "value_testInvalidate";
-    String value = "Foo";
+    final String key = "value_testInvalidate";
+    final String value = "Foo";
 
-    WebConversation wc = new WebConversation();
-    WebRequest req = prepareRequest(key, value);
+    final WebConversation wc = new WebConversation();
+    final WebRequest req = prepareRequest(key, value);
     wc.getResponse(req);
 
     // Invalidate the session
@@ -212,7 +213,7 @@ public abstract class TestSessionsBase {
     // The attribute should not be accessible now...
     req.setParameter("cmd", QueryCommand.GET.name());
     req.setParameter("param", key);
-    WebResponse response = wc.getResponse(req);
+    final WebResponse response = wc.getResponse(req);
 
     assertEquals("", response.getText());
   }
@@ -225,11 +226,11 @@ public abstract class TestSessionsBase {
     // TestSessions only live for a second
     sessionManager.setMaxInactiveInterval(1);
 
-    String key = "value_testSessionExpiration1";
-    String value = "Foo";
+    final String key = "value_testSessionExpiration1";
+    final String value = "Foo";
 
-    WebConversation wc = new WebConversation();
-    WebRequest req = prepareRequest(key, value);
+    final WebConversation wc = new WebConversation();
+    final WebRequest req = prepareRequest(key, value);
     wc.getResponse(req);
 
     // Sleep a while
@@ -238,7 +239,7 @@ public abstract class TestSessionsBase {
     // The attribute should not be accessible now...
     req.setParameter("cmd", QueryCommand.GET.name());
     req.setParameter("param", key);
-    WebResponse response = wc.getResponse(req);
+    final WebResponse response = wc.getResponse(req);
 
     assertEquals("", response.getText());
   }
@@ -263,11 +264,11 @@ public abstract class TestSessionsBase {
   @Test
   public void testSessionExpirationByContainer() throws Exception {
 
-    String key = "value_testSessionExpiration1";
-    String value = "Foo";
+    final String key = "value_testSessionExpiration1";
+    final String value = "Foo";
 
-    WebConversation wc = new WebConversation();
-    WebRequest req = prepareRequest(key, value);
+    final WebConversation wc = new WebConversation();
+    final WebRequest req = prepareRequest(key, value);
     wc.getResponse(req);
 
     // Set the session timeout of this one session.
@@ -281,7 +282,7 @@ public abstract class TestSessionsBase {
     // Do a request, which should cause the session to be expired
     req.setParameter("cmd", QueryCommand.GET.name());
     req.setParameter("param", key);
-    WebResponse response = wc.getResponse(req);
+    final WebResponse response = wc.getResponse(req);
 
     assertEquals("", response.getText());
   }
@@ -291,13 +292,13 @@ public abstract class TestSessionsBase {
    */
   @Test
   public void testRemoveAttribute() throws Exception {
-    String key = "value_testRemoveAttribute";
-    String value = "Foo";
+    final String key = "value_testRemoveAttribute";
+    final String value = "Foo";
 
-    WebConversation wc = new WebConversation();
-    WebRequest req = prepareRequest(key, value);
+    final WebConversation wc = new WebConversation();
+    final WebRequest req = prepareRequest(key, value);
     WebResponse response = wc.getResponse(req);
-    String sessionId = response.getNewCookieValue("JSESSIONID");
+    final String sessionId = response.getNewCookieValue("JSESSIONID");
 
     // Implicitly remove the attribute
     req.removeParameter("value");
@@ -317,13 +318,13 @@ public abstract class TestSessionsBase {
    */
   @Test
   public void testBasicRegion() throws Exception {
-    String key = "value_testBasicRegion";
-    String value = "Foo";
+    final String key = "value_testBasicRegion";
+    final String value = "Foo";
 
-    WebConversation wc = new WebConversation();
-    WebRequest req = prepareRequest(key, value);
-    WebResponse response = wc.getResponse(req);
-    String sessionId = response.getNewCookieValue("JSESSIONID");
+    final WebConversation wc = new WebConversation();
+    final WebRequest req = prepareRequest(key, value);
+    final WebResponse response = wc.getResponse(req);
+    final String sessionId = response.getNewCookieValue("JSESSIONID");
 
     assertEquals(value, region.get(sessionId).getAttribute(key));
   }
@@ -333,13 +334,13 @@ public abstract class TestSessionsBase {
    */
   @Test
   public void testRegionInvalidate() throws Exception {
-    String key = "value_testRegionInvalidate";
-    String value = "Foo";
+    final String key = "value_testRegionInvalidate";
+    final String value = "Foo";
 
-    WebConversation wc = new WebConversation();
-    WebRequest req = prepareRequest(key, value);
-    WebResponse response = wc.getResponse(req);
-    String sessionId = response.getNewCookieValue("JSESSIONID");
+    final WebConversation wc = new WebConversation();
+    final WebRequest req = prepareRequest(key, value);
+    final WebResponse response = wc.getResponse(req);
+    final String sessionId = response.getNewCookieValue("JSESSIONID");
 
     // Invalidate the session
     req.removeParameter("param");
@@ -357,15 +358,15 @@ public abstract class TestSessionsBase {
   @Test
   public void testMultipleAttributeUpdates() throws Exception {
     final String key = "value_testMultipleAttributeUpdates";
-    Callback c = (request, response) -> {
-      HttpSession session = request.getSession();
+    final Callback c = (request, response) -> {
+      final HttpSession session = request.getSession();
       for (int i = 0; i < 1000; i++) {
         session.setAttribute(key, Integer.toString(i));
       }
     };
 
-    WebResponse response = setCallbackAndExecuteGet(c);
-    String sessionId = response.getNewCookieValue("JSESSIONID");
+    final WebResponse response = setCallbackAndExecuteGet(c);
+    final String sessionId = response.getNewCookieValue("JSESSIONID");
     assertEquals("999", region.get(sessionId).getAttribute(key));
   }
 
@@ -374,13 +375,13 @@ public abstract class TestSessionsBase {
    */
   @Test
   public void testCommitSessionValveInvalidSession() throws Exception {
-    Callback c = (request, response) -> {
-      HttpSession session = request.getSession();
+    final Callback c = (request, response) -> {
+      final HttpSession session = request.getSession();
       session.invalidate();
       response.getWriter().write("done");
     };
 
-    WebResponse response = setCallbackAndExecuteGet(c);
+    final WebResponse response = setCallbackAndExecuteGet(c);
     assertEquals("done", response.getText());
   }
 
@@ -389,12 +390,12 @@ public abstract class TestSessionsBase {
    */
   @Test
   public void testExtraSessionsNotCreated() throws Exception {
-    Callback c = (request, response) -> {
+    final Callback c = (request, response) -> {
       // Do nothing with sessions
       response.getWriter().write("done");
     };
 
-    WebResponse response = setCallbackAndExecuteGet(c);
+    final WebResponse response = setCallbackAndExecuteGet(c);
     assertEquals("done", response.getText());
     assertEquals("The region should be empty", 0, region.size());
   }
@@ -405,14 +406,14 @@ public abstract class TestSessionsBase {
    */
   @Test
   public void testLastAccessedTime() throws Exception {
-    Callback c = (request, response) -> {
-      HttpSession session = request.getSession();
+    final Callback c = (request, response) -> {
+      final HttpSession session = request.getSession();
       // Hack to expose the session to our test context
       session.getServletContext().setAttribute("session", session);
       session.setAttribute("lastAccessTime", session.getLastAccessedTime());
       try {
         Thread.sleep(100);
-      } catch (InterruptedException ex) {
+      } catch (final InterruptedException ex) {
         // Ignore.
       }
       session.setAttribute("somethingElse", 1);
@@ -421,16 +422,16 @@ public abstract class TestSessionsBase {
     };
     servlet.getServletContext().setAttribute("callback", c);
 
-    WebConversation wc = new WebConversation();
-    WebRequest req = new GetMethodWebRequest(String.format("http://localhost:%d/test", port));
+    final WebConversation wc = new WebConversation();
+    final WebRequest req = new GetMethodWebRequest(String.format("http://localhost:%d/test", port));
 
     // Execute the callback
     req.setParameter("cmd", QueryCommand.CALLBACK.name());
     req.setParameter("param", "callback");
     wc.getResponse(req);
 
-    HttpSession session = (HttpSession) servlet.getServletContext().getAttribute("session");
-    Long lastAccess = (Long) session.getAttribute("lastAccessTime");
+    final HttpSession session = (HttpSession) servlet.getServletContext().getAttribute("session");
+    final Long lastAccess = (Long) session.getAttribute("lastAccessTime");
 
     assertTrue(
         "Last access time not set correctly: " + lastAccess + " not <= "
diff --git a/extensions/geode-modules-test/src/main/java/org/apache/geode/modules/session/catalina/DeltaSessionManagerJUnitTest.java b/extensions/geode-modules-test/src/main/java/org/apache/geode/modules/session/catalina/AbstractDeltaSessionManagerTest.java
similarity index 71%
rename from extensions/geode-modules-test/src/main/java/org/apache/geode/modules/session/catalina/DeltaSessionManagerJUnitTest.java
rename to extensions/geode-modules-test/src/main/java/org/apache/geode/modules/session/catalina/AbstractDeltaSessionManagerTest.java
index fec8571..ff976b1 100644
--- a/extensions/geode-modules-test/src/main/java/org/apache/geode/modules/session/catalina/DeltaSessionManagerJUnitTest.java
+++ b/extensions/geode-modules-test/src/main/java/org/apache/geode/modules/session/catalina/AbstractDeltaSessionManagerTest.java
@@ -64,7 +64,7 @@ import org.apache.geode.cache.query.internal.LinkedResultSet;
 import org.apache.geode.internal.cache.GemFireCacheImpl;
 import org.apache.geode.modules.session.catalina.internal.DeltaSessionStatistics;
 
-public abstract class DeltaSessionManagerJUnitTest {
+public abstract class AbstractDeltaSessionManagerTest {
 
   protected DeltaSessionManager manager;
   protected AbstractSessionCache sessionCache;
@@ -94,10 +94,10 @@ public abstract class DeltaSessionManagerJUnitTest {
 
   @Test
   public void getRegionAttributesIdSetsIdFromSessionCacheWhenAttributesIdIsNull() {
-    String regionAttributesId = "attributesIdFromSessionCache";
+    final String regionAttributesId = "attributesIdFromSessionCache";
 
     doReturn(regionAttributesId).when(sessionCache).getDefaultRegionAttributesId();
-    String attrId = manager.getRegionAttributesId();
+    final String attrId = manager.getRegionAttributesId();
 
     verify(sessionCache).getDefaultRegionAttributesId();
     assertThat(attrId).isEqualTo(regionAttributesId);
@@ -105,10 +105,10 @@ public abstract class DeltaSessionManagerJUnitTest {
 
   @Test
   public void getEnableLocalCacheSetsIdFromSessionCacheWhenEnableLocalCacheIsNull() {
-    boolean isLocalCacheEnabled = true;
+    final boolean isLocalCacheEnabled = true;
 
     doReturn(isLocalCacheEnabled).when(sessionCache).getDefaultEnableLocalCache();
-    Boolean localCacheEnabledValue = manager.getEnableLocalCache();
+    final Boolean localCacheEnabledValue = manager.getEnableLocalCache();
 
     verify(sessionCache).getDefaultEnableLocalCache();
     assertThat(localCacheEnabledValue).isEqualTo(isLocalCacheEnabled);
@@ -116,23 +116,23 @@ public abstract class DeltaSessionManagerJUnitTest {
 
   @Test
   public void findSessionsReturnsNullWhenIdIsNull() throws IOException {
-    Session session = manager.findSession(null);
+    final Session session = manager.findSession(null);
 
     assertThat(session).isNull();
   }
 
   @Test
   public void findSessionsReturnsNullAndLogsMessageWhenContextNameIsNotValid() throws IOException {
-    String sessionId = "sessionId";
-    String contextName = "contextName";
-    String invalidContextName = "invalidContextName";
+    final String sessionId = "sessionId";
+    final String contextName = "contextName";
+    final String invalidContextName = "invalidContextName";
 
-    DeltaSession expectedSession = mock(DeltaSession.class);
+    final DeltaSession expectedSession = mock(DeltaSession.class);
     when(sessionCache.getSession(sessionId)).thenReturn(expectedSession);
     when(expectedSession.getContextName()).thenReturn(invalidContextName);
     when(context.getName()).thenReturn(contextName);
 
-    Session session = manager.findSession(sessionId);
+    final Session session = manager.findSession(sessionId);
 
     verify(logger).info(anyString());
     assertThat(session).isNull();
@@ -140,34 +140,34 @@ public abstract class DeltaSessionManagerJUnitTest {
 
   @Test
   public void findSessionsReturnsNullWhenIdIsNotFound() throws IOException {
-    String sessionId = "sessionId";
+    final String sessionId = "sessionId";
 
     when(sessionCache.getSession(sessionId)).thenReturn(null);
 
-    Session session = manager.findSession(sessionId);
+    final Session session = manager.findSession(sessionId);
 
     assertThat(session).isNull();
   }
 
   @Test
   public void findSessionsReturnsProperSessionByIdWhenIdAndContextNameIsValid() throws IOException {
-    String sessionId = "sessionId";
-    String contextName = "contextName";
+    final String sessionId = "sessionId";
+    final String contextName = "contextName";
 
-    DeltaSession expectedSession = mock(DeltaSession.class);
+    final DeltaSession expectedSession = mock(DeltaSession.class);
     when(sessionCache.getSession(sessionId)).thenReturn(expectedSession);
     when(expectedSession.getContextName()).thenReturn(contextName);
     when(context.getName()).thenReturn(contextName);
 
-    Session session = manager.findSession(sessionId);
+    final Session session = manager.findSession(sessionId);
 
     assertThat(session).isEqualTo(expectedSession);
   }
 
   @Test
   public void removeProperlyDestroysSessionFromSessionCacheWhenSessionIsNotExpired() {
-    DeltaSession sessionToDestroy = mock(DeltaSession.class);
-    String sessionId = "sessionId";
+    final DeltaSession sessionToDestroy = mock(DeltaSession.class);
+    final String sessionId = "sessionId";
 
     when(sessionToDestroy.getId()).thenReturn(sessionId);
     when(sessionToDestroy.getExpired()).thenReturn(false);
@@ -179,8 +179,8 @@ public abstract class DeltaSessionManagerJUnitTest {
 
   @Test
   public void removeDoesNotDestroySessionFromSessionCacheWhenSessionIsExpired() {
-    DeltaSession sessionToDestroy = mock(DeltaSession.class);
-    String sessionId = "sessionId";
+    final DeltaSession sessionToDestroy = mock(DeltaSession.class);
+    final String sessionId = "sessionId";
 
     when(sessionToDestroy.getId()).thenReturn(sessionId);
     when(sessionToDestroy.getExpired()).thenReturn(true);
@@ -192,7 +192,7 @@ public abstract class DeltaSessionManagerJUnitTest {
 
   @Test
   public void addPutsSessionIntoSessionCacheAndIncrementsStats() {
-    DeltaSession sessionToPut = mock(DeltaSession.class);
+    final DeltaSession sessionToPut = mock(DeltaSession.class);
 
     manager.add(sessionToPut);
 
@@ -202,16 +202,16 @@ public abstract class DeltaSessionManagerJUnitTest {
 
   @Test
   public void listIdsListsAllPresentIds() {
-    Set<String> ids = new HashSet<>();
+    final Set<String> ids = new HashSet<>();
     ids.add("id1");
     ids.add("id2");
     ids.add("id3");
 
     when(sessionCache.keySet()).thenReturn(ids);
 
-    String listOutput = manager.listSessionIds();
+    final String listOutput = manager.listSessionIds();
 
-    for (String id : ids) {
+    for (final String id : ids) {
       assertThat(listOutput).contains(id);
     }
   }
@@ -219,10 +219,10 @@ public abstract class DeltaSessionManagerJUnitTest {
   @Test
   public void loadActivatesAndAddsSingleSessionWithValidIdAndMoreRecentAccessTime()
       throws IOException, ClassNotFoundException {
-    String contextPath = "contextPath";
-    String expectedStoreDir = "";
-    DeltaSession newSession = mock(DeltaSession.class);
-    DeltaSession existingSession = mock(DeltaSession.class);
+    final String contextPath = "contextPath";
+    final String expectedStoreDir = "";
+    final DeltaSession newSession = mock(DeltaSession.class);
+    final DeltaSession existingSession = mock(DeltaSession.class);
 
     prepareMocksForLoadTest(contextPath, newSession, existingSession, expectedStoreDir);
 
@@ -235,10 +235,10 @@ public abstract class DeltaSessionManagerJUnitTest {
   @Test
   public void loadLogsWarningAndDoesNotAddSessionWhenSessionStoreNotFound()
       throws IOException, ClassNotFoundException {
-    String contextPath = "contextPath";
-    String expectedStoreDir = "";
-    DeltaSession newSession = mock(DeltaSession.class);
-    DeltaSession existingSession = mock(DeltaSession.class);
+    final String contextPath = "contextPath";
+    final String expectedStoreDir = "";
+    final DeltaSession newSession = mock(DeltaSession.class);
+    final DeltaSession existingSession = mock(DeltaSession.class);
 
     prepareMocksForLoadTest(contextPath, newSession, existingSession, expectedStoreDir);
 
@@ -253,10 +253,10 @@ public abstract class DeltaSessionManagerJUnitTest {
   @Test
   public void loadDoesNotAddSessionToManagerWithValidIdAndLessRecentAccessTime()
       throws IOException, ClassNotFoundException {
-    String contextPath = "contextPath";
-    String expectedStoreDir = "";
-    DeltaSession newSession = mock(DeltaSession.class);
-    DeltaSession existingSession = mock(DeltaSession.class);
+    final String contextPath = "contextPath";
+    final String expectedStoreDir = "";
+    final DeltaSession newSession = mock(DeltaSession.class);
+    final DeltaSession existingSession = mock(DeltaSession.class);
 
     prepareMocksForLoadTest(contextPath, newSession, existingSession, expectedStoreDir);
 
@@ -272,11 +272,11 @@ public abstract class DeltaSessionManagerJUnitTest {
   public void unloadWritesSingleSessionToDiskWhenIdIsValid()
       throws IOException, NameResolutionException, TypeMismatchException,
       QueryInvocationTargetException, FunctionDomainException {
-    String sessionId = "sessionId";
-    DeltaSession session = mock(DeltaSession.class);
-    FileOutputStream fos = mock(FileOutputStream.class);
-    BufferedOutputStream bos = mock(BufferedOutputStream.class);
-    ObjectOutputStream oos = mock(ObjectOutputStream.class);
+    final String sessionId = "sessionId";
+    final DeltaSession session = mock(DeltaSession.class);
+    final FileOutputStream fos = mock(FileOutputStream.class);
+    final BufferedOutputStream bos = mock(BufferedOutputStream.class);
+    final ObjectOutputStream oos = mock(ObjectOutputStream.class);
 
     prepareMocksForUnloadTest(sessionId, fos, bos, oos, session);
 
@@ -289,17 +289,17 @@ public abstract class DeltaSessionManagerJUnitTest {
   public void unloadDoesNotWriteSessionToDiskAndClosesOutputStreamsWhenOutputStreamThrowsIOException()
       throws IOException, NameResolutionException, TypeMismatchException,
       QueryInvocationTargetException, FunctionDomainException {
-    String sessionId = "sessionId";
-    DeltaSession session = mock(DeltaSession.class);
-    FileOutputStream fos = mock(FileOutputStream.class);
-    BufferedOutputStream bos = mock(BufferedOutputStream.class);
-    ObjectOutputStream oos = mock(ObjectOutputStream.class);
+    final String sessionId = "sessionId";
+    final DeltaSession session = mock(DeltaSession.class);
+    final FileOutputStream fos = mock(FileOutputStream.class);
+    final BufferedOutputStream bos = mock(BufferedOutputStream.class);
+    final ObjectOutputStream oos = mock(ObjectOutputStream.class);
 
     prepareMocksForUnloadTest(sessionId, fos, bos, oos, session);
 
-    String exceptionMessage = "Output Stream IOException";
+    final String exceptionMessage = "Output Stream IOException";
 
-    IOException exception = new IOException(exceptionMessage);
+    final IOException exception = new IOException(exceptionMessage);
 
     doThrow(exception).when(manager).getObjectOutputStream(bos);
 
@@ -315,15 +315,15 @@ public abstract class DeltaSessionManagerJUnitTest {
   public void unloadDoesNotWriteSessionToDiskAndClosesOutputStreamsWhenSessionIsWrongClass()
       throws IOException, NameResolutionException, TypeMismatchException,
       QueryInvocationTargetException, FunctionDomainException {
-    String sessionId = "sessionId";
-    DeltaSession session = mock(DeltaSession.class);
-    FileOutputStream fos = mock(FileOutputStream.class);
-    BufferedOutputStream bos = mock(BufferedOutputStream.class);
-    ObjectOutputStream oos = mock(ObjectOutputStream.class);
+    final String sessionId = "sessionId";
+    final DeltaSession session = mock(DeltaSession.class);
+    final FileOutputStream fos = mock(FileOutputStream.class);
+    final BufferedOutputStream bos = mock(BufferedOutputStream.class);
+    final ObjectOutputStream oos = mock(ObjectOutputStream.class);
 
     prepareMocksForUnloadTest(sessionId, fos, bos, oos, session);
 
-    Session invalidSession =
+    final Session invalidSession =
         mock(Session.class, withSettings().extraInterfaces(DeltaSessionInterface.class));
 
     doReturn(invalidSession).when(manager).findSession(sessionId);
@@ -338,11 +338,11 @@ public abstract class DeltaSessionManagerJUnitTest {
   public void successfulUnloadWithClientServerSessionCachePerformsLocalDestroy()
       throws IOException, NameResolutionException, TypeMismatchException,
       QueryInvocationTargetException, FunctionDomainException {
-    String sessionId = "sessionId";
-    DeltaSession session = mock(DeltaSession.class);
-    FileOutputStream fos = mock(FileOutputStream.class);
-    BufferedOutputStream bos = mock(BufferedOutputStream.class);
-    ObjectOutputStream oos = mock(ObjectOutputStream.class);
+    final String sessionId = "sessionId";
+    final DeltaSession session = mock(DeltaSession.class);
+    final FileOutputStream fos = mock(FileOutputStream.class);
+    final BufferedOutputStream bos = mock(BufferedOutputStream.class);
+    final ObjectOutputStream oos = mock(ObjectOutputStream.class);
 
     prepareMocksForUnloadTest(sessionId, fos, bos, oos, session);
 
@@ -357,10 +357,10 @@ public abstract class DeltaSessionManagerJUnitTest {
 
   @Test
   public void propertyChangeSetsMaxInactiveIntervalWithCorrectPropertyNameAndValue() {
-    String propertyName = "sessionTimeout";
-    PropertyChangeEvent event = mock(PropertyChangeEvent.class);
-    Context eventContext = mock(Context.class);
-    Integer newValue = 1;
+    final String propertyName = "sessionTimeout";
+    final PropertyChangeEvent event = mock(PropertyChangeEvent.class);
+    final Context eventContext = mock(Context.class);
+    final Integer newValue = 1;
 
     when(event.getSource()).thenReturn(eventContext);
     when(event.getPropertyName()).thenReturn(propertyName);
@@ -373,9 +373,9 @@ public abstract class DeltaSessionManagerJUnitTest {
 
   @Test
   public void propertyChangeDoesNotSetMaxInactiveIntervalWithIncorrectPropertyName() {
-    String propertyName = "wrong name";
-    PropertyChangeEvent event = mock(PropertyChangeEvent.class);
-    Context eventContext = mock(Context.class);
+    final String propertyName = "wrong name";
+    final PropertyChangeEvent event = mock(PropertyChangeEvent.class);
+    final Context eventContext = mock(Context.class);
 
     when(event.getSource()).thenReturn(eventContext);
     when(event.getPropertyName()).thenReturn(propertyName);
@@ -387,11 +387,11 @@ public abstract class DeltaSessionManagerJUnitTest {
 
   @Test
   public void propertyChangeDoesNotSetNewMaxInactiveIntervalWithCorrectPropertyNameAndInvalidPropertyValue() {
-    String propertyName = "sessionTimeout";
-    PropertyChangeEvent event = mock(PropertyChangeEvent.class);
-    Context eventContext = mock(Context.class);
-    Integer newValue = -2;
-    Integer oldValue = DEFAULT_MAX_INACTIVE_INTERVAL;
+    final String propertyName = "sessionTimeout";
+    final PropertyChangeEvent event = mock(PropertyChangeEvent.class);
+    final Context eventContext = mock(Context.class);
+    final Integer newValue = -2;
+    final Integer oldValue = DEFAULT_MAX_INACTIVE_INTERVAL;
 
     when(event.getSource()).thenReturn(eventContext);
     when(event.getPropertyName()).thenReturn(propertyName);
@@ -403,20 +403,21 @@ public abstract class DeltaSessionManagerJUnitTest {
     verify(manager).setMaxInactiveInterval(oldValue);
   }
 
-  public void prepareMocksForUnloadTest(String sessionId, FileOutputStream fos,
-      BufferedOutputStream bos, ObjectOutputStream oos, DeltaSession session)
+  public void prepareMocksForUnloadTest(final String sessionId, final FileOutputStream fos,
+      final BufferedOutputStream bos, final ObjectOutputStream oos,
+      final DeltaSession session)
       throws NameResolutionException, TypeMismatchException, QueryInvocationTargetException,
       FunctionDomainException, IOException {
-    String regionName = "regionName";
-    String contextPath = "contextPath";
-    String catalinaBaseSystemProp = "Catalina/Base";
-    String systemFileSeparator = "/";
-    String expectedStoreDir = catalinaBaseSystemProp + systemFileSeparator + "temp";
+    final String regionName = "regionName";
+    final String contextPath = "contextPath";
+    final String catalinaBaseSystemProp = "Catalina/Base";
+    final String systemFileSeparator = "/";
+    final String expectedStoreDir = catalinaBaseSystemProp + systemFileSeparator + "temp";
 
-    InternalQueryService queryService = mock(InternalQueryService.class);
-    Query query = mock(Query.class);
-    File store = mock(File.class);
-    SelectResults results = new LinkedResultSet();
+    final InternalQueryService queryService = mock(InternalQueryService.class);
+    final Query query = mock(Query.class);
+    final File store = mock(File.class);
+    final SelectResults results = new LinkedResultSet();
 
     when(sessionCache.getCache()).thenReturn(cache);
     when(context.getPath()).thenReturn(contextPath);
@@ -438,19 +439,19 @@ public abstract class DeltaSessionManagerJUnitTest {
     results.add(sessionId);
   }
 
-  public void prepareMocksForLoadTest(String contextPath, DeltaSession newSession,
-      DeltaSession existingSession, String expectedStoreDir)
+  public void prepareMocksForLoadTest(final String contextPath, final DeltaSession newSession,
+      final DeltaSession existingSession, String expectedStoreDir)
       throws IOException, ClassNotFoundException {
-    String catalinaBaseSystemProp = "Catalina/Base";
-    String systemFileSeparator = "/";
+    final String catalinaBaseSystemProp = "Catalina/Base";
+    final String systemFileSeparator = "/";
     expectedStoreDir = catalinaBaseSystemProp + systemFileSeparator + "temp";
-    String newSessionId = "newSessionId";
+    final String newSessionId = "newSessionId";
 
-    File store = mock(File.class);
-    FileInputStream fis = mock(FileInputStream.class);
-    BufferedInputStream bis = mock(BufferedInputStream.class);
-    ObjectInputStream ois = mock(ObjectInputStream.class);
-    Loader loader = mock(Loader.class);
+    final File store = mock(File.class);
+    final FileInputStream fis = mock(FileInputStream.class);
+    final BufferedInputStream bis = mock(BufferedInputStream.class);
+    final ObjectInputStream ois = mock(ObjectInputStream.class);
+    final Loader loader = mock(Loader.class);
 
     when(context.getPath()).thenReturn(contextPath);
     when(context.getLoader()).thenReturn(loader);
diff --git a/extensions/geode-modules-test/src/main/java/org/apache/geode/modules/session/catalina/ClientServerSessionCacheJUnitTest.java b/extensions/geode-modules-test/src/main/java/org/apache/geode/modules/session/catalina/ClientServerSessionCacheJUnitTest.java
deleted file mode 100644
index 0ca0ce3..0000000
--- a/extensions/geode-modules-test/src/main/java/org/apache/geode/modules/session/catalina/ClientServerSessionCacheJUnitTest.java
+++ /dev/null
@@ -1,334 +0,0 @@
-/*
- * 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.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.mockito.Mockito.any;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.doThrow;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import javax.servlet.http.HttpSession;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.ArgumentCaptor;
-
-import org.apache.geode.Statistics;
-import org.apache.geode.cache.AttributesMutator;
-import org.apache.geode.cache.CacheListener;
-import org.apache.geode.cache.DataPolicy;
-import org.apache.geode.cache.InterestResultPolicy;
-import org.apache.geode.cache.RegionAttributes;
-import org.apache.geode.cache.RegionShortcut;
-import org.apache.geode.cache.client.ClientCache;
-import org.apache.geode.cache.client.ClientRegionFactory;
-import org.apache.geode.cache.client.ClientRegionShortcut;
-import org.apache.geode.cache.client.internal.InternalClientCache;
-import org.apache.geode.cache.client.internal.PoolImpl;
-import org.apache.geode.cache.execute.Function;
-import org.apache.geode.cache.execute.FunctionException;
-import org.apache.geode.cache.execute.ResultCollector;
-import org.apache.geode.internal.cache.GemFireCacheImpl;
-import org.apache.geode.modules.session.catalina.callback.SessionExpirationCacheListener;
-import org.apache.geode.modules.util.BootstrappingFunction;
-import org.apache.geode.modules.util.CreateRegionFunction;
-import org.apache.geode.modules.util.DebugCacheListener;
-import org.apache.geode.modules.util.RegionConfiguration;
-import org.apache.geode.modules.util.RegionStatus;
-import org.apache.geode.modules.util.SessionCustomExpiry;
-import org.apache.geode.modules.util.TouchPartitionedRegionEntriesFunction;
-import org.apache.geode.modules.util.TouchReplicatedRegionEntriesFunction;
-
-public class ClientServerSessionCacheJUnitTest extends AbstractSessionCacheJUnitTest {
-
-  private List<RegionStatus> regionStatusResultList = new ArrayList<>();
-  private ClientCache cache = mock(GemFireCacheImpl.class);
-  private ResultCollector collector = mock(ResultCollector.class);
-  private Statistics stats = mock(Statistics.class);
-  @SuppressWarnings("unchecked")
-  private ClientRegionFactory<String, HttpSession> regionFactory = mock(ClientRegionFactory.class);
-  @SuppressWarnings("unchecked")
-  private RegionAttributes<String, HttpSession> attributes = mock(RegionAttributes.class);
-
-  @Before
-  public void setUp() {
-    sessionCache = spy(new ClientServerSessionCache(sessionManager, cache));
-    doReturn(emptyExecution).when((ClientServerSessionCache) sessionCache)
-        .getExecutionForFunctionOnServers();
-    doReturn(emptyExecution).when((ClientServerSessionCache) sessionCache)
-        .getExecutionForFunctionOnServersWithArguments(any());
-    doReturn(emptyExecution).when((ClientServerSessionCache) sessionCache)
-        .getExecutionForFunctionOnServerWithRegionConfiguration(any());
-    doReturn(emptyExecution).when((ClientServerSessionCache) sessionCache)
-        .getExecutionForFunctionOnRegionWithFilter(any());
-
-    when(sessionManager.getLogger()).thenReturn(logger);
-    when(sessionManager.getEnableLocalCache()).thenReturn(true);
-    when(sessionManager.getRegionName()).thenReturn(sessionRegionName);
-    when(sessionManager.getMaxInactiveInterval())
-        .thenReturn(RegionConfiguration.DEFAULT_MAX_INACTIVE_INTERVAL);
-
-    when(cache.getDistributedSystem()).thenReturn(distributedSystem);
-    doReturn(regionFactory).when(cache)
-        .createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY_HEAP_LRU);
-    doReturn(sessionRegion).when(regionFactory).create(any());
-    when(((InternalClientCache) cache).isClient()).thenReturn(true);
-
-    when(emptyExecution.execute(any(Function.class))).thenReturn(collector);
-    when(emptyExecution.execute(any(String.class))).thenReturn(collector);
-
-    when(collector.getResult()).thenReturn(regionStatusResultList);
-
-    when(distributedSystem.createAtomicStatistics(any(), any())).thenReturn(stats);
-
-    regionStatusResultList.clear();
-    regionStatusResultList.add(RegionStatus.VALID);
-  }
-
-  @Test
-  public void initializeSessionCacheSucceeds() {
-    sessionCache.initialize();
-
-    verify(emptyExecution).execute(any(BootstrappingFunction.class));
-    verify(emptyExecution).execute(CreateRegionFunction.ID);
-    verify(cache).createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY_HEAP_LRU);
-    verify(regionFactory, times(0)).setStatisticsEnabled(true);
-    verify(regionFactory, times(0)).setCustomEntryIdleTimeout(any(SessionCustomExpiry.class));
-    verify(regionFactory, times(0)).addCacheListener(any(SessionExpirationCacheListener.class));
-    verify(regionFactory).create(sessionRegionName);
-  }
-
-  @Test
-  public void bootstrappingFunctionThrowsException() {
-    FunctionException exception = new FunctionException();
-
-    ResultCollector exceptionCollector = mock(ResultCollector.class);
-
-    when(emptyExecution.execute(new BootstrappingFunction())).thenReturn(exceptionCollector);
-    when(exceptionCollector.getResult()).thenThrow(exception);
-
-    sessionCache.initialize();
-
-    verify(logger).warn("Caught unexpected exception:", exception);
-  }
-
-
-  @Test
-  public void createOrRetrieveRegionThrowsException() {
-    RuntimeException exception = new RuntimeException();
-    doThrow(exception).when((ClientServerSessionCache) sessionCache).createLocalSessionRegion();
-
-    assertThatThrownBy(() -> sessionCache.initialize()).hasCause(exception)
-        .isInstanceOf(IllegalStateException.class);
-
-    verify(logger).fatal("Unable to create or retrieve region", exception);
-
-  }
-
-  @Test
-  public void createRegionFunctionFailsOnServer() {
-    ArgumentCaptor<String> stringCaptor = ArgumentCaptor.forClass(String.class);
-
-    regionStatusResultList.clear();
-    regionStatusResultList.add(RegionStatus.INVALID);
-
-    assertThatThrownBy(() -> sessionCache.initialize()).isInstanceOf(IllegalStateException.class)
-        .hasCauseInstanceOf(IllegalStateException.class).hasMessageContaining(
-            "An exception occurred on the server while attempting to create or validate region named "
-                + sessionRegionName
-                + ". See the server log for additional details.");
-
-    verify(logger).fatal(stringCaptor.capture(), any(Exception.class));
-    assertThat(stringCaptor.getValue()).isEqualTo("Unable to create or retrieve region");
-  }
-
-  @Test
-  public void nonDefaultMaxTimeoutIntervalSetsExpirationDetails() {
-    // Setting the mocked return value of getMaxInactiveInterval to something distinctly not equal
-    // to the default
-    when(sessionManager.getMaxInactiveInterval())
-        .thenReturn(RegionConfiguration.DEFAULT_MAX_INACTIVE_INTERVAL + 1);
-
-    sessionCache.initialize();
-
-    verify(regionFactory).setStatisticsEnabled(true);
-    verify(regionFactory).setCustomEntryIdleTimeout(any(SessionCustomExpiry.class));
-    verify(regionFactory).addCacheListener(any(SessionExpirationCacheListener.class));
-  }
-
-  @Test
-  public void createLocalSessionRegionWithoutEnableLocalCache() {
-    when(sessionManager.getEnableLocalCache()).thenReturn(false);
-    doReturn(regionFactory).when(cache).createClientRegionFactory(ClientRegionShortcut.PROXY);
-    when(regionFactory.create(sessionRegionName)).thenReturn(sessionRegion);
-
-    sessionCache.initialize();
-
-    verify(regionFactory).addCacheListener(any(SessionExpirationCacheListener.class));
-  }
-
-  @Test
-  public void createOrRetrieveRegionWithNonNullSessionRegionDoesNotCreateRegion() {
-    @SuppressWarnings("unchecked")
-    CacheListener<String, HttpSession>[] cacheListeners =
-        new CacheListener[] {new SessionExpirationCacheListener()};
-    doReturn(sessionRegion).when(cache).getRegion(sessionRegionName);
-    doReturn(attributes).when(sessionRegion).getAttributes();
-    doReturn(cacheListeners).when(attributes).getCacheListeners();
-
-    sessionCache.initialize();
-
-    verify((ClientServerSessionCache) sessionCache, times(0)).createSessionRegionOnServers();
-    verify((ClientServerSessionCache) sessionCache, times(0)).createLocalSessionRegion();
-  }
-
-  @Test
-  public void createOrRetrieveRegionWithNonNullSessionRegionAndNoSessionExpirationCacheListenerCreatesListener() {
-    @SuppressWarnings("unchecked")
-    CacheListener<String, HttpSession>[] cacheListeners =
-        new CacheListener[] {new DebugCacheListener()};
-    @SuppressWarnings("unchecked")
-    AttributesMutator<String, HttpSession> attributesMutator = mock(AttributesMutator.class);
-    doReturn(sessionRegion).when(cache).getRegion(sessionRegionName);
-    doReturn(attributes).when(sessionRegion).getAttributes();
-    doReturn(cacheListeners).when(attributes).getCacheListeners();
-    doReturn(attributesMutator).when(sessionRegion).getAttributesMutator();
-
-    sessionCache.initialize();
-
-    verify(attributesMutator).addCacheListener(any(SessionExpirationCacheListener.class));
-  }
-
-  @Test
-  public void createOrRetrieveRegionWithNonNullSessionProxyRegionRegistersInterestForAllKeys() {
-    @SuppressWarnings("unchecked")
-    CacheListener<String, HttpSession>[] cacheListeners =
-        new CacheListener[] {new SessionExpirationCacheListener()};
-    doReturn(sessionRegion).when(cache).getRegion(sessionRegionName);
-    doReturn(attributes).when(sessionRegion).getAttributes();
-    doReturn(cacheListeners).when(attributes).getCacheListeners();
-    when(attributes.getDataPolicy()).thenReturn(DataPolicy.DEFAULT);
-
-    sessionCache.initialize();
-
-    verify(sessionRegion).registerInterestForAllKeys(InterestResultPolicy.KEYS);
-  }
-
-  @Test
-  public void createOrRetrieveRegionWithNonNullSessionProxyRegionNotRegistersInterestIfEmpty() {
-    @SuppressWarnings("unchecked")
-    CacheListener<String, HttpSession>[] cacheListeners =
-        new CacheListener[] {new SessionExpirationCacheListener()};
-    doReturn(sessionRegion).when(cache).getRegion(sessionRegionName);
-    doReturn(attributes).when(sessionRegion).getAttributes();
-    doReturn(cacheListeners).when(attributes).getCacheListeners();
-    when(attributes.getDataPolicy()).thenReturn(DataPolicy.EMPTY);
-
-    sessionCache.initialize();
-
-    verify(sessionRegion, never()).registerInterestForAllKeys(InterestResultPolicy.KEYS);
-  }
-
-  @Test
-  public void touchSessionsInvokesPRFunctionForPRAndDoesNotThrowExceptionWhenFunctionDoesNotThrowException() {
-    Set<String> sessionIds = new HashSet<>();
-
-    when(sessionManager.getRegionAttributesId()).thenReturn(RegionShortcut.PARTITION.toString());
-
-    sessionCache.touchSessions(sessionIds);
-
-    verify(emptyExecution).execute(TouchPartitionedRegionEntriesFunction.ID);
-  }
-
-  @Test
-  public void touchSessionsInvokesPRFunctionForPRAndThrowsExceptionWhenFunctionThrowsException() {
-    Set<String> sessionIds = new HashSet<>();
-    FunctionException exception = new FunctionException();
-    ResultCollector exceptionCollector = mock(ResultCollector.class);
-
-    when(sessionManager.getRegionAttributesId()).thenReturn(RegionShortcut.PARTITION.toString());
-    when(emptyExecution.execute(TouchPartitionedRegionEntriesFunction.ID))
-        .thenReturn(exceptionCollector);
-    when(exceptionCollector.getResult()).thenThrow(exception);
-
-    sessionCache.touchSessions(sessionIds);
-    verify(logger).warn("Caught unexpected exception:", exception);
-  }
-
-  @Test
-  public void touchSessionsInvokesRRFunctionForRRAndDoesNotThrowExceptionWhenFunctionDoesNotThrowException() {
-    // Need to invoke this to set the session region
-    when(regionFactory.create(sessionRegionName)).thenReturn(sessionRegion);
-    sessionCache.initialize();
-
-    Set<String> sessionIds = new HashSet<>();
-
-    when(sessionRegion.getFullPath()).thenReturn("/" + sessionRegionName);
-    when(sessionManager.getRegionAttributesId()).thenReturn(RegionShortcut.REPLICATE.toString());
-
-    sessionCache.touchSessions(sessionIds);
-    verify(emptyExecution).execute(TouchReplicatedRegionEntriesFunction.ID);
-  }
-
-  @Test
-  public void touchSessionsInvokesRRFunctionForRRAndThrowsExceptionWhenFunctionThrowsException() {
-    // Need to invoke this to set the session region
-    when(regionFactory.create(sessionRegionName)).thenReturn(sessionRegion);
-    sessionCache.initialize();
-
-    Set<String> sessionIds = new HashSet<>();
-    FunctionException exception = new FunctionException();
-    ResultCollector exceptionCollector = mock(ResultCollector.class);
-
-    when(sessionRegion.getFullPath()).thenReturn("/" + sessionRegionName);
-    when(sessionManager.getRegionAttributesId()).thenReturn(RegionShortcut.REPLICATE.toString());
-    when(emptyExecution.execute(TouchReplicatedRegionEntriesFunction.ID))
-        .thenReturn(exceptionCollector);
-    when(exceptionCollector.getResult()).thenThrow(exception);
-
-    sessionCache.touchSessions(sessionIds);
-    verify(logger).warn("Caught unexpected exception:", exception);
-  }
-
-  @Test
-  public void isBackingCacheEnabledReturnsTrueWhenCommitValveFailfastDisabled() {
-    assertThat(sessionCache.isBackingCacheAvailable()).isTrue();
-  }
-
-  @Test
-  public void isBackingCacheEnabledReturnsValueWhenCommitValveFailfastEnabled() {
-    boolean backingCacheEnabled = false;
-    PoolImpl pool = mock(PoolImpl.class);
-
-    when(sessionManager.isCommitValveFailfastEnabled()).thenReturn(true);
-    doReturn(pool).when((ClientServerSessionCache) sessionCache).findPoolInPoolManager();
-    when(pool.isPrimaryUpdaterAlive()).thenReturn(backingCacheEnabled);
-
-    assertThat(sessionCache.isBackingCacheAvailable()).isEqualTo(backingCacheEnabled);
-  }
-}
diff --git a/extensions/geode-modules-tomcat7/src/integrationTest/java/org/apache/geode/modules/session/Tomcat7SessionsJUnitTest.java b/extensions/geode-modules-tomcat7/src/integrationTest/java/org/apache/geode/modules/session/Tomcat7SessionsTest.java
similarity index 87%
rename from extensions/geode-modules-tomcat7/src/integrationTest/java/org/apache/geode/modules/session/Tomcat7SessionsJUnitTest.java
rename to extensions/geode-modules-tomcat7/src/integrationTest/java/org/apache/geode/modules/session/Tomcat7SessionsTest.java
index 2c048d5..f37eedd 100644
--- a/extensions/geode-modules-tomcat7/src/integrationTest/java/org/apache/geode/modules/session/Tomcat7SessionsJUnitTest.java
+++ b/extensions/geode-modules-tomcat7/src/integrationTest/java/org/apache/geode/modules/session/Tomcat7SessionsTest.java
@@ -28,7 +28,7 @@ import org.apache.geode.modules.session.catalina.Tomcat7DeltaSessionManager;
 import org.apache.geode.test.junit.categories.HttpSessionTest;
 
 @Category({HttpSessionTest.class})
-public class Tomcat7SessionsJUnitTest extends TestSessionsBase {
+public class Tomcat7SessionsTest extends AbstractSessionsTest {
 
   // Set up the session manager we need
   @BeforeClass
@@ -45,11 +45,11 @@ public class Tomcat7SessionsJUnitTest extends TestSessionsBase {
     // TestSessions only live for a minute
     sessionManager.getTheContext().setSessionTimeout(1);
 
-    String key = "value_testSessionExpiration1";
-    String value = "Foo";
+    final String key = "value_testSessionExpiration1";
+    final String value = "Foo";
 
-    WebConversation wc = new WebConversation();
-    WebRequest req = new GetMethodWebRequest(String.format("http://localhost:%d/test", port));
+    final WebConversation wc = new WebConversation();
+    final WebRequest req = new GetMethodWebRequest(String.format("http://localhost:%d/test", port));
 
     // Set an attribute
     req.setParameter("cmd", QueryCommand.SET.name());
diff --git a/extensions/geode-modules-tomcat7/src/test/java/org/apache/geode/modules/session/catalina/Tomcat7DeltaSessionManagerJUnitTest.java b/extensions/geode-modules-tomcat7/src/test/java/org/apache/geode/modules/session/catalina/Tomcat7DeltaSessionManagerTest.java
similarity index 96%
rename from extensions/geode-modules-tomcat7/src/test/java/org/apache/geode/modules/session/catalina/Tomcat7DeltaSessionManagerJUnitTest.java
rename to extensions/geode-modules-tomcat7/src/test/java/org/apache/geode/modules/session/catalina/Tomcat7DeltaSessionManagerTest.java
index f1bee51..e6fd534 100644
--- a/extensions/geode-modules-tomcat7/src/test/java/org/apache/geode/modules/session/catalina/Tomcat7DeltaSessionManagerJUnitTest.java
+++ b/extensions/geode-modules-tomcat7/src/test/java/org/apache/geode/modules/session/catalina/Tomcat7DeltaSessionManagerTest.java
@@ -34,7 +34,7 @@ import org.junit.Test;
 
 import org.apache.geode.internal.cache.GemFireCacheImpl;
 
-public class Tomcat7DeltaSessionManagerJUnitTest extends DeltaSessionManagerJUnitTest {
+public class Tomcat7DeltaSessionManagerTest extends AbstractDeltaSessionManagerTest {
   private Pipeline pipeline;
 
   @Before
@@ -118,8 +118,8 @@ public class Tomcat7DeltaSessionManagerJUnitTest extends DeltaSessionManagerJUni
 
   @Test
   public void setContainerSetsProperContainerAndMaxInactiveInterval() {
-    Context container = mock(Context.class);
-    int containerMaxInactiveInterval = 3;
+    final Context container = mock(Context.class);
+    final int containerMaxInactiveInterval = 3;
 
     doReturn(containerMaxInactiveInterval).when(container).getSessionTimeout();
 
diff --git a/extensions/geode-modules-tomcat8/src/test/java/org/apache/geode/modules/session/catalina/Tomcat8DeltaSessionManagerJUnitTest.java b/extensions/geode-modules-tomcat8/src/test/java/org/apache/geode/modules/session/catalina/Tomcat8DeltaSessionManagerTest.java
similarity index 98%
rename from extensions/geode-modules-tomcat8/src/test/java/org/apache/geode/modules/session/catalina/Tomcat8DeltaSessionManagerJUnitTest.java
rename to extensions/geode-modules-tomcat8/src/test/java/org/apache/geode/modules/session/catalina/Tomcat8DeltaSessionManagerTest.java
index 1bf7939..c293be3 100644
--- a/extensions/geode-modules-tomcat8/src/test/java/org/apache/geode/modules/session/catalina/Tomcat8DeltaSessionManagerJUnitTest.java
+++ b/extensions/geode-modules-tomcat8/src/test/java/org/apache/geode/modules/session/catalina/Tomcat8DeltaSessionManagerTest.java
@@ -33,7 +33,7 @@ import org.junit.Test;
 
 import org.apache.geode.internal.cache.GemFireCacheImpl;
 
-public class Tomcat8DeltaSessionManagerJUnitTest extends DeltaSessionManagerJUnitTest {
+public class Tomcat8DeltaSessionManagerTest extends AbstractDeltaSessionManagerTest {
   private Pipeline pipeline;
 
   @Before
diff --git a/extensions/geode-modules-tomcat9/src/test/java/org/apache/geode/modules/session/catalina/Tomcat9DeltaSessionManagerJUnitTest.java b/extensions/geode-modules-tomcat9/src/test/java/org/apache/geode/modules/session/catalina/Tomcat9DeltaSessionManagerTest.java
similarity index 98%
rename from extensions/geode-modules-tomcat9/src/test/java/org/apache/geode/modules/session/catalina/Tomcat9DeltaSessionManagerJUnitTest.java
rename to extensions/geode-modules-tomcat9/src/test/java/org/apache/geode/modules/session/catalina/Tomcat9DeltaSessionManagerTest.java
index cc55763..5cdeb058 100644
--- a/extensions/geode-modules-tomcat9/src/test/java/org/apache/geode/modules/session/catalina/Tomcat9DeltaSessionManagerJUnitTest.java
+++ b/extensions/geode-modules-tomcat9/src/test/java/org/apache/geode/modules/session/catalina/Tomcat9DeltaSessionManagerTest.java
@@ -33,7 +33,7 @@ import org.junit.Test;
 
 import org.apache.geode.internal.cache.GemFireCacheImpl;
 
-public class Tomcat9DeltaSessionManagerJUnitTest extends DeltaSessionManagerJUnitTest {
+public class Tomcat9DeltaSessionManagerTest extends AbstractDeltaSessionManagerTest {
   private Pipeline pipeline;
 
   @Before
diff --git a/extensions/geode-modules/src/integrationTest/java/org/apache/geode/modules/session/Tomcat6SessionsJUnitTest.java b/extensions/geode-modules/src/integrationTest/java/org/apache/geode/modules/session/Tomcat6SessionsTest.java
similarity index 88%
rename from extensions/geode-modules/src/integrationTest/java/org/apache/geode/modules/session/Tomcat6SessionsJUnitTest.java
rename to extensions/geode-modules/src/integrationTest/java/org/apache/geode/modules/session/Tomcat6SessionsTest.java
index a80feb2..47da3f4 100644
--- a/extensions/geode-modules/src/integrationTest/java/org/apache/geode/modules/session/Tomcat6SessionsJUnitTest.java
+++ b/extensions/geode-modules/src/integrationTest/java/org/apache/geode/modules/session/Tomcat6SessionsTest.java
@@ -21,8 +21,8 @@ import org.apache.geode.modules.session.catalina.Tomcat6DeltaSessionManager;
 import org.apache.geode.test.junit.categories.SessionTest;
 
 @Category(SessionTest.class)
-// TODO: Remove the entire class once Tomcat6DeltaSessionManager is removed from the product.
-public class Tomcat6SessionsJUnitTest extends TestSessionsBase {
+@Deprecated
+public class Tomcat6SessionsTest extends AbstractSessionsTest {
 
   @BeforeClass
   public static void setupClass() throws Exception {
diff --git a/extensions/geode-modules-test/src/main/java/org/apache/geode/modules/session/catalina/AbstractSessionCacheJUnitTest.java b/extensions/geode-modules/src/test/java/org/apache/geode/modules/session/catalina/AbstractSessionCacheTest.java
similarity index 86%
rename from extensions/geode-modules-test/src/main/java/org/apache/geode/modules/session/catalina/AbstractSessionCacheJUnitTest.java
rename to extensions/geode-modules/src/test/java/org/apache/geode/modules/session/catalina/AbstractSessionCacheTest.java
index 99906cc..c40ac1e 100644
--- a/extensions/geode-modules-test/src/main/java/org/apache/geode/modules/session/catalina/AbstractSessionCacheJUnitTest.java
+++ b/extensions/geode-modules/src/test/java/org/apache/geode/modules/session/catalina/AbstractSessionCacheTest.java
@@ -15,6 +15,7 @@
 
 package org.apache.geode.modules.session.catalina;
 
+import static org.apache.geode.util.internal.UncheckedUtils.uncheckedCast;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.anyInt;
 import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
@@ -26,6 +27,8 @@ import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
+import java.util.List;
+
 import javax.servlet.http.HttpSession;
 
 import org.apache.juli.logging.Log;
@@ -39,14 +42,13 @@ import org.apache.geode.cache.execute.Execution;
 import org.apache.geode.distributed.DistributedSystem;
 import org.apache.geode.modules.util.RegionConfiguration;
 
-public abstract class AbstractSessionCacheJUnitTest {
+public abstract class AbstractSessionCacheTest {
 
   protected String sessionRegionName = "sessionRegion";
-  private String sessionRegionAttributesId = RegionShortcut.PARTITION.toString();
-  private int nonDefaultMaxInactiveInterval = RegionConfiguration.DEFAULT_MAX_INACTIVE_INTERVAL + 1;
-  private boolean gatewayDeltaReplicationEnabled = true;
-  private boolean gatewayReplicationEnabled = true;
-  private boolean enableDebugListener = true;
+  private final String sessionRegionAttributesId = RegionShortcut.PARTITION.toString();
+  private final boolean gatewayDeltaReplicationEnabled = true;
+  private final boolean gatewayReplicationEnabled = true;
+  private final boolean enableDebugListener = true;
 
 
   protected SessionManager sessionManager = mock(SessionManager.class);
@@ -54,13 +56,14 @@ public abstract class AbstractSessionCacheJUnitTest {
   protected Region<String, HttpSession> sessionRegion = mock(Region.class, RETURNS_DEEP_STUBS);
   protected DistributedSystem distributedSystem = mock(DistributedSystem.class);
   protected Log logger = mock(Log.class);
-  protected Execution emptyExecution = mock(Execution.class);
+  protected Execution<Object, Object, List<Object>> emptyExecution =
+      uncheckedCast(mock(Execution.class));
 
   protected AbstractSessionCache sessionCache;
 
   @Test
   public void createRegionConfigurationSetsAppropriateValuesWithDefaultMaxInactiveInterval() {
-    RegionConfiguration config = spy(new RegionConfiguration());
+    final RegionConfiguration config = spy(new RegionConfiguration());
     doReturn(config).when(sessionCache).getNewRegionConfiguration();
 
     when(sessionManager.getRegionName()).thenReturn(sessionRegionName);
@@ -85,11 +88,12 @@ public abstract class AbstractSessionCacheJUnitTest {
 
   @Test
   public void createRegionConfigurationSetsAppropriateValuesWithNonDefaultMaxInactiveInterval() {
-    RegionConfiguration config = spy(new RegionConfiguration());
+    final RegionConfiguration config = spy(new RegionConfiguration());
     doReturn(config).when(sessionCache).getNewRegionConfiguration();
 
     when(sessionManager.getRegionName()).thenReturn(sessionRegionName);
     when(sessionManager.getRegionAttributesId()).thenReturn(sessionRegionAttributesId);
+    final int nonDefaultMaxInactiveInterval = RegionConfiguration.DEFAULT_MAX_INACTIVE_INTERVAL + 1;
     when(sessionManager.getMaxInactiveInterval()).thenReturn(nonDefaultMaxInactiveInterval);
     when(sessionManager.getEnableGatewayDeltaReplication())
         .thenReturn(gatewayDeltaReplicationEnabled);
@@ -109,8 +113,8 @@ public abstract class AbstractSessionCacheJUnitTest {
 
   @Test
   public void destroySessionDoesNotThrowExceptionWhenGetOperatingRegionThrowsEntryNotFoundException() {
-    EntryNotFoundException exception = new EntryNotFoundException("Entry not found.");
-    String sessionId = "sessionId";
+    final EntryNotFoundException exception = new EntryNotFoundException("Entry not found.");
+    final String sessionId = "sessionId";
     // For Client/Server the operating Region is always the session Region, for peer to peer this is
     // only true when
     // local caching is not enabled. For the purposes of this test the behavior is equivalent
diff --git a/extensions/geode-modules/src/test/java/org/apache/geode/modules/session/catalina/ClientServerSessionCacheTest.java b/extensions/geode-modules/src/test/java/org/apache/geode/modules/session/catalina/ClientServerSessionCacheTest.java
index c8f59ee..1307579 100644
--- a/extensions/geode-modules/src/test/java/org/apache/geode/modules/session/catalina/ClientServerSessionCacheTest.java
+++ b/extensions/geode-modules/src/test/java/org/apache/geode/modules/session/catalina/ClientServerSessionCacheTest.java
@@ -12,32 +12,323 @@
  * 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.cache.Region.SEPARATOR;
+import static org.apache.geode.util.internal.UncheckedUtils.uncheckedCast;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
 import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
+import static org.mockito.Mockito.any;
 import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.doThrow;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.never;
 import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.servlet.http.HttpSession;
 
+import org.junit.Before;
 import org.junit.Test;
+import org.mockito.ArgumentCaptor;
 
+import org.apache.geode.Statistics;
+import org.apache.geode.cache.AttributesMutator;
+import org.apache.geode.cache.CacheListener;
 import org.apache.geode.cache.DataPolicy;
 import org.apache.geode.cache.InterestResultPolicy;
 import org.apache.geode.cache.Region;
 import org.apache.geode.cache.RegionAttributes;
+import org.apache.geode.cache.RegionShortcut;
 import org.apache.geode.cache.client.ClientCache;
+import org.apache.geode.cache.client.ClientRegionFactory;
+import org.apache.geode.cache.client.ClientRegionShortcut;
+import org.apache.geode.cache.client.internal.InternalClientCache;
+import org.apache.geode.cache.client.internal.PoolImpl;
+import org.apache.geode.cache.execute.Function;
+import org.apache.geode.cache.execute.FunctionException;
+import org.apache.geode.cache.execute.ResultCollector;
+import org.apache.geode.internal.cache.GemFireCacheImpl;
+import org.apache.geode.modules.session.catalina.callback.SessionExpirationCacheListener;
+import org.apache.geode.modules.util.BootstrappingFunction;
+import org.apache.geode.modules.util.CreateRegionFunction;
+import org.apache.geode.modules.util.DebugCacheListener;
+import org.apache.geode.modules.util.RegionConfiguration;
+import org.apache.geode.modules.util.RegionStatus;
+import org.apache.geode.modules.util.SessionCustomExpiry;
+import org.apache.geode.modules.util.TouchPartitionedRegionEntriesFunction;
+import org.apache.geode.modules.util.TouchReplicatedRegionEntriesFunction;
+
+public class ClientServerSessionCacheTest extends AbstractSessionCacheTest {
+
+  private final List<Object> regionStatusResultList = new ArrayList<>();
+  private final ClientCache cache = mock(GemFireCacheImpl.class);
+  private final ResultCollector<Object, List<Object>> collector =
+      uncheckedCast(mock(ResultCollector.class));
+  private final Statistics stats = mock(Statistics.class);
+  private final ClientRegionFactory<String, HttpSession> regionFactory =
+      uncheckedCast(mock(ClientRegionFactory.class));
+  private final RegionAttributes<String, HttpSession> attributes =
+      uncheckedCast(mock(RegionAttributes.class));
+
+  @Before
+  public void setUp() {
+    sessionCache = spy(new ClientServerSessionCache(sessionManager, cache));
+    doReturn(emptyExecution).when((ClientServerSessionCache) sessionCache)
+        .getExecutionForFunctionOnServers();
+    doReturn(emptyExecution).when((ClientServerSessionCache) sessionCache)
+        .getExecutionForFunctionOnServersWithArguments(any());
+    doReturn(emptyExecution).when((ClientServerSessionCache) sessionCache)
+        .getExecutionForFunctionOnServerWithRegionConfiguration(any());
+    doReturn(emptyExecution).when((ClientServerSessionCache) sessionCache)
+        .getExecutionForFunctionOnRegionWithFilter(any());
+
+    when(sessionManager.getLogger()).thenReturn(logger);
+    when(sessionManager.getEnableLocalCache()).thenReturn(true);
+    when(sessionManager.getRegionName()).thenReturn(sessionRegionName);
+    when(sessionManager.getMaxInactiveInterval())
+        .thenReturn(RegionConfiguration.DEFAULT_MAX_INACTIVE_INTERVAL);
+
+    when(cache.getDistributedSystem()).thenReturn(distributedSystem);
+    doReturn(regionFactory).when(cache)
+        .createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY_HEAP_LRU);
+    doReturn(sessionRegion).when(regionFactory).create(any());
+    when(((InternalClientCache) cache).isClient()).thenReturn(true);
+
+    when(emptyExecution.execute(any(Function.class))).thenReturn(collector);
+    when(emptyExecution.execute(any(String.class))).thenReturn(collector);
+
+    when(collector.getResult()).thenReturn(regionStatusResultList);
+
+    when(distributedSystem.createAtomicStatistics(any(), any())).thenReturn(stats);
+
+    regionStatusResultList.clear();
+    regionStatusResultList.add(RegionStatus.VALID);
+  }
+
+  @Test
+  public void initializeSessionCacheSucceeds() {
+    sessionCache.initialize();
+
+    verify(emptyExecution).execute(any(BootstrappingFunction.class));
+    verify(emptyExecution).execute(CreateRegionFunction.ID);
+    verify(cache).createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY_HEAP_LRU);
+    verify(regionFactory, times(0)).setStatisticsEnabled(true);
+    verify(regionFactory, times(0)).setCustomEntryIdleTimeout(any(SessionCustomExpiry.class));
+    verify(regionFactory, times(0)).addCacheListener(any(SessionExpirationCacheListener.class));
+    verify(regionFactory).create(sessionRegionName);
+  }
+
+  @Test
+  public void bootstrappingFunctionThrowsException() {
+    final FunctionException exception = new FunctionException();
+
+    final ResultCollector<Object, List<Object>> exceptionCollector =
+        uncheckedCast(mock(ResultCollector.class));
+
+    when(emptyExecution.execute(new BootstrappingFunction())).thenReturn(exceptionCollector);
+    when(exceptionCollector.getResult()).thenThrow(exception);
+
+    sessionCache.initialize();
+
+    verify(logger).warn("Caught unexpected exception:", exception);
+  }
+
+
+  @Test
+  public void createOrRetrieveRegionThrowsException() {
+    final RuntimeException exception = new RuntimeException();
+    doThrow(exception).when((ClientServerSessionCache) sessionCache).createLocalSessionRegion();
+
+    assertThatThrownBy(() -> sessionCache.initialize()).hasCause(exception)
+        .isInstanceOf(IllegalStateException.class);
+
+    verify(logger).fatal("Unable to create or retrieve region", exception);
+
+  }
+
+  @Test
+  public void createRegionFunctionFailsOnServer() {
+    final ArgumentCaptor<String> stringCaptor = ArgumentCaptor.forClass(String.class);
+
+    regionStatusResultList.clear();
+    regionStatusResultList.add(RegionStatus.INVALID);
+
+    assertThatThrownBy(() -> sessionCache.initialize()).isInstanceOf(IllegalStateException.class)
+        .hasCauseInstanceOf(IllegalStateException.class).hasMessageContaining(
+            "An exception occurred on the server while attempting to create or validate region named "
+                + sessionRegionName
+                + ". See the server log for additional details.");
+
+    verify(logger).fatal(stringCaptor.capture(), any(Exception.class));
+    assertThat(stringCaptor.getValue()).isEqualTo("Unable to create or retrieve region");
+  }
+
+  @Test
+  public void nonDefaultMaxTimeoutIntervalSetsExpirationDetails() {
+    // Setting the mocked return value of getMaxInactiveInterval to something distinctly not equal
+    // to the default
+    when(sessionManager.getMaxInactiveInterval())
+        .thenReturn(RegionConfiguration.DEFAULT_MAX_INACTIVE_INTERVAL + 1);
+
+    sessionCache.initialize();
+
+    verify(regionFactory).setStatisticsEnabled(true);
+    verify(regionFactory).setCustomEntryIdleTimeout(any(SessionCustomExpiry.class));
+    verify(regionFactory).addCacheListener(any(SessionExpirationCacheListener.class));
+  }
+
+  @Test
+  public void createLocalSessionRegionWithoutEnableLocalCache() {
+    when(sessionManager.getEnableLocalCache()).thenReturn(false);
+    doReturn(regionFactory).when(cache).createClientRegionFactory(ClientRegionShortcut.PROXY);
+    when(regionFactory.create(sessionRegionName)).thenReturn(sessionRegion);
+
+    sessionCache.initialize();
+
+    verify(regionFactory).addCacheListener(any(SessionExpirationCacheListener.class));
+    verify(sessionRegion).registerInterestForAllKeys(InterestResultPolicy.KEYS);
+  }
 
-public class ClientServerSessionCacheTest {
+  @Test
+  public void createOrRetrieveRegionWithNonNullSessionRegionDoesNotCreateRegion() {
+    final CacheListener<String, HttpSession>[] cacheListeners =
+        uncheckedCast(new CacheListener[] {new SessionExpirationCacheListener()});
+    doReturn(sessionRegion).when(cache).getRegion(sessionRegionName);
+    doReturn(attributes).when(sessionRegion).getAttributes();
+    doReturn(cacheListeners).when(attributes).getCacheListeners();
+
+    sessionCache.initialize();
+
+    verify((ClientServerSessionCache) sessionCache, times(0)).createSessionRegionOnServers();
+    verify((ClientServerSessionCache) sessionCache, times(0)).createLocalSessionRegion();
+  }
+
+  @Test
+  public void createOrRetrieveRegionWithNonNullSessionRegionAndNoSessionExpirationCacheListenerCreatesListener() {
+    final CacheListener<String, HttpSession>[] cacheListeners =
+        uncheckedCast(new CacheListener[] {new DebugCacheListener()});
+    final AttributesMutator<String, HttpSession> attributesMutator =
+        uncheckedCast(mock(AttributesMutator.class));
+    doReturn(sessionRegion).when(cache).getRegion(sessionRegionName);
+    doReturn(attributes).when(sessionRegion).getAttributes();
+    doReturn(cacheListeners).when(attributes).getCacheListeners();
+    doReturn(attributesMutator).when(sessionRegion).getAttributesMutator();
+
+    sessionCache.initialize();
+
+    verify(attributesMutator).addCacheListener(any(SessionExpirationCacheListener.class));
+  }
+
+  @Test
+  public void createOrRetrieveRegionWithNonNullSessionProxyRegionRegistersInterestForAllKeys() {
+    final CacheListener<String, HttpSession>[] cacheListeners =
+        uncheckedCast(new CacheListener[] {new SessionExpirationCacheListener()});
+    doReturn(sessionRegion).when(cache).getRegion(sessionRegionName);
+    doReturn(attributes).when(sessionRegion).getAttributes();
+    doReturn(cacheListeners).when(attributes).getCacheListeners();
+    when(attributes.getDataPolicy()).thenReturn(DataPolicy.DEFAULT);
+
+    sessionCache.initialize();
 
+    verify(sessionRegion).registerInterestForAllKeys(InterestResultPolicy.KEYS);
+  }
+
+  @Test
+  public void touchSessionsInvokesPRFunctionForPRAndDoesNotThrowExceptionWhenFunctionDoesNotThrowException() {
+    final Set<String> sessionIds = new HashSet<>();
+
+    when(sessionManager.getRegionAttributesId()).thenReturn(RegionShortcut.PARTITION.toString());
+
+    sessionCache.touchSessions(sessionIds);
+
+    verify(emptyExecution).execute(TouchPartitionedRegionEntriesFunction.ID);
+  }
+
+  @Test
+  public void touchSessionsInvokesPRFunctionForPRAndThrowsExceptionWhenFunctionThrowsException() {
+    final Set<String> sessionIds = new HashSet<>();
+    final FunctionException exception = new FunctionException();
+    final ResultCollector<Object, List<Object>> exceptionCollector =
+        uncheckedCast(mock(ResultCollector.class));
+
+    when(sessionManager.getRegionAttributesId()).thenReturn(RegionShortcut.PARTITION.toString());
+    when(emptyExecution.execute(TouchPartitionedRegionEntriesFunction.ID))
+        .thenReturn(exceptionCollector);
+    when(exceptionCollector.getResult()).thenThrow(exception);
+
+    sessionCache.touchSessions(sessionIds);
+    verify(logger).warn("Caught unexpected exception:", exception);
+  }
+
+  @Test
+  public void touchSessionsInvokesRRFunctionForRRAndDoesNotThrowExceptionWhenFunctionDoesNotThrowException() {
+    // Need to invoke this to set the session region
+    when(regionFactory.create(sessionRegionName)).thenReturn(sessionRegion);
+    sessionCache.initialize();
+
+    final Set<String> sessionIds = new HashSet<>();
+
+    when(sessionRegion.getFullPath()).thenReturn(SEPARATOR + sessionRegionName);
+    when(sessionManager.getRegionAttributesId()).thenReturn(RegionShortcut.REPLICATE.toString());
+
+    sessionCache.touchSessions(sessionIds);
+    verify(emptyExecution).execute(TouchReplicatedRegionEntriesFunction.ID);
+  }
+
+  @Test
+  public void touchSessionsInvokesRRFunctionForRRAndThrowsExceptionWhenFunctionThrowsException() {
+    // Need to invoke this to set the session region
+    when(regionFactory.create(sessionRegionName)).thenReturn(sessionRegion);
+    sessionCache.initialize();
+
+    final Set<String> sessionIds = new HashSet<>();
+    final FunctionException exception = new FunctionException();
+    final ResultCollector<Object, List<Object>> exceptionCollector =
+        uncheckedCast(mock(ResultCollector.class));
+
+    when(sessionRegion.getFullPath()).thenReturn(SEPARATOR + sessionRegionName);
+    when(sessionManager.getRegionAttributesId()).thenReturn(RegionShortcut.REPLICATE.toString());
+    when(emptyExecution.execute(TouchReplicatedRegionEntriesFunction.ID))
+        .thenReturn(exceptionCollector);
+    when(exceptionCollector.getResult()).thenThrow(exception);
+
+    sessionCache.touchSessions(sessionIds);
+    verify(logger).warn("Caught unexpected exception:", exception);
+  }
+
+  @Test
+  public void isBackingCacheEnabledReturnsTrueWhenCommitValveFailfastDisabled() {
+    assertThat(sessionCache.isBackingCacheAvailable()).isTrue();
+  }
+
+  @Test
+  public void isBackingCacheEnabledReturnsValueWhenCommitValveFailfastEnabled() {
+    final boolean backingCacheEnabled = false;
+    final PoolImpl pool = mock(PoolImpl.class);
+
+    when(sessionManager.isCommitValveFailfastEnabled()).thenReturn(true);
+    doReturn(pool).when((ClientServerSessionCache) sessionCache).findPoolInPoolManager();
+    when(pool.isPrimaryUpdaterAlive()).thenReturn(backingCacheEnabled);
+
+    assertThat(sessionCache.isBackingCacheAvailable()).isEqualTo(backingCacheEnabled);
+  }
 
   @Test
   public void registerInterestForSessionRegion() {
-    SessionManager manager = mock(SessionManager.class);
-    ClientCache clientCache = mock(ClientCache.class);
-    Region region = mock(Region.class, RETURNS_DEEP_STUBS);
-    ClientServerSessionCache cache = spy(new ClientServerSessionCache(manager, clientCache));
+    final SessionManager manager = mock(SessionManager.class);
+    final ClientCache clientCache = mock(ClientCache.class);
+    final Region region = mock(Region.class, RETURNS_DEEP_STUBS);
+    final ClientServerSessionCache cache = spy(new ClientServerSessionCache(manager, clientCache));
     doReturn(region).when(cache).createLocalSessionRegion();
 
     cache.createLocalSessionRegionWithRegisterInterest();
diff --git a/extensions/geode-modules-test/src/main/java/org/apache/geode/modules/session/catalina/DeltaSessionFacadeJUnitTest.java b/extensions/geode-modules/src/test/java/org/apache/geode/modules/session/catalina/DeltaSessionFacadeTest.java
similarity index 88%
rename from extensions/geode-modules-test/src/main/java/org/apache/geode/modules/session/catalina/DeltaSessionFacadeJUnitTest.java
rename to extensions/geode-modules/src/test/java/org/apache/geode/modules/session/catalina/DeltaSessionFacadeTest.java
index 81254c7..0dac329 100644
--- a/extensions/geode-modules-test/src/main/java/org/apache/geode/modules/session/catalina/DeltaSessionFacadeJUnitTest.java
+++ b/extensions/geode-modules/src/test/java/org/apache/geode/modules/session/catalina/DeltaSessionFacadeTest.java
@@ -22,13 +22,13 @@ import static org.mockito.Mockito.verify;
 
 import org.junit.Test;
 
-public class DeltaSessionFacadeJUnitTest {
+public class DeltaSessionFacadeTest {
 
   @Test
   public void DeltaSessionFacadeMakesProperCallsOnSessionWhenInvoked() {
-    DeltaSessionInterface session = spy(new DeltaSession());
+    final DeltaSessionInterface session = spy(new DeltaSession());
 
-    DeltaSessionFacade facade = new DeltaSessionFacade(session);
+    final DeltaSessionFacade facade = new DeltaSessionFacade(session);
 
     doNothing().when(session).commit();
     doReturn(true).when(session).isValid();
diff --git a/extensions/geode-modules-test/src/main/java/org/apache/geode/modules/session/catalina/DeltaSessionJUnitTest.java b/extensions/geode-modules/src/test/java/org/apache/geode/modules/session/catalina/DeltaSessionTest.java
similarity index 71%
rename from extensions/geode-modules-test/src/main/java/org/apache/geode/modules/session/catalina/DeltaSessionJUnitTest.java
rename to extensions/geode-modules/src/test/java/org/apache/geode/modules/session/catalina/DeltaSessionTest.java
index 1d55ce0..fc0c159 100644
--- a/extensions/geode-modules-test/src/main/java/org/apache/geode/modules/session/catalina/DeltaSessionJUnitTest.java
+++ b/extensions/geode-modules/src/test/java/org/apache/geode/modules/session/catalina/DeltaSessionTest.java
@@ -46,15 +46,15 @@ import org.apache.geode.internal.util.BlobHelper;
 import org.apache.geode.modules.session.catalina.internal.DeltaSessionAttributeEvent;
 import org.apache.geode.modules.session.catalina.internal.DeltaSessionStatistics;
 
-public class DeltaSessionJUnitTest {
+public class DeltaSessionTest {
 
-  private DeltaSessionManager manager = mock(DeltaSessionManager.class);
-  private Region<String, HttpSession> sessionRegion = mock(Region.class);
-  private SessionCache sessionCache = mock(ClientServerSessionCache.class);
+  private final DeltaSessionManager manager = mock(DeltaSessionManager.class);
+  private final Region<String, HttpSession> sessionRegion = mock(Region.class);
+  private final SessionCache sessionCache = mock(ClientServerSessionCache.class);
   DeltaSessionStatistics stats = mock(DeltaSessionStatistics.class);
   private final String sessionRegionName = "sessionRegionName";
   private final String contextName = "contextName";
-  private Log logger = mock(Log.class);
+  private final Log logger = mock(Log.class);
 
   @Before
   public void setup() {
@@ -72,7 +72,7 @@ public class DeltaSessionJUnitTest {
 
   @Test
   public void sessionConstructionThrowsIllegalArgumentExceptionIfProvidedManagerIsNotDeltaSessionManager() {
-    Manager invalidManager = mock(Manager.class);
+    final Manager invalidManager = mock(Manager.class);
 
     assertThatThrownBy(() -> new DeltaSession(invalidManager))
         .isInstanceOf(IllegalArgumentException.class)
@@ -81,35 +81,35 @@ public class DeltaSessionJUnitTest {
 
   @Test
   public void sessionConstructionDoesNotThrowExceptionWithValidArgument() {
-    DeltaSession session = new DeltaSession(manager);
+    final DeltaSession session = new DeltaSession(manager);
 
     verify(logger).debug(anyString());
   }
 
   @Test
   public void getSessionCreatesFacadeWhenFacadeIsNullAndPackageProtectionDisabled() {
-    DeltaSession session = new DeltaSession(manager);
+    final DeltaSession session = new DeltaSession(manager);
 
-    HttpSession returnedSession = session.getSession();
+    final HttpSession returnedSession = session.getSession();
 
     assertThat(returnedSession).isNotNull();
   }
 
   @Test
   public void getSessionCreatesFacadeWhenFacadeIsNullAndPackageProtectionEnabled() {
-    DeltaSession session = spy(new DeltaSession(manager));
-    DeltaSessionFacade facade = mock(DeltaSessionFacade.class);
+    final DeltaSession session = spy(new DeltaSession(manager));
+    final DeltaSessionFacade facade = mock(DeltaSessionFacade.class);
     doReturn(true).when(session).isPackageProtectionEnabled();
     doReturn(facade).when(session).getNewFacade(any(DeltaSession.class));
 
-    HttpSession returnedSession = session.getSession();
+    final HttpSession returnedSession = session.getSession();
 
     assertThat(returnedSession).isEqualTo(facade);
   }
 
   @Test
   public void processExpiredIncrementsStatisticsCountForExpiredSessions() {
-    DeltaSession session = spy(new DeltaSession(manager));
+    final DeltaSession session = spy(new DeltaSession(manager));
 
     doNothing().when((StandardSession) session).expire(false);
     session.processExpired();
@@ -119,13 +119,13 @@ public class DeltaSessionJUnitTest {
 
   @Test
   public void applyEventsAppliesEachEventAndPutsSessionIntoRegion() {
-    DeltaSessionAttributeEvent event1 = mock(DeltaSessionAttributeEvent.class);
-    DeltaSessionAttributeEvent event2 = mock(DeltaSessionAttributeEvent.class);
-    List<DeltaSessionAttributeEvent> events = new ArrayList<>();
+    final DeltaSessionAttributeEvent event1 = mock(DeltaSessionAttributeEvent.class);
+    final DeltaSessionAttributeEvent event2 = mock(DeltaSessionAttributeEvent.class);
+    final List<DeltaSessionAttributeEvent> events = new ArrayList<>();
     events.add(event1);
     events.add(event2);
-    Region<String, DeltaSessionInterface> region = mock(Region.class);
-    DeltaSession session = spy(new DeltaSession(manager));
+    final Region<String, DeltaSessionInterface> region = mock(Region.class);
+    final DeltaSession session = spy(new DeltaSession(manager));
 
     session.applyAttributeEvents(region, events);
 
@@ -139,8 +139,8 @@ public class DeltaSessionJUnitTest {
 
   @Test
   public void commitThrowsIllegalStateExceptionWhenCalledOnInvalidSession() {
-    DeltaSession session = spy(new DeltaSession(manager));
-    String sessionId = "invalidatedSession";
+    final DeltaSession session = spy(new DeltaSession(manager));
+    final String sessionId = "invalidatedSession";
     doReturn(sessionId).when(session).getId();
 
     assertThatThrownBy(() -> session.commit()).isInstanceOf(IllegalStateException.class)
@@ -149,35 +149,35 @@ public class DeltaSessionJUnitTest {
 
   @Test
   public void getSizeInBytesReturnsProperValueForMultipleAttributes() {
-    String attrName1 = "attrName1";
-    String attrName2 = "attrName2";
-    List attrList = new ArrayList<String>();
+    final String attrName1 = "attrName1";
+    final String attrName2 = "attrName2";
+    final List attrList = new ArrayList<String>();
     attrList.add(attrName1);
     attrList.add(attrName2);
 
-    Enumeration<String> attrNames = Collections.enumeration(attrList);
+    final Enumeration<String> attrNames = Collections.enumeration(attrList);
 
-    byte[] value1 = {0, 0, 0, 0};
-    byte[] value2 = {0, 0, 0, 0, 0};
-    int totalSize = value1.length + value2.length;
+    final byte[] value1 = {0, 0, 0, 0};
+    final byte[] value2 = {0, 0, 0, 0, 0};
+    final int totalSize = value1.length + value2.length;
 
-    DeltaSession session = spy(new DeltaSession(manager));
+    final DeltaSession session = spy(new DeltaSession(manager));
     doReturn(attrNames).when(session).getAttributeNames();
     doReturn(value1).when(session).getAttributeWithoutDeserialize(attrName1);
     doReturn(value2).when(session).getAttributeWithoutDeserialize(attrName2);
 
-    int sessionSize = session.getSizeInBytes();
+    final int sessionSize = session.getSizeInBytes();
 
     assertThat(sessionSize).isEqualTo(totalSize);
   }
 
   @Test
   public void serializeLogsWarningWhenExceptionIsThrownDuringSerialization() throws IOException {
-    Object obj = "unserialized object";
-    String exceptionMessaage = "Serialization failed.";
-    IOException exception = new IOException(exceptionMessaage);
+    final Object obj = "unserialized object";
+    final String exceptionMessaage = "Serialization failed.";
+    final IOException exception = new IOException(exceptionMessaage);
 
-    DeltaSession session = spy(new DeltaSession(manager));
+    final DeltaSession session = spy(new DeltaSession(manager));
     doThrow(exception).when(session).serializeViaBlobHelper(obj);
     session.serialize(obj);
 
@@ -186,11 +186,11 @@ public class DeltaSessionJUnitTest {
 
   @Test
   public void serializeReturnsSerializedObject() throws IOException {
-    Object obj = "unserialized object";
-    byte[] serializedObj = BlobHelper.serializeToBlob(obj);
+    final Object obj = "unserialized object";
+    final byte[] serializedObj = BlobHelper.serializeToBlob(obj);
 
-    DeltaSession session = spy(new DeltaSession(manager));
-    byte[] result = session.serialize(obj);
+    final DeltaSession session = spy(new DeltaSession(manager));
+    final byte[] result = session.serialize(obj);
 
     assertThat(result).isEqualTo(serializedObj);
   }
diff --git a/extensions/geode-modules-test/src/main/java/org/apache/geode/modules/session/catalina/PeerToPeerSessionCacheJUnitTest.java b/extensions/geode-modules/src/test/java/org/apache/geode/modules/session/catalina/PeerToPeerSessionCacheTest.java
similarity index 90%
rename from extensions/geode-modules-test/src/main/java/org/apache/geode/modules/session/catalina/PeerToPeerSessionCacheJUnitTest.java
rename to extensions/geode-modules/src/test/java/org/apache/geode/modules/session/catalina/PeerToPeerSessionCacheTest.java
index 2bea8de..34e5dbf 100644
--- a/extensions/geode-modules-test/src/main/java/org/apache/geode/modules/session/catalina/PeerToPeerSessionCacheJUnitTest.java
+++ b/extensions/geode-modules/src/test/java/org/apache/geode/modules/session/catalina/PeerToPeerSessionCacheTest.java
@@ -46,14 +46,12 @@ import org.apache.geode.modules.util.SessionCustomExpiry;
 import org.apache.geode.modules.util.TouchPartitionedRegionEntriesFunction;
 import org.apache.geode.modules.util.TouchReplicatedRegionEntriesFunction;
 
-public class PeerToPeerSessionCacheJUnitTest extends AbstractSessionCacheJUnitTest {
+public class PeerToPeerSessionCacheTest extends AbstractSessionCacheTest {
 
-  private String localRegionName = sessionRegionName + "_local";
-  @SuppressWarnings("unchecked")
-  private RegionFactory<String, HttpSession> regionFactory = mock(RegionFactory.class);
-  @SuppressWarnings("unchecked")
-  private Region<String, HttpSession> localRegion = mock(Region.class);
-  private Cache cache = mock(Cache.class);
+  private final String localRegionName = sessionRegionName + "_local";
+  private final RegionFactory<String, HttpSession> regionFactory = mock(RegionFactory.class);
+  private final Region<String, HttpSession> localRegion = mock(Region.class);
+  private final Cache cache = mock(Cache.class);
 
   @Before
   public void setUp() {
@@ -152,8 +150,8 @@ public class PeerToPeerSessionCacheJUnitTest extends AbstractSessionCacheJUnitTe
 
   @Test
   public void touchSessionsWithPartitionedRegionSucceeds() {
-    Set<String> sessionIds = new HashSet<>();
-    ResultCollector collector = mock(ResultCollector.class);
+    final Set<String> sessionIds = new HashSet<>();
+    final ResultCollector collector = mock(ResultCollector.class);
 
     when(sessionManager.getRegionAttributesId()).thenReturn(RegionShortcut.PARTITION.toString());
     doReturn(emptyExecution).when((PeerToPeerSessionCache) sessionCache)
@@ -171,8 +169,8 @@ public class PeerToPeerSessionCacheJUnitTest extends AbstractSessionCacheJUnitTe
     // Need to invoke this to set the session region
     sessionCache.initialize();
 
-    Set<String> sessionIds = new HashSet<>();
-    ResultCollector collector = mock(ResultCollector.class);
+    final Set<String> sessionIds = new HashSet<>();
+    final ResultCollector collector = mock(ResultCollector.class);
 
     when(sessionManager.getRegionAttributesId()).thenReturn(RegionShortcut.REPLICATE.toString());
     doReturn(emptyExecution).when((PeerToPeerSessionCache) sessionCache)
@@ -187,9 +185,9 @@ public class PeerToPeerSessionCacheJUnitTest extends AbstractSessionCacheJUnitTe
 
   @Test
   public void touchSessionsCatchesThrownException() {
-    Set<String> sessionIds = new HashSet<>();
-    ResultCollector collector = mock(ResultCollector.class);
-    FunctionException exception = new FunctionException();
+    final Set<String> sessionIds = new HashSet<>();
+    final ResultCollector collector = mock(ResultCollector.class);
+    final FunctionException exception = new FunctionException();
 
     when(sessionManager.getRegionAttributesId()).thenReturn(RegionShortcut.PARTITION.toString());
     doReturn(emptyExecution).when((PeerToPeerSessionCache) sessionCache)
diff --git a/extensions/geode-modules-test/src/main/java/org/apache/geode/modules/session/catalina/callback/SessionExpirationCacheListenerJUnitTest.java b/extensions/geode-modules/src/test/java/org/apache/geode/modules/session/catalina/callback/SessionExpirationCacheListenerTest.java
similarity index 80%
rename from extensions/geode-modules-test/src/main/java/org/apache/geode/modules/session/catalina/callback/SessionExpirationCacheListenerJUnitTest.java
rename to extensions/geode-modules/src/test/java/org/apache/geode/modules/session/catalina/callback/SessionExpirationCacheListenerTest.java
index 7228fe8..b1c8a00 100644
--- a/extensions/geode-modules-test/src/main/java/org/apache/geode/modules/session/catalina/callback/SessionExpirationCacheListenerJUnitTest.java
+++ b/extensions/geode-modules/src/test/java/org/apache/geode/modules/session/catalina/callback/SessionExpirationCacheListenerTest.java
@@ -27,12 +27,12 @@ import org.apache.geode.cache.EntryEvent;
 import org.apache.geode.cache.Operation;
 import org.apache.geode.modules.session.catalina.DeltaSession;
 
-public class SessionExpirationCacheListenerJUnitTest {
+public class SessionExpirationCacheListenerTest {
   @Test
-  public void TestAfterDestroyProcessesSessionExpiredByGemfire() {
-    SessionExpirationCacheListener listener = new SessionExpirationCacheListener();
-    EntryEvent<String, HttpSession> event = mock(EntryEvent.class);
-    DeltaSession session = mock(DeltaSession.class);
+  public void testAfterDestroyProcessesSessionExpired() {
+    final SessionExpirationCacheListener listener = new SessionExpirationCacheListener();
+    final EntryEvent<String, HttpSession> event = mock(EntryEvent.class);
+    final DeltaSession session = mock(DeltaSession.class);
 
     when(event.getOperation()).thenReturn(Operation.EXPIRE_DESTROY);
     when(event.getOldValue()).thenReturn(session);
diff --git a/extensions/geode-modules-test/src/main/java/org/apache/geode/modules/session/catalina/internal/DeltaSessionAttributeEventBatchJUnitTest.java b/extensions/geode-modules/src/test/java/org/apache/geode/modules/session/catalina/internal/DeltaSessionAttributeEventBatchTest.java
similarity index 77%
rename from extensions/geode-modules-test/src/main/java/org/apache/geode/modules/session/catalina/internal/DeltaSessionAttributeEventBatchJUnitTest.java
rename to extensions/geode-modules/src/test/java/org/apache/geode/modules/session/catalina/internal/DeltaSessionAttributeEventBatchTest.java
index bee73b8..9906618 100644
--- a/extensions/geode-modules-test/src/main/java/org/apache/geode/modules/session/catalina/internal/DeltaSessionAttributeEventBatchJUnitTest.java
+++ b/extensions/geode-modules/src/test/java/org/apache/geode/modules/session/catalina/internal/DeltaSessionAttributeEventBatchTest.java
@@ -30,7 +30,7 @@ import org.apache.geode.cache.Cache;
 import org.apache.geode.cache.Region;
 import org.apache.geode.modules.session.catalina.DeltaSessionInterface;
 
-public class DeltaSessionAttributeEventBatchJUnitTest {
+public class DeltaSessionAttributeEventBatchTest {
   String regionName = "regionName";
   String sessionId = "sessionId";
   LogWriter logWriter = mock(LogWriter.class);
@@ -38,23 +38,22 @@ public class DeltaSessionAttributeEventBatchJUnitTest {
   @Test
   public void TestApplyForBatch() {
 
-    List<DeltaSessionAttributeEvent> eventList = new ArrayList<>();
-    DeltaSessionAttributeEvent event1 = mock(DeltaSessionAttributeEvent.class);
-    DeltaSessionAttributeEvent event2 = mock(DeltaSessionAttributeEvent.class);
+    final List<DeltaSessionAttributeEvent> eventList = new ArrayList<>();
+    final DeltaSessionAttributeEvent event1 = mock(DeltaSessionAttributeEvent.class);
+    final DeltaSessionAttributeEvent event2 = mock(DeltaSessionAttributeEvent.class);
     eventList.add(event1);
     eventList.add(event2);
 
-
-    Cache cache = mock(Cache.class);
-    Region<String, DeltaSessionInterface> region = mock(Region.class);
-    DeltaSessionInterface deltaSessionInterface = mock(DeltaSessionInterface.class);
+    final Cache cache = mock(Cache.class);
+    final Region<String, DeltaSessionInterface> region = mock(Region.class);
+    final DeltaSessionInterface deltaSessionInterface = mock(DeltaSessionInterface.class);
 
     doReturn(region).when(cache).getRegion(regionName);
     when(cache.getLogger()).thenReturn(logWriter);
     when(logWriter.fineEnabled()).thenReturn(false);
     when(region.get(sessionId)).thenReturn(deltaSessionInterface);
 
-    DeltaSessionAttributeEventBatch batch =
+    final DeltaSessionAttributeEventBatch batch =
         new DeltaSessionAttributeEventBatch(regionName, sessionId, eventList);
 
     batch.apply(cache);
diff --git a/extensions/geode-modules-test/src/main/java/org/apache/geode/modules/session/catalina/internal/DeltaSessionDestroyAttributeEventJUnitTest.java b/extensions/geode-modules/src/test/java/org/apache/geode/modules/session/catalina/internal/DeltaSessionDestroyAttributeEventTest.java
similarity index 79%
rename from extensions/geode-modules-test/src/main/java/org/apache/geode/modules/session/catalina/internal/DeltaSessionDestroyAttributeEventJUnitTest.java
rename to extensions/geode-modules/src/test/java/org/apache/geode/modules/session/catalina/internal/DeltaSessionDestroyAttributeEventTest.java
index 5ea2648..7f2a944 100644
--- a/extensions/geode-modules-test/src/main/java/org/apache/geode/modules/session/catalina/internal/DeltaSessionDestroyAttributeEventJUnitTest.java
+++ b/extensions/geode-modules/src/test/java/org/apache/geode/modules/session/catalina/internal/DeltaSessionDestroyAttributeEventTest.java
@@ -22,13 +22,14 @@ import org.junit.Test;
 
 import org.apache.geode.modules.session.catalina.DeltaSessionInterface;
 
-public class DeltaSessionDestroyAttributeEventJUnitTest {
+public class DeltaSessionDestroyAttributeEventTest {
   @Test
   public void DeltaSessionDestroyAttributeEventAppliesAttributeToSession() {
-    String attributeName = "DestroyAttribute";
+    final String attributeName = "DestroyAttribute";
 
-    DeltaSessionDestroyAttributeEvent event = new DeltaSessionDestroyAttributeEvent(attributeName);
-    DeltaSessionInterface deltaSessionInterface = mock(DeltaSessionInterface.class);
+    final DeltaSessionDestroyAttributeEvent event =
+        new DeltaSessionDestroyAttributeEvent(attributeName);
+    final DeltaSessionInterface deltaSessionInterface = mock(DeltaSessionInterface.class);
     event.apply((deltaSessionInterface));
 
     verify(deltaSessionInterface).localDestroyAttribute(attributeName);
diff --git a/extensions/geode-modules-test/src/main/java/org/apache/geode/modules/session/catalina/internal/DeltaSessionStatisticsJUnitTest.java b/extensions/geode-modules/src/test/java/org/apache/geode/modules/session/catalina/internal/DeltaSessionStatisticsTest.java
similarity index 85%
rename from extensions/geode-modules-test/src/main/java/org/apache/geode/modules/session/catalina/internal/DeltaSessionStatisticsJUnitTest.java
rename to extensions/geode-modules/src/test/java/org/apache/geode/modules/session/catalina/internal/DeltaSessionStatisticsTest.java
index 51b8129..8a005f9 100644
--- a/extensions/geode-modules-test/src/main/java/org/apache/geode/modules/session/catalina/internal/DeltaSessionStatisticsJUnitTest.java
+++ b/extensions/geode-modules/src/test/java/org/apache/geode/modules/session/catalina/internal/DeltaSessionStatisticsTest.java
@@ -28,18 +28,19 @@ import org.junit.Test;
 import org.apache.geode.Statistics;
 import org.apache.geode.distributed.internal.InternalDistributedSystem;
 
-public class DeltaSessionStatisticsJUnitTest {
+public class DeltaSessionStatisticsTest {
 
   @Test
   public void CreatedDeltaSessionStatisticsAccessProperStats() {
-    String appName = "DeltaSessionStatisticsTest";
+    final String appName = "DeltaSessionStatisticsTest";
 
-    InternalDistributedSystem internalDistributedSystem = mock(InternalDistributedSystem.class);
-    Statistics statistics = mock(Statistics.class);
+    final InternalDistributedSystem internalDistributedSystem =
+        mock(InternalDistributedSystem.class);
+    final Statistics statistics = mock(Statistics.class);
 
     when(internalDistributedSystem.createAtomicStatistics(any(), any())).thenReturn(statistics);
 
-    DeltaSessionStatistics deltaSessionStatistics =
+    final DeltaSessionStatistics deltaSessionStatistics =
         new DeltaSessionStatistics(internalDistributedSystem, appName);
 
     deltaSessionStatistics.incSessionsCreated();
diff --git a/extensions/geode-modules-test/src/main/java/org/apache/geode/modules/session/catalina/internal/DeltaSessionUpdateAttributeEventJUnitTest.java b/extensions/geode-modules/src/test/java/org/apache/geode/modules/session/catalina/internal/DeltaSessionUpdateAttributeEventTest.java
similarity index 81%
rename from extensions/geode-modules-test/src/main/java/org/apache/geode/modules/session/catalina/internal/DeltaSessionUpdateAttributeEventJUnitTest.java
rename to extensions/geode-modules/src/test/java/org/apache/geode/modules/session/catalina/internal/DeltaSessionUpdateAttributeEventTest.java
index d356afd..50e439b 100644
--- a/extensions/geode-modules-test/src/main/java/org/apache/geode/modules/session/catalina/internal/DeltaSessionUpdateAttributeEventJUnitTest.java
+++ b/extensions/geode-modules/src/test/java/org/apache/geode/modules/session/catalina/internal/DeltaSessionUpdateAttributeEventTest.java
@@ -22,15 +22,15 @@ import org.junit.Test;
 
 import org.apache.geode.modules.session.catalina.DeltaSessionInterface;
 
-public class DeltaSessionUpdateAttributeEventJUnitTest {
+public class DeltaSessionUpdateAttributeEventTest {
   @Test
   public void DeltaSessionDestroyAttributeEventAppliesAttributeToSession() {
-    String attributeName = "UpdateAttribute";
-    String attributeValue = "UpdateValue";
+    final String attributeName = "UpdateAttribute";
+    final String attributeValue = "UpdateValue";
 
-    DeltaSessionUpdateAttributeEvent event =
+    final DeltaSessionUpdateAttributeEvent event =
         new DeltaSessionUpdateAttributeEvent(attributeName, attributeValue);
-    DeltaSessionInterface deltaSessionInterface = mock(DeltaSessionInterface.class);
+    final DeltaSessionInterface deltaSessionInterface = mock(DeltaSessionInterface.class);
     event.apply((deltaSessionInterface));
 
     verify(deltaSessionInterface).localUpdateAttribute(attributeName, attributeValue);
diff --git a/extensions/geode-modules-test/src/main/java/org/apache/geode/modules/util/CreateRegionFunctionJUnitTest.java b/extensions/geode-modules/src/test/java/org/apache/geode/modules/util/CreateRegionFunctionTest.java
similarity index 85%
rename from extensions/geode-modules-test/src/main/java/org/apache/geode/modules/util/CreateRegionFunctionJUnitTest.java
rename to extensions/geode-modules/src/test/java/org/apache/geode/modules/util/CreateRegionFunctionTest.java
index 5009489..c653f0e 100644
--- a/extensions/geode-modules-test/src/main/java/org/apache/geode/modules/util/CreateRegionFunctionJUnitTest.java
+++ b/extensions/geode-modules/src/test/java/org/apache/geode/modules/util/CreateRegionFunctionTest.java
@@ -30,10 +30,10 @@ import org.apache.geode.cache.EvictionAttributes;
 import org.apache.geode.cache.RegionAttributes;
 
 // TODO: Remove the deprecated method invocations once RegionAttributesCreation is also updated.
-public class CreateRegionFunctionJUnitTest {
+public class CreateRegionFunctionTest {
 
   private RegionAttributes getRegionAttributesWithModifiedDiskDirs(final File[] diskDirs) {
-    RegionAttributes mockRegionAttributes = mock(RegionAttributes.class);
+    final RegionAttributes mockRegionAttributes = mock(RegionAttributes.class);
     when(mockRegionAttributes.getDiskStoreName()).thenReturn(null);
     when(mockRegionAttributes.getDataPolicy()).thenReturn(DataPolicy.NORMAL);
     when(mockRegionAttributes.getCacheListeners()).thenReturn(new CacheListener[] {});
@@ -45,7 +45,7 @@ public class CreateRegionFunctionJUnitTest {
   }
 
   private RegionAttributes getRegionAttributesWithModifiedDiskDirSize(final int[] diskDirSize) {
-    RegionAttributes mockRegionAttributes = mock(RegionAttributes.class);
+    final RegionAttributes mockRegionAttributes = mock(RegionAttributes.class);
     when(mockRegionAttributes.getDiskStoreName()).thenReturn(null);
     when(mockRegionAttributes.getDataPolicy()).thenReturn(DataPolicy.NORMAL);
     when(mockRegionAttributes.getCacheListeners()).thenReturn(new CacheListener[] {});
@@ -59,18 +59,19 @@ public class CreateRegionFunctionJUnitTest {
 
   @Test
   public void regionComparisonMustBeSuccessfulWhenDiskStoreNamesForBothAreNullAndDiskPropertiesAreDifferent() {
-    CreateRegionFunction createRegionFunction = mock(CreateRegionFunction.class);
+    final CreateRegionFunction createRegionFunction = mock(CreateRegionFunction.class);
     doCallRealMethod().when(createRegionFunction).compareRegionAttributes(any(), any());
 
-    RegionAttributes existingRegionAttributes =
+    final RegionAttributes existingRegionAttributes =
         getRegionAttributesWithModifiedDiskDirSize(new int[] {1});
-    RegionAttributes requestedRegionAttributes =
+    final RegionAttributes requestedRegionAttributes =
         getRegionAttributesWithModifiedDiskDirSize(new int[] {2});
     createRegionFunction.compareRegionAttributes(existingRegionAttributes,
         requestedRegionAttributes);
 
-    RegionAttributes existingRegionAttributes2 = getRegionAttributesWithModifiedDiskDirs(null);
-    RegionAttributes requestedRegionAttributes2 =
+    final RegionAttributes existingRegionAttributes2 =
+        getRegionAttributesWithModifiedDiskDirs(null);
+    final RegionAttributes requestedRegionAttributes2 =
         getRegionAttributesWithModifiedDiskDirs(new File[] {});
     createRegionFunction.compareRegionAttributes(existingRegionAttributes2,
         requestedRegionAttributes2);
diff --git a/extensions/geode-modules-test/src/main/java/org/apache/geode/modules/util/TouchPartitionedRegionEntriesFunctionJUnitTest.java b/extensions/geode-modules/src/test/java/org/apache/geode/modules/util/TouchPartitionedRegionEntriesFunctionTest.java
similarity index 84%
rename from extensions/geode-modules-test/src/main/java/org/apache/geode/modules/util/TouchPartitionedRegionEntriesFunctionJUnitTest.java
rename to extensions/geode-modules/src/test/java/org/apache/geode/modules/util/TouchPartitionedRegionEntriesFunctionTest.java
index 6852681..5d09a09 100644
--- a/extensions/geode-modules-test/src/main/java/org/apache/geode/modules/util/TouchPartitionedRegionEntriesFunctionJUnitTest.java
+++ b/extensions/geode-modules/src/test/java/org/apache/geode/modules/util/TouchPartitionedRegionEntriesFunctionTest.java
@@ -37,15 +37,15 @@ import org.apache.geode.cache.execute.FunctionContext;
 import org.apache.geode.cache.execute.RegionFunctionContext;
 import org.apache.geode.cache.execute.ResultSender;
 
-public class TouchPartitionedRegionEntriesFunctionJUnitTest {
+public class TouchPartitionedRegionEntriesFunctionTest {
 
-  private TouchPartitionedRegionEntriesFunction function =
+  private final TouchPartitionedRegionEntriesFunction function =
       spy(new TouchPartitionedRegionEntriesFunction());
-  private FunctionContext context = mock(RegionFunctionContext.class);
-  private Cache cache = mock(Cache.class);
-  private LogWriter logger = mock(LogWriter.class);
-  private Region primaryDataSet = mock(Region.class);
-  private ResultSender resultSender = mock(ResultSender.class);
+  private final FunctionContext context = mock(RegionFunctionContext.class);
+  private final Cache cache = mock(Cache.class);
+  private final LogWriter logger = mock(LogWriter.class);
+  private final Region primaryDataSet = mock(Region.class);
+  private final ResultSender resultSender = mock(ResultSender.class);
 
   @Before
   public void setUp() {
@@ -69,7 +69,7 @@ public class TouchPartitionedRegionEntriesFunctionJUnitTest {
 
   @Test
   public void executeDoesNotThrowExceptionWithProperlyDefinedContextAndMultipleKeys() {
-    HashSet<String> keys = new HashSet();
+    final HashSet<String> keys = new HashSet();
     keys.add("Key1");
     keys.add("Key2");
 
diff --git a/extensions/geode-modules-test/src/main/java/org/apache/geode/modules/util/TouchReplicatedRegionEntriesFunctionJUnitTest.java b/extensions/geode-modules/src/test/java/org/apache/geode/modules/util/TouchReplicatedRegionEntriesFunctionTest.java
similarity index 79%
rename from extensions/geode-modules-test/src/main/java/org/apache/geode/modules/util/TouchReplicatedRegionEntriesFunctionJUnitTest.java
rename to extensions/geode-modules/src/test/java/org/apache/geode/modules/util/TouchReplicatedRegionEntriesFunctionTest.java
index 294317a..f7e80c8 100644
--- a/extensions/geode-modules-test/src/main/java/org/apache/geode/modules/util/TouchReplicatedRegionEntriesFunctionJUnitTest.java
+++ b/extensions/geode-modules/src/test/java/org/apache/geode/modules/util/TouchReplicatedRegionEntriesFunctionTest.java
@@ -33,17 +33,17 @@ import org.apache.geode.cache.execute.FunctionContext;
 import org.apache.geode.cache.execute.RegionFunctionContext;
 import org.apache.geode.cache.execute.ResultSender;
 
-public class TouchReplicatedRegionEntriesFunctionJUnitTest {
-  private TouchReplicatedRegionEntriesFunction function =
+public class TouchReplicatedRegionEntriesFunctionTest {
+  private final TouchReplicatedRegionEntriesFunction function =
       spy(new TouchReplicatedRegionEntriesFunction());
-  private FunctionContext context = mock(RegionFunctionContext.class);
-  private Cache cache = mock(Cache.class);
-  private LogWriter logger = mock(LogWriter.class);
-  private Region region = mock(Region.class);
-  private ResultSender resultSender = mock(ResultSender.class);
-  private String regionName = "regionName";
-  private HashSet<String> keys = new HashSet<>();
-  private Object[] arguments = new Object[] {regionName, keys};
+  private final FunctionContext context = mock(RegionFunctionContext.class);
+  private final Cache cache = mock(Cache.class);
+  private final LogWriter logger = mock(LogWriter.class);
+  private final Region region = mock(Region.class);
+  private final ResultSender resultSender = mock(ResultSender.class);
+  private final String regionName = "regionName";
+  private final HashSet<String> keys = new HashSet<>();
+  private final Object[] arguments = new Object[] {regionName, keys};
 
   @Before
   public void setUp() {

[geode] 01/11: Revert "GEODE-8684: Setting a session's maxInactiveInterval does not work when the commit valve is disabled"

Posted by sa...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

sabbey37 pushed a commit to branch support/1.13
in repository https://gitbox.apache.org/repos/asf/geode.git

commit ccdb502dd7f94aecaa75cbace114518ce0ff09bc
Author: Sarah <sa...@pivotal.io>
AuthorDate: Mon Apr 12 09:22:03 2021 -0400

    Revert "GEODE-8684: Setting a session's maxInactiveInterval does not work when the commit valve is disabled"
    
    This reverts commit cab4bcfd8d95c2d70ca40ad50e2beb761c798ca0.
---
 .../modules/session/catalina/DeltaSession.java     |  4 ---
 .../geode/session/tests/TomcatContainer.java       | 15 ++++-----
 .../apache/geode/session/tests/TomcatInstall.java  | 36 ++--------------------
 .../apache/geode/session/tests/CargoTestBase.java  |  9 +++---
 .../tests/Tomcat6CachingClientServerTest.java      |  2 +-
 .../session/tests/Tomcat6ClientServerTest.java     |  3 +-
 .../apache/geode/session/tests/Tomcat6Test.java    |  3 +-
 .../tests/Tomcat7CachingClientServerTest.java      |  2 +-
 .../session/tests/Tomcat7ClientServerTest.java     |  3 +-
 .../apache/geode/session/tests/Tomcat7Test.java    |  3 +-
 .../tests/Tomcat8CachingClientServerTest.java      |  2 +-
 .../session/tests/Tomcat8ClientServerTest.java     |  3 +-
 .../apache/geode/session/tests/Tomcat8Test.java    |  3 +-
 .../tests/Tomcat9CachingClientServerTest.java      |  2 +-
 ...omcat9CachingClientServerValveDisabledTest.java | 28 -----------------
 .../session/tests/Tomcat9ClientServerTest.java     |  3 +-
 .../apache/geode/session/tests/Tomcat9Test.java    |  3 +-
 .../Tomcat8ClientServerRollingUpgradeTest.java     |  4 +--
 ...omcatSessionBackwardsCompatibilityTestBase.java |  8 ++---
 19 files changed, 34 insertions(+), 102 deletions(-)

diff --git a/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/DeltaSession.java b/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/DeltaSession.java
index 3d9e627..4e5e969 100644
--- a/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/DeltaSession.java
+++ b/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/DeltaSession.java
@@ -362,10 +362,6 @@ public class DeltaSession extends StandardSession
   @Override
   public void setMaxInactiveInterval(int interval) {
     super.setMaxInactiveInterval(interval);
-
-    if (!isCommitEnabled() && id != null) {
-      putInRegion(getOperatingRegion(), true, null);
-    }
   }
 
   @Override
diff --git a/geode-assembly/geode-assembly-test/src/main/java/org/apache/geode/session/tests/TomcatContainer.java b/geode-assembly/geode-assembly-test/src/main/java/org/apache/geode/session/tests/TomcatContainer.java
index b0d4168..38d262d 100644
--- a/geode-assembly/geode-assembly-test/src/main/java/org/apache/geode/session/tests/TomcatContainer.java
+++ b/geode-assembly/geode-assembly-test/src/main/java/org/apache/geode/session/tests/TomcatContainer.java
@@ -65,16 +65,17 @@ public class TomcatContainer extends ServerContainer {
     setConfigFile(contextXMLFile.getAbsolutePath(), DEFAULT_TOMCAT_XML_REPLACEMENT_DIR,
         DEFAULT_TOMCAT_CONTEXT_XML_REPLACEMENT_NAME);
 
-    if (install.getConnectionType() == ContainerInstall.ConnectionType.CLIENT_SERVER ||
-        install.getConnectionType() == ContainerInstall.ConnectionType.CACHING_CLIENT_SERVER) {
+    if (install.getConnectionType() == ContainerInstall.ConnectionType.CLIENT_SERVER) {
+      // using proxy region, override the default client/server setting to set to false
       setCacheProperty("enableLocalCache",
           String.valueOf(install.getConnectionType().enableLocalCache()));
+    } else {
+      // using default, either setting it explicitly or leave it off should have the same effect
+      if (System.currentTimeMillis() % 2 == 0) {
+        setCacheProperty("enableLocalCache",
+            String.valueOf(install.getConnectionType().enableLocalCache()));
+      }
     }
-
-    if (install.getCommitValve() != TomcatInstall.CommitValve.DEFAULT) {
-      setCacheProperty("enableCommitValve", install.getCommitValve().getValue());
-    }
-
     setCacheProperty("className", install.getContextSessionManagerClass());
 
     // Deploy war file to container configuration
diff --git a/geode-assembly/geode-assembly-test/src/main/java/org/apache/geode/session/tests/TomcatInstall.java b/geode-assembly/geode-assembly-test/src/main/java/org/apache/geode/session/tests/TomcatInstall.java
index af7d955..322558e 100644
--- a/geode-assembly/geode-assembly-test/src/main/java/org/apache/geode/session/tests/TomcatInstall.java
+++ b/geode-assembly/geode-assembly-test/src/main/java/org/apache/geode/session/tests/TomcatInstall.java
@@ -89,26 +89,6 @@ public class TomcatInstall extends ContainerInstall {
   }
 
   /**
-   * This determines the setting for 'enableCommitValve' in Tomcat's context.xml when configuring
-   * the DeltaSessionManager.
-   */
-  public enum CommitValve {
-    ENABLED("true"),
-    DISABLED("false"),
-    DEFAULT(null);
-
-    private final String value;
-
-    CommitValve(String value) {
-      this.value = value;
-    }
-
-    public String getValue() {
-      return value;
-    }
-  }
-
-  /**
    * If you update this list method to return different dependencies, please also update the Tomcat
    * module documentation! The documentation can be found here:
    * geode-docs/tools_modules/http_session_mgmt/tomcat_installing_the_module.html.md.erb
@@ -123,14 +103,11 @@ public class TomcatInstall extends ContainerInstall {
 
   private final TomcatVersion version;
 
-  private final CommitValve commitValve;
-
   public TomcatInstall(String name, TomcatVersion version, ConnectionType connectionType,
-      IntSupplier portSupplier,
-      CommitValve commitValve)
+      IntSupplier portSupplier)
       throws Exception {
     this(name, version, connectionType, DEFAULT_MODULE_LOCATION, GEODE_BUILD_HOME_LIB,
-        portSupplier, commitValve);
+        portSupplier);
   }
 
   /**
@@ -143,14 +120,12 @@ public class TomcatInstall extends ContainerInstall {
    * skipping properties needed to speedup container startup.
    */
   public TomcatInstall(String name, TomcatVersion version, ConnectionType connType,
-      String modulesJarLocation, String extraJarsPath, IntSupplier portSupplier,
-      CommitValve commitValve)
+      String modulesJarLocation, String extraJarsPath, IntSupplier portSupplier)
       throws Exception {
     // Does download and install from URL
     super(name, version.getDownloadURL(), connType, "tomcat", modulesJarLocation, portSupplier);
 
     this.version = version;
-    this.commitValve = commitValve;
     modulesJarLocation = getModulePath() + "/lib/";
 
     // Install geode sessions into tomcat install
@@ -266,10 +241,6 @@ public class TomcatInstall extends ContainerInstall {
     return version.name() + "_" + getConnectionType().getName();
   }
 
-  public CommitValve getCommitValve() {
-    return commitValve;
-  }
-
   /**
    * Copies jars specified by {@link #tomcatRequiredJars} from the {@link #getModulePath()} and the
    * specified other directory passed to the function
@@ -344,5 +315,4 @@ public class TomcatInstall extends ContainerInstall {
     editPropertyFile(getHome() + "/conf/catalina.properties", version.jarSkipPropertyName(),
         jarsToSkip, true);
   }
-
 }
diff --git a/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/CargoTestBase.java b/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/CargoTestBase.java
index 8e95e1d..4ef5c78 100644
--- a/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/CargoTestBase.java
+++ b/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/CargoTestBase.java
@@ -23,7 +23,6 @@ import java.net.URISyntaxException;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
-import java.util.concurrent.TimeUnit;
 import java.util.function.IntSupplier;
 
 import org.apache.logging.log4j.Logger;
@@ -34,6 +33,7 @@ import org.junit.Test;
 import org.junit.experimental.categories.Category;
 import org.junit.rules.TestName;
 
+import org.apache.geode.internal.AvailablePortHelper;
 import org.apache.geode.internal.UniquePortSupplier;
 import org.apache.geode.logging.internal.log4j.api.LogService;
 import org.apache.geode.modules.session.functions.GetMaxInactiveInterval;
@@ -81,7 +81,8 @@ public abstract class CargoTestBase {
   public void setup() throws Exception {
     dumpDockerInfo();
     announceTest("START");
-    locatorVM = clusterStartupRule.startLocatorVM(0);
+    int locatorPortSuggestion = AvailablePortHelper.getRandomAvailableTCPPort();
+    locatorVM = clusterStartupRule.startLocatorVM(0, locatorPortSuggestion);
 
     client = new Client();
     manager = new ContainerManager();
@@ -251,7 +252,7 @@ public abstract class CargoTestBase {
     client.setMaxInactive(1); // max inactive time is 1 second. Lets wait a second.
     Thread.sleep(2000);
 
-    await().atMost(10, TimeUnit.SECONDS).untilAsserted(() -> {
+    await().untilAsserted(() -> {
       verifySessionIsRemoved(key);
       Thread.sleep(1000);
     });
@@ -284,7 +285,7 @@ public abstract class CargoTestBase {
     for (int i = 0; i < manager.numContainers(); i++) {
       client.setPort(Integer.parseInt(manager.getContainerPort(i)));
       if (install.getConnectionType() == ContainerInstall.ConnectionType.CACHING_CLIENT_SERVER) {
-        await().atMost(30, TimeUnit.SECONDS).until(() -> Integer.toString(expected)
+        await().until(() -> Integer.toString(expected)
             .equals(client.executionFunction(GetMaxInactiveInterval.class).getResponse()));
       } else {
         assertEquals(Integer.toString(expected),
diff --git a/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat6CachingClientServerTest.java b/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat6CachingClientServerTest.java
index 1c6f9d0..3bd14ee 100644
--- a/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat6CachingClientServerTest.java
+++ b/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat6CachingClientServerTest.java
@@ -23,6 +23,6 @@ public class Tomcat6CachingClientServerTest extends TomcatClientServerTest {
   @Override
   public ContainerInstall getInstall(IntSupplier portSupplier) throws Exception {
     return new TomcatInstall(getClass().getSimpleName(), TOMCAT6, CACHING_CLIENT_SERVER,
-        portSupplier, TomcatInstall.CommitValve.DEFAULT);
+        portSupplier);
   }
 }
diff --git a/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat6ClientServerTest.java b/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat6ClientServerTest.java
index 75d853d..1924034 100644
--- a/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat6ClientServerTest.java
+++ b/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat6ClientServerTest.java
@@ -22,7 +22,6 @@ import java.util.function.IntSupplier;
 public class Tomcat6ClientServerTest extends TomcatClientServerTest {
   @Override
   public ContainerInstall getInstall(IntSupplier portSupplier) throws Exception {
-    return new TomcatInstall(getClass().getSimpleName(), TOMCAT6, CLIENT_SERVER, portSupplier,
-        TomcatInstall.CommitValve.DEFAULT);
+    return new TomcatInstall(getClass().getSimpleName(), TOMCAT6, CLIENT_SERVER, portSupplier);
   }
 }
diff --git a/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat6Test.java b/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat6Test.java
index 50487d0..60dface 100644
--- a/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat6Test.java
+++ b/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat6Test.java
@@ -22,7 +22,6 @@ import java.util.function.IntSupplier;
 public class Tomcat6Test extends CargoTestBase {
   @Override
   public ContainerInstall getInstall(IntSupplier portSupplier) throws Exception {
-    return new TomcatInstall(getClass().getSimpleName(), TOMCAT6, PEER_TO_PEER, portSupplier,
-        TomcatInstall.CommitValve.DEFAULT);
+    return new TomcatInstall(getClass().getSimpleName(), TOMCAT6, PEER_TO_PEER, portSupplier);
   }
 }
diff --git a/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat7CachingClientServerTest.java b/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat7CachingClientServerTest.java
index 4401bfe..c2db978 100644
--- a/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat7CachingClientServerTest.java
+++ b/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat7CachingClientServerTest.java
@@ -23,6 +23,6 @@ public class Tomcat7CachingClientServerTest extends TomcatClientServerTest {
   @Override
   public ContainerInstall getInstall(IntSupplier portSupplier) throws Exception {
     return new TomcatInstall(getClass().getSimpleName(), TOMCAT7, CACHING_CLIENT_SERVER,
-        portSupplier, TomcatInstall.CommitValve.DEFAULT);
+        portSupplier);
   }
 }
diff --git a/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat7ClientServerTest.java b/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat7ClientServerTest.java
index f2cacf5..5c39fd2 100644
--- a/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat7ClientServerTest.java
+++ b/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat7ClientServerTest.java
@@ -23,7 +23,6 @@ import java.util.function.IntSupplier;
 public class Tomcat7ClientServerTest extends TomcatClientServerTest {
   @Override
   public ContainerInstall getInstall(IntSupplier portSupplier) throws Exception {
-    return new TomcatInstall(getClass().getSimpleName(), TOMCAT7, CLIENT_SERVER, portSupplier,
-        TomcatInstall.CommitValve.DEFAULT);
+    return new TomcatInstall(getClass().getSimpleName(), TOMCAT7, CLIENT_SERVER, portSupplier);
   }
 }
diff --git a/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat7Test.java b/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat7Test.java
index 5e93e1f..1922fdb 100644
--- a/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat7Test.java
+++ b/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat7Test.java
@@ -22,7 +22,6 @@ import java.util.function.IntSupplier;
 public class Tomcat7Test extends CargoTestBase {
   @Override
   public ContainerInstall getInstall(IntSupplier portSupplier) throws Exception {
-    return new TomcatInstall(getClass().getSimpleName(), TOMCAT7, PEER_TO_PEER, portSupplier,
-        TomcatInstall.CommitValve.DEFAULT);
+    return new TomcatInstall(getClass().getSimpleName(), TOMCAT7, PEER_TO_PEER, portSupplier);
   }
 }
diff --git a/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat8CachingClientServerTest.java b/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat8CachingClientServerTest.java
index ca3e921..03b65df 100644
--- a/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat8CachingClientServerTest.java
+++ b/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat8CachingClientServerTest.java
@@ -23,6 +23,6 @@ public class Tomcat8CachingClientServerTest extends TomcatClientServerTest {
   @Override
   public ContainerInstall getInstall(IntSupplier portSupplier) throws Exception {
     return new TomcatInstall(getClass().getSimpleName(), TOMCAT8, CACHING_CLIENT_SERVER,
-        portSupplier, TomcatInstall.CommitValve.DEFAULT);
+        portSupplier);
   }
 }
diff --git a/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat8ClientServerTest.java b/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat8ClientServerTest.java
index f52eacc..a4e960d 100644
--- a/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat8ClientServerTest.java
+++ b/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat8ClientServerTest.java
@@ -22,7 +22,6 @@ import java.util.function.IntSupplier;
 public class Tomcat8ClientServerTest extends TomcatClientServerTest {
   @Override
   public ContainerInstall getInstall(IntSupplier portSupplier) throws Exception {
-    return new TomcatInstall(getClass().getSimpleName(), TOMCAT8, CLIENT_SERVER, portSupplier,
-        TomcatInstall.CommitValve.DEFAULT);
+    return new TomcatInstall(getClass().getSimpleName(), TOMCAT8, CLIENT_SERVER, portSupplier);
   }
 }
diff --git a/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat8Test.java b/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat8Test.java
index dba0402..93a7441 100644
--- a/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat8Test.java
+++ b/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat8Test.java
@@ -22,7 +22,6 @@ import java.util.function.IntSupplier;
 public class Tomcat8Test extends CargoTestBase {
   @Override
   public ContainerInstall getInstall(IntSupplier portSupplier) throws Exception {
-    return new TomcatInstall(getClass().getSimpleName(), TOMCAT8, PEER_TO_PEER, portSupplier,
-        TomcatInstall.CommitValve.DEFAULT);
+    return new TomcatInstall(getClass().getSimpleName(), TOMCAT8, PEER_TO_PEER, portSupplier);
   }
 }
diff --git a/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat9CachingClientServerTest.java b/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat9CachingClientServerTest.java
index a02376c..8e8b4c4 100644
--- a/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat9CachingClientServerTest.java
+++ b/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat9CachingClientServerTest.java
@@ -23,6 +23,6 @@ public class Tomcat9CachingClientServerTest extends TomcatClientServerTest {
   @Override
   public ContainerInstall getInstall(IntSupplier portSupplier) throws Exception {
     return new TomcatInstall(getClass().getSimpleName(), TOMCAT9, CACHING_CLIENT_SERVER,
-        portSupplier, TomcatInstall.CommitValve.DEFAULT);
+        portSupplier);
   }
 }
diff --git a/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat9CachingClientServerValveDisabledTest.java b/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat9CachingClientServerValveDisabledTest.java
deleted file mode 100644
index 3738d9c..0000000
--- a/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat9CachingClientServerValveDisabledTest.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * 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.session.tests;
-
-import static org.apache.geode.session.tests.ContainerInstall.ConnectionType.CACHING_CLIENT_SERVER;
-import static org.apache.geode.session.tests.TomcatInstall.TomcatVersion.TOMCAT9;
-
-import java.util.function.IntSupplier;
-
-public class Tomcat9CachingClientServerValveDisabledTest extends TomcatClientServerTest {
-  @Override
-  public ContainerInstall getInstall(IntSupplier portSupplier) throws Exception {
-    return new TomcatInstall(getClass().getSimpleName(), TOMCAT9, CACHING_CLIENT_SERVER,
-        portSupplier, TomcatInstall.CommitValve.DISABLED);
-  }
-}
diff --git a/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat9ClientServerTest.java b/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat9ClientServerTest.java
index f922d2b..a617e19 100644
--- a/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat9ClientServerTest.java
+++ b/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat9ClientServerTest.java
@@ -23,7 +23,6 @@ public class Tomcat9ClientServerTest extends TomcatClientServerTest {
 
   @Override
   public ContainerInstall getInstall(IntSupplier portSupplier) throws Exception {
-    return new TomcatInstall(getClass().getSimpleName(), TOMCAT9, CLIENT_SERVER, portSupplier,
-        TomcatInstall.CommitValve.DEFAULT);
+    return new TomcatInstall(getClass().getSimpleName(), TOMCAT9, CLIENT_SERVER, portSupplier);
   }
 }
diff --git a/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat9Test.java b/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat9Test.java
index cb65d56..b7777d1 100644
--- a/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat9Test.java
+++ b/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat9Test.java
@@ -22,7 +22,6 @@ import java.util.function.IntSupplier;
 public class Tomcat9Test extends CargoTestBase {
   @Override
   public ContainerInstall getInstall(IntSupplier portSupplier) throws Exception {
-    return new TomcatInstall(getClass().getSimpleName(), TOMCAT9, PEER_TO_PEER, portSupplier,
-        TomcatInstall.CommitValve.DEFAULT);
+    return new TomcatInstall(getClass().getSimpleName(), TOMCAT9, PEER_TO_PEER, portSupplier);
   }
 }
diff --git a/geode-assembly/src/upgradeTest/java/org/apache/geode/session/tests/Tomcat8ClientServerRollingUpgradeTest.java b/geode-assembly/src/upgradeTest/java/org/apache/geode/session/tests/Tomcat8ClientServerRollingUpgradeTest.java
index be78750..ec6c39c 100644
--- a/geode-assembly/src/upgradeTest/java/org/apache/geode/session/tests/Tomcat8ClientServerRollingUpgradeTest.java
+++ b/geode-assembly/src/upgradeTest/java/org/apache/geode/session/tests/Tomcat8ClientServerRollingUpgradeTest.java
@@ -136,12 +136,12 @@ public class Tomcat8ClientServerRollingUpgradeTest {
             ContainerInstall.ConnectionType.CLIENT_SERVER,
             oldModules.getAbsolutePath(),
             oldBuild.getAbsolutePath() + "/lib",
-            portSupplier::getAvailablePort, TomcatInstall.CommitValve.DEFAULT);
+            portSupplier::getAvailablePort);
 
     tomcat8AndCurrentModules =
         new TomcatInstall("Tomcat8AndCurrentModules", TomcatInstall.TomcatVersion.TOMCAT8,
             ContainerInstall.ConnectionType.CLIENT_SERVER,
-            portSupplier::getAvailablePort, TomcatInstall.CommitValve.DEFAULT);
+            portSupplier::getAvailablePort);
 
     classPathTomcat8AndOldModules = getClassPathTomcat8AndOldModules();
 
diff --git a/geode-assembly/src/upgradeTest/java/org/apache/geode/session/tests/TomcatSessionBackwardsCompatibilityTestBase.java b/geode-assembly/src/upgradeTest/java/org/apache/geode/session/tests/TomcatSessionBackwardsCompatibilityTestBase.java
index 15dc1c8..7c71b83 100644
--- a/geode-assembly/src/upgradeTest/java/org/apache/geode/session/tests/TomcatSessionBackwardsCompatibilityTestBase.java
+++ b/geode-assembly/src/upgradeTest/java/org/apache/geode/session/tests/TomcatSessionBackwardsCompatibilityTestBase.java
@@ -120,24 +120,24 @@ public abstract class TomcatSessionBackwardsCompatibilityTestBase {
         new TomcatInstall("Tomcat7079AndOldModules", TomcatInstall.TomcatVersion.TOMCAT7,
             ContainerInstall.ConnectionType.CLIENT_SERVER,
             oldModules.getAbsolutePath(), oldBuild.getAbsolutePath() + "/lib",
-            portSupplier::getAvailablePort, TomcatInstall.CommitValve.DEFAULT);
+            portSupplier::getAvailablePort);
 
     tomcat7079AndCurrentModules =
         new TomcatInstall("Tomcat7079AndCurrentModules", TomcatInstall.TomcatVersion.TOMCAT7,
             ContainerInstall.ConnectionType.CLIENT_SERVER,
-            portSupplier::getAvailablePort, TomcatInstall.CommitValve.DEFAULT);
+            portSupplier::getAvailablePort);
 
     tomcat8AndOldModules =
         new TomcatInstall("Tomcat8AndOldModules", TomcatInstall.TomcatVersion.TOMCAT8,
             ContainerInstall.ConnectionType.CLIENT_SERVER,
             oldModules.getAbsolutePath(),
             oldBuild.getAbsolutePath() + "/lib",
-            portSupplier::getAvailablePort, TomcatInstall.CommitValve.DEFAULT);
+            portSupplier::getAvailablePort);
 
     tomcat8AndCurrentModules =
         new TomcatInstall("Tomcat8AndCurrentModules", TomcatInstall.TomcatVersion.TOMCAT8,
             ContainerInstall.ConnectionType.CLIENT_SERVER,
-            portSupplier::getAvailablePort, TomcatInstall.CommitValve.DEFAULT);
+            portSupplier::getAvailablePort);
 
     classPathTomcat7079 = tomcat7079AndCurrentModules.getHome() + "/lib/*" + File.pathSeparator
         + tomcat7079AndCurrentModules.getHome() + "/bin/*";

[geode] 04/11: Revert "GEODE-8781: Added ReconnectListener to PeerToPeerSessionCache"

Posted by sa...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

sabbey37 pushed a commit to branch support/1.13
in repository https://gitbox.apache.org/repos/asf/geode.git

commit 8d8705743b8f05c39e28bd1b554523c88ce3587f
Author: Sarah <sa...@pivotal.io>
AuthorDate: Mon Apr 12 09:22:48 2021 -0400

    Revert "GEODE-8781: Added ReconnectListener to PeerToPeerSessionCache"
    
    This reverts commit 4022403a996efd3235fa03cc62952c05675225c8.
---
 .../modules/session/catalina/DeltaSessionManager.java |  6 +-----
 .../session/catalina/PeerToPeerSessionCache.java      | 19 -------------------
 2 files changed, 1 insertion(+), 24 deletions(-)

diff --git a/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/DeltaSessionManager.java b/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/DeltaSessionManager.java
index e8fb0e2..2af36fe 100644
--- a/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/DeltaSessionManager.java
+++ b/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/DeltaSessionManager.java
@@ -550,11 +550,7 @@ public abstract class DeltaSessionManager extends ManagerBase
     TimerTask task = new TimerTask() {
       @Override
       public void run() {
-        int currentActiveSessions = 0;
-        try {
-          currentActiveSessions = getSessionCache().size();
-        } catch (Exception ignore) {
-        }
+        int currentActiveSessions = getSessionCache().size();
         if (currentActiveSessions > getMaxActive()) {
           setMaxActive(currentActiveSessions);
           if (getLogger().isDebugEnabled()) {
diff --git a/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/PeerToPeerSessionCache.java b/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/PeerToPeerSessionCache.java
index 04e197d..d5031c1 100644
--- a/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/PeerToPeerSessionCache.java
+++ b/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/PeerToPeerSessionCache.java
@@ -27,8 +27,6 @@ import org.apache.geode.cache.execute.Execution;
 import org.apache.geode.cache.execute.Function;
 import org.apache.geode.cache.execute.FunctionService;
 import org.apache.geode.cache.execute.ResultCollector;
-import org.apache.geode.distributed.internal.InternalDistributedSystem;
-import org.apache.geode.internal.cache.InternalCache;
 import org.apache.geode.modules.session.catalina.callback.LocalSessionCacheLoader;
 import org.apache.geode.modules.session.catalina.callback.LocalSessionCacheWriter;
 import org.apache.geode.modules.session.catalina.callback.SessionExpirationCacheListener;
@@ -49,7 +47,6 @@ public class PeerToPeerSessionCache extends AbstractSessionCache {
   public PeerToPeerSessionCache(SessionManager sessionManager, Cache cache) {
     super(sessionManager);
     this.cache = cache;
-    addReconnectListener();
   }
 
   @Override
@@ -245,20 +242,4 @@ public class PeerToPeerSessionCache extends AbstractSessionCache {
   Execution getExecutionForFunctionOnMembersWithArguments(Object[] arguments) {
     return FunctionService.onMembers().setArguments(arguments);
   }
-
-  private void addReconnectListener() {
-    InternalDistributedSystem.addReconnectListener(
-        new InternalDistributedSystem.ReconnectListener() {
-          @Override
-          public void onReconnect(InternalDistributedSystem oldSystem,
-              InternalDistributedSystem newSystem) {
-            reinitialize(newSystem.getCache());
-          }
-        });
-  }
-
-  private void reinitialize(InternalCache reconnectedCache) {
-    this.cache = reconnectedCache;
-    initialize();
-  }
 }