From 1524b1d4bed3ddd5a07f7ea8d8aa69eb27b69f76 Mon Sep 17 00:00:00 2001 From: segabriel Date: Thu, 27 Jan 2022 15:26:26 +0200 Subject: [PATCH] Don't cache key resolutions when cleanup interval is zero (#94) --- .../scalecube/security/tokens/jwt/JwtTokenResolverImpl.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tokens/src/main/java/io/scalecube/security/tokens/jwt/JwtTokenResolverImpl.java b/tokens/src/main/java/io/scalecube/security/tokens/jwt/JwtTokenResolverImpl.java index 80be622..2aa548d 100644 --- a/tokens/src/main/java/io/scalecube/security/tokens/jwt/JwtTokenResolverImpl.java +++ b/tokens/src/main/java/io/scalecube/security/tokens/jwt/JwtTokenResolverImpl.java @@ -114,6 +114,10 @@ public Mono> resolve(String token) { } private Mono findKey(String kid, AtomicReference> computedValueHolder) { + if (cleanupInterval.isZero()) { + return Mono.defer(() -> keyProvider.findKey(kid)).cache(); + } + return keyResolutions.computeIfAbsent( kid, (kid1) -> {