Skip to content

AOT contributions will be registered for JbcOAuth2AuthorizationService subclasses #1778

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

Closed
wants to merge 1 commit into from

Conversation

billkoch
Copy link
Contributor

AOT contributions will be registered for JbcOAuth2AuthorizationService subclasses

Prior to this commit, String-based class name comparisons were used for determining if a bean was of type JdbcOAuth2AuthorizationService or JdbcRegisteredClientRepository.

Now JdbcOAuth2AuthorizationService.class.isAssignableFrom(...) and JdbcRegisteredClientRepository.class.isAssignableFrom(...) is used so that any subclasses are detected and the necessary AOT hints are contributed.

closes gh-1737

Copy link
Collaborator

@jgrandja jgrandja left a 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 @billkoch. Please see review comments.

Also, can you please rebase off the 1.2.x branch and I'll take care of forward porting it to main.

@@ -43,8 +43,10 @@
import org.springframework.security.oauth2.core.oidc.user.OidcUserAuthority;
import org.springframework.security.oauth2.core.user.DefaultOAuth2User;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update copyright year

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤦‍♂️ Fixed

@@ -0,0 +1,108 @@
/*
* Copyright 2020-2021 the original author or authors.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update copyright year


import static org.assertj.core.api.Assertions.assertThat;

class OAuth2AuthorizationServerBeanRegistrationAotProcessorTests {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add javadoc similar to other tests

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed


class OAuth2AuthorizationServerBeanRegistrationAotProcessorTests {

OAuth2AuthorizationServerBeanRegistrationAotProcessor processor;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make the members private

@ParameterizedTest
@ValueSource(classes = { JdbcOAuth2AuthorizationService.class, CustomJdbcOAuth2AuthorizationService.class,
JdbcRegisteredClientRepository.class, CustomJdbcRegisteredClientRepository.class })
void whenABeanRegistrationAotContributionShouldBeReturned(Class<?> beanClass) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename to processAheadOfTimeWhenBeanTypeJdbcBasedImplThenReturnContribution

@ParameterizedTest
@ValueSource(classes = { InMemoryOAuth2AuthorizationService.class, InMemoryRegisteredClientRepository.class,
Object.class })
void whenABeanRegistrationAotContributionShouldNotBeReturned(Class<?> beanClass) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename to processAheadOfTimeWhenBeanTypeNotJdbcBasedImplThenDoesNotReturnContribution

}

@Test
void aotContributionOnlyNeedsSpecifiedOnce() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename to processAheadOfTimeWhenMultipleBeanTypeJdbcBasedImplThenReturnContributionOnce

@jgrandja jgrandja added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Oct 18, 2024
@jgrandja jgrandja added this to the 1.2.7 milestone Oct 18, 2024
@jgrandja jgrandja self-assigned this Oct 18, 2024
…e subclasses

Prior to this commit, String-based class name comparisons were used for determining if a bean was of type JdbcOAuth2AuthorizationService or
JdbcRegisteredClientRepository.

Now JdbcOAuth2AuthorizationService.class.isAssignableFrom(...) and JdbcRegisteredClientRepository.class.isAssignableFrom(...) is used so that any subclasses are
detected and the necessary AOT hints are contributed.

closes spring-projectsgh-1737
@billkoch billkoch changed the base branch from main to 1.2.x October 18, 2024 18:51
@billkoch
Copy link
Contributor Author

@jgrandja Thanks for the review! I believe I've addressed all the comments. Please let me know if there's anything else you'd like me to change.

@jgrandja
Copy link
Collaborator

Thanks for the updates @billkoch. This is now merged!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Jackson2 AOT contribution not registered when extending JdbcOAuth2AuthorizationService
3 participants