-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Fixed NullPointerException with WWW-Authenticate #9303
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
Conversation
2a40bba
to
e8e88eb
Compare
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.
Thanks for the PR, @tristanessquare! I've left some feedback inline.
@@ -70,7 +70,7 @@ private OAuth2Error readErrorFromWwwAuthenticate(HttpHeaders headers) { | |||
return null; | |||
} | |||
BearerTokenError bearerTokenError = getBearerToken(wwwAuthenticateHeader); | |||
String errorCode = (bearerTokenError.getCode() != null) ? bearerTokenError.getCode() | |||
String errorCode = (bearerTokenError != null && bearerTokenError.getCode() != null) ? bearerTokenError.getCode() |
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.
This doesn't appear to address the issue completely since bearerTokenError
is referred to later on in the method, potentially causing more NPEs.
If wonder if it would be better to do:
if (bearerTokenError == null) {
return new OAuth2Error(OAuth2ErrorCodes.SERVER_ERROR, null, null);
}
String errorCode = ...
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.
That's a good point. I will do that.
Hi, @tristanessquare! Are you able to make the requested changes? |
e8e88eb
to
ab60faa
Compare
Thanks, @tristanessquare! I think the changes make sense. Since this is addressing a bug, would you please also add a test to |
ab60faa
to
d6bfc7c
Compare
d6bfc7c
to
0ad5b44
Compare
Thanks for the PR, @tristanessquare! This is now merged into |
Fixed possible NullPointerException that happens when the OAuth2 ResourceServer does not return a valid WWW-Authenticate header format.