New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[JENKINS-55945] IllegalStateException trying to get user. #4107
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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."); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it be useful to include the exception in the log message? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I debated that myself. My opinion is that because the handling is so narrow, it would just introduce clutter to include the exception. If we broadened the catch, then we would definitely want to add the exception. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It the issue is understood, a stack trace only makes the log look scarier. It's easy to misread a stack trace as an exception that wasn't handled properly. On the other hand, the message from the exception could be useful to make sure we caught the correct exception. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jvz do you consider this comment as resolved? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh yeah, good with me. |
||
return false; | ||
} | ||
if (userFromSession == null) { | ||
// no requirement for further test as there is no user inside | ||
return false; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No-idiomatic abbreviations set a bad example to others. Common names for an exception are
e
,x
andex
. Not a blocker.