Bug 64230 - Allow to configure session manager to skip expiring sessions at shutdown
Summary: Allow to configure session manager to skip expiring sessions at shutdown
Status: NEW
Alias: None
Product: Tomcat 9
Classification: Unclassified
Component: Catalina (show other bugs)
Version: 9.0.31
Hardware: PC
: P2 enhancement (vote)
Target Milestone: -----
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-03-15 22:40 UTC by Konstantin Kolinko
Modified: 2020-03-15 22:40 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Konstantin Kolinko 2020-03-15 22:40:51 UTC
As an additional improvement for
https://github.com/apache/tomcat/commit/81cfd2dc665db684b1fba0de5af4d08102dc50fb


I have a web application running on Tomcat 9.0.31 where StandardManager is configured to do not persist sessions on shutdown:

 <Manager pathname="" />

With this configuration, when the web application is being stopped, StandardManager expires all sessions that it did not write out. [1]

I think that there could be an option so that StandardManager just drops the sessions as they are, without notifying the web application. It will allow to shut down faster.


As an example: I am dealing with a framework that installs a HttpSessionBindingListener and does some work when a session is being expired - tries to send notification to a client, and fails. All that work is not needed and I would like to have an option to skip it all.

(For reference, the call stack that I observe is the same as in [2] even though I use a rather later version of the framework - 8.10.1).


Notes:

1. I see two possible implementations:

(a) Skip the whole loop that expires sessions. ([1]: lines 388-403.

(b) Run the loop, but do not notify listeners when a session is expired:
I mean: in the loop (line 394) replace:

-    session.expire();
+    session.expire(false);

I would like to go with (a), but (b) is a safer option.


2. Possible name of the option and sample configuration:

<Manager pathname="" expireDroppedSessions="false" />

with "true" being the default value.


-------------

[1] https://github.com/apache/tomcat/blob/81cfd2dc665db684b1fba0de5af4d08102dc50fb/java/org/apache/catalina/session/StandardManager.java#L388

[2] https://github.com/vaadin/framework/issues/7734#issue-194789340