Remove BeanResolver Null Checks#19209
Conversation
StandardEvaluationContext.setBeanResolver now accepts a nullable BeanResolver, so the workarounds added for the original limitation are no longer needed. This removes the explicit null guards (and equivalent Optional.ofNullable idiom) as well as the @SuppressWarnings("NullAway") annotations introduced to silence the false positives. In addition to the seven sites that explicitly referenced spring-projects/spring-framework#35371, two sites in spring-security-core followed the same workaround pattern without the comment marker (AbstractSecurityExpressionHandler and DefaultMethodSecurityExpressionHandler) and have also been simplified. Closes spring-projectsgh-17816 Signed-off-by: Kim Tae Eun <snowykte0426@naver.com>
|
A few choices I made that I'd like to confirm before this is merged:
|
Resolves gh-17816.
Spring Framework updated
StandardEvaluationContext.setBeanResolverto accept a
@Nullable BeanResolver(spring-projects/spring-framework#35371, included in 6.2.11 and 7.0.x).
Since Spring Security now depends on Spring Framework 7.0.7,
the temporary NullAway workarounds around
setBeanResolvercan be removed.
Changes
Removed temporary workarounds from the following locations.
Removed
@SuppressWarnings("NullAway")DefaultHttpSecurityExpressionHandlerCurrentSecurityContextArgumentResolverAuthenticationPrincipalArgumentResolverRemoved unnecessary null guards
AuthenticationPrincipalArgumentResolverCurrentSecurityContextArgumentResolverCurrentSecurityContextArgumentResolverDefaultMessageSecurityExpressionHandlerAlso removed obsolete comments referencing
spring-projects/spring-framework#35371 and cleaned up
unused imports/local variables where applicable.
Behavior
No behavior change.
StandardEvaluationContext.beanResolverdefaults tonull,so calling
setBeanResolver(null)is equivalent to not invokingthe setter.
Verification
./gradlew :spring-security-web:compileJava :spring-security-messaging:compileJava./gradlew :spring-security-web:test --tests "*AuthenticationPrincipalArgumentResolver*" --tests "*CurrentSecurityContextArgumentResolver*" --tests "*DefaultHttpSecurityExpressionHandler*"./gradlew :spring-security-messaging:test --tests "*CurrentSecurityContextArgumentResolver*" --tests "*DefaultMessageSecurityExpressionHandler*"grep -rn "35371" --include="*.java"