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 /**