diff --git a/oauth2/oauth2-resource-server/src/main/java/org/springframework/security/oauth2/server/resource/authentication/JwtIssuerReactiveAuthenticationManagerResolver.java b/oauth2/oauth2-resource-server/src/main/java/org/springframework/security/oauth2/server/resource/authentication/JwtIssuerReactiveAuthenticationManagerResolver.java index 40ff610edc..a30359176b 100644 --- a/oauth2/oauth2-resource-server/src/main/java/org/springframework/security/oauth2/server/resource/authentication/JwtIssuerReactiveAuthenticationManagerResolver.java +++ b/oauth2/oauth2-resource-server/src/main/java/org/springframework/security/oauth2/server/resource/authentication/JwtIssuerReactiveAuthenticationManagerResolver.java @@ -121,7 +121,7 @@ public final class JwtIssuerReactiveAuthenticationManagerResolver return this.issuerConverter.convert(exchange) .flatMap(issuer -> this.issuerAuthenticationManagerResolver.resolve(issuer).switchIfEmpty( - Mono.error(new InvalidBearerTokenException("Invalid issuer " + issuer))) + Mono.error(() -> new InvalidBearerTokenException("Invalid issuer " + issuer))) ); } @@ -142,7 +142,7 @@ public final class JwtIssuerReactiveAuthenticationManagerResolver try { String issuer = JWTParser.parse(token.getToken()).getJWTClaimsSet().getIssuer(); return Mono.justOrEmpty(issuer).switchIfEmpty( - Mono.error(new InvalidBearerTokenException("Missing issuer"))); + Mono.error(() -> new InvalidBearerTokenException("Missing issuer"))); } catch (Exception e) { return Mono.error(new InvalidBearerTokenException(e.getMessage())); }