boris-petrov opened a new issue, #2050: URL: https://github.com/apache/shiro/issues/2050
### Search before asking - [x] I had searched in the [issues](https://github.com/apache/shiro/issues?q=is%3Aissue) and found no similar issues. ### Environment Tomcat, Java 24. ### Shiro version 2.0.2 ### What was the actual outcome? After the fix in #372 I expected that `getPrincipal` would never blow up even if the session has expired. That's not true in a Tomcat environment, however. Check the stacktrace below: ``` java.lang.IllegalStateException: The request object has been recycled and is no longer associated with this facade at org.apache.catalina.connector.RequestFacade.checkFacade(RequestFacade.java:856) at org.apache.catalina.connector.RequestFacade.removeAttribute(RequestFacade.java:419) at javax.servlet.ServletRequestWrapper.removeAttribute(ServletRequestWrapper.java:246) at org.apache.shiro.web.session.mgt.DefaultWebSessionManager.onInvalidation(DefaultWebSessionManager.java:306) at org.apache.shiro.web.session.mgt.DefaultWebSessionManager.onExpiration(DefaultWebSessionManager.java:294) at org.apache.shiro.session.mgt.AbstractValidatingSessionManager.validate(AbstractValidatingSessionManager.java:143) at org.apache.shiro.session.mgt.AbstractValidatingSessionManager.doGetSession(AbstractValidatingSessionManager.java:118) at org.apache.shiro.session.mgt.AbstractNativeSessionManager.lookupSession(AbstractNativeSessionManager.java:149) at org.apache.shiro.session.mgt.AbstractNativeSessionManager.lookupRequiredSession(AbstractNativeSessionManager.java:153) at org.apache.shiro.session.mgt.AbstractNativeSessionManager.getAttribute(AbstractNativeSessionManager.java:250) at org.apache.shiro.session.mgt.DelegatingSession.getAttribute(DelegatingSession.java:141) at org.apache.shiro.session.ProxiedSession.getAttribute(ProxiedSession.java:121) at org.apache.shiro.subject.support.DelegatingSubject.getRunAsPrincipalsStack(DelegatingSubject.java:476) at org.apache.shiro.subject.support.DelegatingSubject.getPrincipals(DelegatingSubject.java:159) at org.apache.shiro.subject.support.DelegatingSubject.getPrincipal(DelegatingSubject.java:155) ... ``` ### What was the expected outcome? No exception. I'm not sure how best to handle that. Perhaps the `DefaultWebSessionManager` should handle `IllegalStateException` in `onInvalidation`? Ideas? cc @lprimak ### How to reproduce Create a web session inside Tomcat, expire it and call `getPrincipal` on the `Subject`. ### Debug logs _No response_ -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
