Fix compile warning in spring-security-test #18593
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
#18440
Here's an explanation of the compiler warnings fixed in this PR:
Fixed Warnings

1. WebSecurityConfigurationTests.java
Issue: Raw type warning due to missing generic type specification in ClassUtils.getMethod() call
Fix: Added (Class<?>[]) cast to ensure generic type safety
2. OneTimeTokenAuthenticationTokenTests.java

Issue: Warning from using deprecated functionality
Fix: Added @SuppressWarnings("removal") annotation to suppress the deprecation warning
3. OneTimeTokenReactiveAuthenticationManagerTests.java

Issue: Deprecation warnings from using deprecated OneTimeTokenAuthenticationToken or related deprecated APIs throughout the test methods
Fix: Added @SuppressWarnings("removal") annotation to each test method that uses the deprecated functionality
4. AuthorityAuthorizationManagerTests.java

Issue: Ambiguous method call warnings. Passing null directly to varargs methods like hasAnyRole(String...) and hasAnyAuthority(String...) creates ambiguity - the compiler can't determine if null represents a null array or an array containing a single null element
Fix: Added explicit (String[]) cast to clarify that null represents a null array, not a single null element
5. DefaultMethodSecurityExpressionHandlerKotlinTests.kt

Issue: Kotlin's "unchecked cast" warnings when casting generic types. The compiler cannot verify at runtime that the cast to parameterized types like Map<String, String>, Collection, Array, or Stream is type-safe, since generic type information is erased at runtime
Fix: Added @Suppress("UNCHECKED_CAST") annotation to explicitly acknowledge and suppress these unavoidable warnings
6/ DelegatingAuthenticationEntryPointTests.java

Issue: Deprecation warnings from using the deprecated DelegatingAuthenticationEntryPoint class or its constructors/methods
Fix: Added @SuppressWarnings("removal") annotation to each test method that uses the deprecated functionality
7. OneTimeTokenAuthenticationFilterTests.java

Issue: Deprecation warnings from using deprecated OneTimeTokenAuthenticationFilter or related one-time token authentication APIs
Fix: Added @SuppressWarnings("removal") annotation to each test method that uses the deprecated functionality