-
Couldn't load subscription status.
- Fork 6.2k
Add Support SupplierReactiveClientRegistrationRepository #16770
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
base: main
Are you sure you want to change the base?
Conversation
Closes spring-projectsgh-16750 Signed-off-by: Max Batischev <mblancer@mail.ru>
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, @franticticktick! I've left my feedback inline.
| public <T extends ReactiveClientRegistrationRepository & Iterable<ClientRegistration>> SupplierReactiveClientRegistrationRepository( | ||
| Supplier<? extends ReactiveClientRegistrationRepository> repositorySupplier) { | ||
| Assert.notNull(repositorySupplier, "repositorySupplier cannot be null"); | ||
| this.repositorySupplier = SingletonSupplier.of(repositorySupplier); |
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.
Are you able to change this logic to reflect SupplierReactiveJwtDecoder? I'd prefer to rely on reactive operations in this class since they are available to us.
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.
We have JwtDecoderInitializationException to indicate an error with lazy initialization of a JwtDecoder instance. Maybe it makes sense to introduce ClientRegistrationInitializationException in a separate commit?
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.
@franticticktick The problem is that if Supplier.get() is a blocking operation (e.g. making an HTTP request), then when ReactiveClientRegistrationRepository.findByRegistrationId is invoked it will invoke Supplier.get() and block the main thread.
|
Hey @jzheaux, maybe this PR got lost, could you look at it when you have time? |
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 again for the PR @franticticktick! Please see my feedback inline
| */ | ||
| @Override | ||
| public Iterator<ClientRegistration> iterator() { | ||
| return ((Iterable<ClientRegistration>) this.repositorySupplier.get()).iterator(); |
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.
If the generic type is done correctly, then this should not need to be cast. I've added hints in the code how to do this
| public final class SupplierReactiveClientRegistrationRepository | ||
| implements ReactiveClientRegistrationRepository, Iterable<ClientRegistration> { | ||
|
|
||
| private final Supplier<? extends ReactiveClientRegistrationRepository> repositorySupplier; |
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.
| private final Supplier<? extends ReactiveClientRegistrationRepository> repositorySupplier; | |
| private final Supplier<T> repositorySupplier; |
| * @see ReactiveClientRegistrationRepository | ||
| * @see ClientRegistration | ||
| */ | ||
| public final class SupplierReactiveClientRegistrationRepository |
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.
| public final class SupplierReactiveClientRegistrationRepository | |
| public final class SupplierReactiveClientRegistrationRepository<T extends ReactiveClientRegistrationRepository & Iterable<ClientRegistration>> |
| public <T extends ReactiveClientRegistrationRepository & Iterable<ClientRegistration>> SupplierReactiveClientRegistrationRepository( | ||
| Supplier<? extends ReactiveClientRegistrationRepository> repositorySupplier) { |
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.
| public <T extends ReactiveClientRegistrationRepository & Iterable<ClientRegistration>> SupplierReactiveClientRegistrationRepository( | |
| Supplier<? extends ReactiveClientRegistrationRepository> repositorySupplier) { | |
| public SupplierReactiveClientRegistrationRepository(Supplier<T> repositorySupplier) { |
Closes gh-16750