Skip to content

Commit

Permalink
[JENKINS-55945] IllegalStateException trying to get user. (#4107)
Browse files Browse the repository at this point in the history
This change catches the exception and returns false, invalidating the user session. This behavior is sensible, because if we are unable to validate the user we must assume the session is invalid.
Catching the error at this point reportedly helps with some scenarios and shouldn't cause any further harm.
  • Loading branch information
jeffret-b authored and oleg-nenashev committed Jul 11, 2019
1 parent b9d507c commit 8349ceb
Showing 1 changed file with 7 additions and 1 deletion.
Expand Up @@ -84,7 +84,13 @@ private boolean hasInvalidSessionSeed(Authentication authentication, HttpSession
return false;
}

User userFromSession = User.getById(authentication.getName(), false);
User userFromSession;
try {
userFromSession = User.getById(authentication.getName(), false);
} catch (IllegalStateException ise) {
logger.warn("Encountered IllegalStateException trying to get a user. System init may not have completed yet. Invalidating user session.");
return false;
}
if (userFromSession == null) {
// no requirement for further test as there is no user inside
return false;
Expand Down

0 comments on commit 8349ceb

Please sign in to comment.