From a3a8f23b3df79ce24592c57940f9073a51bee4ab Mon Sep 17 00:00:00 2001 From: kwondh5217 Date: Wed, 18 Dec 2024 14:59:46 +0900 Subject: [PATCH] Remove Deprecated Usages of RemoteJWKSet close gh-16251 --- .../security/oauth2/jwt/NimbusJwtDecoder.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/oauth2/oauth2-jose/src/main/java/org/springframework/security/oauth2/jwt/NimbusJwtDecoder.java b/oauth2/oauth2-jose/src/main/java/org/springframework/security/oauth2/jwt/NimbusJwtDecoder.java index e5a6368e92..936eb8b1dd 100644 --- a/oauth2/oauth2-jose/src/main/java/org/springframework/security/oauth2/jwt/NimbusJwtDecoder.java +++ b/oauth2/oauth2-jose/src/main/java/org/springframework/security/oauth2/jwt/NimbusJwtDecoder.java @@ -457,8 +457,12 @@ public List get(JWKSelector jwkSelector, SecurityContext context) throws Ke return Collections.emptyList(); } synchronized (this) { - jwkSet = fetchJWKSet(); - this.jwkSetCache.put(jwkSet); + if(jwkSet == this.jwkSetCache.get()) { + jwkSet = fetchJWKSet(); + this.jwkSetCache.put(jwkSet); + } else { + jwkSet = this.jwkSetCache.get(); + } } if(jwkSet == null) { return Collections.emptyList();