Skip to content

Commit

Permalink
Nullpointer on nonexistent session (#58)
Browse files Browse the repository at this point in the history
When Jenkins is restarted(or session information otherwise lost) half way through the interaction it might not have a session at this point.
  • Loading branch information
mjmbischoff authored Jan 20, 2019
1 parent 91ef8a8 commit 52c1ea1
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,12 @@ private String buildOAuthRedirectUrl() throws NullPointerException {
* @return an HttpResponse
*/
public HttpResponse doFinishLogin(StaplerRequest request) {
return OicSession.getCurrent().doFinishLogin(request);
OicSession currentSession = OicSession.getCurrent();
if(currentSession==null) {
LOGGER.fine("No session to resume (perhaps jenkins was restarted?)");
return HttpResponses.errorWithoutStack(401, "Unauthorized");
}
return currentSession.doFinishLogin(request);
}

/**
Expand Down

0 comments on commit 52c1ea1

Please sign in to comment.