You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@shiro.apache.org by "boris-petrov (via GitHub)" <gi...@apache.org> on 2025/03/26 17:36:29 UTC
[I] [Bug] `getRunAsPrincipalsStack` can throw random exceptions when the session is invalid [shiro]
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: issues-unsubscribe@shiro.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@shiro.apache.org
For additional commands, e-mail: issues-help@shiro.apache.org
Re: [I] [Bug] `getRunAsPrincipalsStack` can throw random exceptions when the session is invalid [shiro]
Posted by "boris-petrov (via GitHub)" <gi...@apache.org>.
boris-petrov commented on issue #2050:
URL: https://github.com/apache/shiro/issues/2050#issuecomment-2757457386
@lprimak thank you for the quick response and fix! Yes, your PR works fine and my application doesn't crash any more. I'll be eagerly awaiting a new release with the fix. 😄
--
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: issues-unsubscribe@shiro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@shiro.apache.org
For additional commands, e-mail: issues-help@shiro.apache.org
Re: [I] [Bug] `getRunAsPrincipalsStack` can throw random exceptions when the session is invalid [shiro]
Posted by "lprimak (via GitHub)" <gi...@apache.org>.
lprimak closed issue #2050: [Bug] `getRunAsPrincipalsStack` can throw random exceptions when the session is invalid
URL: https://github.com/apache/shiro/issues/2050
--
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: issues-unsubscribe@shiro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@shiro.apache.org
For additional commands, e-mail: issues-help@shiro.apache.org
Re: [I] [Bug] `getRunAsPrincipalsStack` can throw random exceptions when the session is invalid [shiro]
Posted by "lprimak (via GitHub)" <gi...@apache.org>.
lprimak commented on issue #2050:
URL: https://github.com/apache/shiro/issues/2050#issuecomment-2755700510
Nice find!
Can you test out my PR to see if it fixes your issue?
Thank you!
--
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: issues-unsubscribe@shiro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@shiro.apache.org
For additional commands, e-mail: issues-help@shiro.apache.org