-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Remove internal Optional usage in favor of null checks #7295
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
Remove internal Optional usage in favor of null checks #7295
Conversation
…ster' of https://github.com/watsta/spring-security into spring-projectsgh-7155-remove-optional-usage # Conflicts: # oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/web/reactive/function/client/ServerOAuth2AuthorizedClientExchangeFilterFunction.java
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.
Thank you for the PR @watsta. I've left some feedback inline.
.map(configurationMetadata -> configurationMetadata.get("end_session_endpoint")) | ||
.map(Object::toString) | ||
.map(URI::create); | ||
ClientRegistration clientRegistration = this.clientRegistrationRepository.findByRegistrationId(registrationId); |
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.
clientRegistration
may be null
. Please add a null check here.
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.
Fixed in 6a4425c
@@ -67,7 +67,6 @@ | |||
import java.util.HashSet; | |||
import java.util.List; | |||
import java.util.Map; | |||
import java.util.Optional; |
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.
There is no need to change this file since it is a test. Please revert this change.
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.
Reverted in f6f4378
if (this.accessTokenResponseClient != null) { | ||
authorizedClientProviderBuilder.clientCredentials(configurer -> | ||
configurer.accessTokenResponseClient(this.accessTokenResponseClient)); | ||
} |
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 code changes the existing functionality. If accessTokenResponseClient
is null, clientCredentials
should still be enabled. Please add an else
statement containing authorizedClientProviderBuilder.clientCredentials()
to ensure clientCredentials
is enabled by default.
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.
Updated in 3fef167
Hi @eleftherias, Thank you for the comments! I updated the PR with the requested changes. |
Thanks for the PR @watsta! This is now merged into master. |
Fixes gh-7155
I did not modify public APIs, tests, examples and samples. Optional usage in the codebase after this PR:
Note that Optional is still used in
org.springframework.security.oauth2.client.web.reactive.function.client.OAuth2AuthorizedClientResolver
org.springframework.security.oauth2.client.web.reactive.result.method.annotation.OAuth2AuthorizedClientResolver
As I couldn't think of a nice way to resolve it.