steinarb commented on code in PR #2807:
URL: https://github.com/apache/shiro/pull/2807#discussion_r3454636641
##########
core/src/main/java/org/apache/shiro/mgt/DefaultSecurityManager.java:
##########
@@ -305,7 +305,7 @@ public Subject login(Subject subject, AuthenticationToken
token) throws Authenti
* @param subject Subject
*/
protected void beforeSuccessfulLogin(Subject subject) {
- Session session = subject.getSession(false);
+ Session session = subject != null ? subject.getSession(false) : null;
Review Comment:
With a static import of Optional.session
```
import static java.util.Optional.ofNullable;
```
it is possible to make the expression more compact
```
Session session = ofNullable(subject).map(s ->
s.getSession(false)).orElse(null);
```
--
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]