-
Notifications
You must be signed in to change notification settings - Fork 6.2k
Remove compiler warnings for spring-security-oauth2-authorization-server #18562
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?
Remove compiler warnings for spring-security-oauth2-authorization-server #18562
Conversation
98b1478 to
2218ebe
Compare
Remove compiler warnings in spring-security-oauth2-authorization-server - Remove ACCESS_DECLARED_FIELDS from AOT/runtime hints - Add @SuppressWarnings("removal") for Jackson2 deprecated adapters Closes spring-projectsgh-18432 Signed-off-by: gimgisu <[email protected]>
2218ebe to
e0ef1d6
Compare
rwinch
left a comment
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! I've responded with a few comments. Please keep in mind that there are a few examples of me wanting to understand why the deprecated fields in MemberCategory were not migrated according to the Javadocs, but this is a general question and should be considered throughout the whole pull request.
| // Jackson Modules | ||
| if (jackson2Present) { | ||
| hints.reflection() | ||
| .registerTypes( |
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 needs to continue to register the jackson 2 modules for passivity. You can extract it into a separate method and add a suppression to it.
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.
Agreed. Jackson 2 module registration is still required for passivity when Jackson 2
is present on the classpath.
I will keep the Jackson 2 registrations, extract them into a dedicated helper method,
and scope @SuppressWarnings("removal") to that method only so the intent is explicit
while preserving the existing behavior.
Jackson 3 module registration will remain unchanged.
Thank you.
| hints.reflection() | ||
| .registerType(Collections.class, MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, | ||
| MemberCategory.INVOKE_DECLARED_METHODS); |
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 and the similar changes don't seem to be a one to one change from deprecation to replacement. For example, I'd expect this change to be as shown in this suggestion since the deprecation for DECLARED_CLASSES states it is deprecated with no replacement since registerType registers the class.
| hints.reflection() | |
| .registerType(Collections.class, MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, | |
| MemberCategory.INVOKE_DECLARED_METHODS); | |
| hints.reflection().registerType(Collections.class); |
Can you help me understand why these changes do not appear to be a one to one replacement for the deprecations?
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 clarification.
You're right — my change removed MemberCategory.DECLARED_CLASSES but didn’t make it explicit that the type itself is still being registered.
Since DECLARED_CLASSES is deprecated with no replacement (because registerType already registers the class), I’ll add an explicit
hints.reflection().registerType(T.class) alongside the existing INVOKE_* categories. This preserves the original “type registration”
intent while keeping the reflective invocation hints where needed.
| hints.reflection() | ||
| .registerType(HashSet.class, MemberCategory.DECLARED_FIELDS, | ||
| MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, MemberCategory.INVOKE_DECLARED_METHODS); | ||
| .registerType(HashSet.class, MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, |
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.
Can you help me understand why MemberCategory.DECLARED_FIELDS wasn't migrated to MemberCategory.INVOKE_DECLARED_FIELDS as documented within the Javadoc?
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 pointing this out.
You’re right — MemberCategory.DECLARED_FIELDS should be migrated to MemberCategory.ACCESS_DECLARED_FIELDS as documented in the Javadoc.
In my earlier change, I removed DECLARED_FIELDS without explicitly replacing it with ACCESS_DECLARED_FIELDS, which made the migration look incomplete and not 1:1.
I’ve updated the code so that:
- All previous DECLARED_FIELDS usages are now migrated to
ACCESS_DECLARED_FIELDS. - INVOKE_DECLARED_CONSTRUCTORS / INVOKE_DECLARED_METHODS are kept only where
reflective invocation was already required.
This preserves the original intent of field access while aligning with the documented replacement in Spring Framework 7.
Summary
Closes #18432
AOT/runtime hints in the OAuth2 Authorization Server module
Deprecated Jackson2 adapter usage
Testing
Notes
Other module warnings are unchanged and outside this module’s scope.