From 83679b99cd40caa401d173c8f8e72fc98eb5d5be Mon Sep 17 00:00:00 2001 From: Mark Thomas Date: Sat, 7 Nov 2015 21:35:29 +0000 Subject: [PATCH] Handle the unlikely case where different versions of a web application are deployed with different session settings git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1713184 13f79535-47bb-0310-9956-ffa450edef68 --- .../catalina/connector/CoyoteAdapter.java | 6 ++-- .../apache/catalina/connector/Request.java | 30 +++++++++++-------- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/java/org/apache/catalina/connector/CoyoteAdapter.java b/java/org/apache/catalina/connector/CoyoteAdapter.java index a4e4221ba50e..a02c6af74a81 100644 --- a/java/org/apache/catalina/connector/CoyoteAdapter.java +++ b/java/org/apache/catalina/connector/CoyoteAdapter.java @@ -757,9 +757,11 @@ protected boolean postParseRequest(org.apache.coyote.Request req, Request reques // Reset mapping request.getMappingData().recycle(); mapRequired = true; - // Recycle cookies in case correct context is - // configured with different settings + // Recycle cookies and session info in case the + // correct context is configured with different + // settings req.getCookies().recycle(); + request.recycleSessionInfo(); } break; } diff --git a/java/org/apache/catalina/connector/Request.java b/java/org/apache/catalina/connector/Request.java index 91e73b4bba1f..2072fa82adf0 100644 --- a/java/org/apache/catalina/connector/Request.java +++ b/java/org/apache/catalina/connector/Request.java @@ -468,18 +468,7 @@ public void recycle() { notes.clear(); cookies = null; - if (session != null) { - try { - session.endAccess(); - } catch (Throwable t) { - ExceptionUtils.handleThrowable(t); - log.warn(sm.getString("coyoteRequest.sessionEndAccessFail"), t); - } - } - session = null; - requestedSessionCookie = false; - requestedSessionId = null; - requestedSessionURL = false; + recycleSessionInfo(); if (Globals.IS_SECURITY_ENABLED || Connector.RECYCLE_FACADES) { parameterMap = new ParameterMap<>(); @@ -513,6 +502,23 @@ public void recycle() { } + protected void recycleSessionInfo() { + if (session != null) { + try { + session.endAccess(); + } catch (Throwable t) { + ExceptionUtils.handleThrowable(t); + log.warn(sm.getString("coyoteRequest.sessionEndAccessFail"), t); + } + } + session = null; + requestedSessionCookie = false; + requestedSessionId = null; + requestedSessionURL = false; + requestedSessionSSL = false; + } + + // -------------------------------------------------------- Request Methods /**