We have recently started using session persistence capability with persistAuthentication="true". When a user is logged-out of the system and redirected to the login page, they are given a session whose principle object is null. If in that period the tomcat server is restarted, the doWriteObject from org.apache.catalina.session.StandardSession is called where on line 1489 it tries to check if the sessionPrincipal is serializable, but does not check if it is null before that - (https://github.com/apache/tomcat/blob/10.1.x/java/org/apache/catalina/session/StandardSession.java#L1489 ). If the principal is null (like in the above-described scenario) - then the manager logs a warning message saying it cannot serialize the principal for the session. This is somewhat misleading as there is simply no principal to serialize. My suggestion here would be to either add a null-check before logging the warning message, or add a configuration option where this particular case (one of a null principal) can be toggled, perhaps something like 'warnNullPrincipalSerialize'. Without such an ability we would get a lot of these warning messages in our production and we would not know which ones came from a session that is simply unauthenticated (i.e. principal is null), and which ones came from an actual issue with serializing the principal of an authenticated user.
Seems reasonable. Would you like to prepare a patch/PR for this? Please include an entry in the changelog if you do so.
Hi Christopher, Thanks for the quick reply! I created the PR (#638) and referenced the bug from here.
Hi (In reply to Christopher Schultz from comment #1) > Seems reasonable. Would you like to prepare a patch/PR for this? > > Please include an entry in the changelog if you do so. I'm not sure how to include an entry in the changelog, could you please do that or point me to a howto for doing it?
I can do the changelog if you do the PR.
(In reply to Christopher Schultz from comment #4) > I can do the changelog if you do the PR. Thanks! Here is the PR https://github.com/apache/tomcat/pull/638
Thanks for the PR. This has been fixed in: - 11.0.x for 11.0.0-M10 onwards - 10.1.x for 10.1.12 onwards - 9.0.x for 9.0.79 onwards - 8.5.x for 8.5.92 onwards