From dbf7f4cfe5224b85b75449248a35ff69283a7e33 Mon Sep 17 00:00:00 2001 From: Tran Ngoc Nhan Date: Thu, 19 Feb 2026 17:55:08 +0700 Subject: [PATCH] Remove unused `@Nullable` Signed-off-by: Tran Ngoc Nhan --- .../security/core/authority/FactorGrantedAuthority.java | 1 - .../web/authentication/switchuser/SwitchUserFilter.java | 1 + .../authentication/switchuser/SwitchUserGrantedAuthority.java | 4 +--- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/org/springframework/security/core/authority/FactorGrantedAuthority.java b/core/src/main/java/org/springframework/security/core/authority/FactorGrantedAuthority.java index 8db5347b03..51d88fbb4a 100644 --- a/core/src/main/java/org/springframework/security/core/authority/FactorGrantedAuthority.java +++ b/core/src/main/java/org/springframework/security/core/authority/FactorGrantedAuthority.java @@ -88,7 +88,6 @@ public final class FactorGrantedAuthority implements GrantedAuthority { private final Instant issuedAt; - @SuppressWarnings("NullAway") private FactorGrantedAuthority(String authority, Instant issuedAt) { Assert.notNull(authority, "authority cannot be null"); Assert.notNull(issuedAt, "issuedAt cannot be null"); diff --git a/web/src/main/java/org/springframework/security/web/authentication/switchuser/SwitchUserFilter.java b/web/src/main/java/org/springframework/security/web/authentication/switchuser/SwitchUserFilter.java index 5f262928dc..c6910250cd 100644 --- a/web/src/main/java/org/springframework/security/web/authentication/switchuser/SwitchUserFilter.java +++ b/web/src/main/java/org/springframework/security/web/authentication/switchuser/SwitchUserFilter.java @@ -303,6 +303,7 @@ public class SwitchUserFilter extends GenericFilterBean implements ApplicationEv // grant an additional authority that contains the original Authentication object // which will be used to 'exit' from the current switched user. Authentication currentAuthentication = getCurrentAuthentication(request); + Assert.notNull(currentAuthentication, "currentAuthentication cannot be null"); GrantedAuthority switchAuthority = new SwitchUserGrantedAuthority(this.switchAuthorityRole, currentAuthentication); // get the original authorities diff --git a/web/src/main/java/org/springframework/security/web/authentication/switchuser/SwitchUserGrantedAuthority.java b/web/src/main/java/org/springframework/security/web/authentication/switchuser/SwitchUserGrantedAuthority.java index 153ace1fea..475beae7f9 100644 --- a/web/src/main/java/org/springframework/security/web/authentication/switchuser/SwitchUserGrantedAuthority.java +++ b/web/src/main/java/org/springframework/security/web/authentication/switchuser/SwitchUserGrantedAuthority.java @@ -16,8 +16,6 @@ package org.springframework.security.web.authentication.switchuser; -import org.jspecify.annotations.Nullable; - import org.springframework.security.core.Authentication; import org.springframework.security.core.GrantedAuthority; import org.springframework.util.Assert; @@ -40,7 +38,7 @@ public final class SwitchUserGrantedAuthority implements GrantedAuthority { private final Authentication source; - public SwitchUserGrantedAuthority(String role, @Nullable Authentication source) { + public SwitchUserGrantedAuthority(String role, Authentication source) { Assert.notNull(role, "role cannot be null"); Assert.notNull(source, "source cannot be null"); this.role = role;