diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/ReactiveTokenValidator.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/ReactiveTokenValidator.java index cbafdbccc2..c154c9c700 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/ReactiveTokenValidator.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/ReactiveTokenValidator.java @@ -23,6 +23,7 @@ import java.security.PublicKey; import java.security.Signature; import java.security.spec.InvalidKeySpecException; import java.security.spec.X509EncodedKeySpec; +import java.util.HashMap; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.TimeUnit; @@ -71,7 +72,8 @@ class ReactiveTokenValidator { private Mono validateKeyIdAndSignature(Token token) { String keyId = token.getKeyId(); - return Mono.just(this.cachedTokenKeys) + Map localCachedTokenKeys = new HashMap<>(this.cachedTokenKeys); + return Mono.just(localCachedTokenKeys) .filter((tokenKeys) -> tokenKeys.containsKey(keyId)) .switchIfEmpty(this.securityService.fetchTokenKeys() .doOnSuccess((fetchedTokenKeys) -> {