Skip to content

Commit 04e671f

Browse files
robotmrvjzheaux
authored andcommitted
Instantiate exceptions lazily
Add lazy Exception instantiation to reduce allocations Fixes gh-7995
1 parent 727fee1 commit 04e671f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

oauth2/oauth2-resource-server/src/main/java/org/springframework/security/oauth2/server/resource/authentication/JwtIssuerReactiveAuthenticationManagerResolver.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public Mono<ReactiveAuthenticationManager> resolve(ServerWebExchange exchange) {
121121
return this.issuerConverter.convert(exchange)
122122
.flatMap(issuer ->
123123
this.issuerAuthenticationManagerResolver.resolve(issuer).switchIfEmpty(
124-
Mono.error(new InvalidBearerTokenException("Invalid issuer " + issuer)))
124+
Mono.error(() -> new InvalidBearerTokenException("Invalid issuer " + issuer)))
125125
);
126126
}
127127

@@ -142,7 +142,7 @@ private Mono<String> issuer(BearerTokenAuthenticationToken token) {
142142
try {
143143
String issuer = JWTParser.parse(token.getToken()).getJWTClaimsSet().getIssuer();
144144
return Mono.justOrEmpty(issuer).switchIfEmpty(
145-
Mono.error(new InvalidBearerTokenException("Missing issuer")));
145+
Mono.error(() -> new InvalidBearerTokenException("Missing issuer")));
146146
} catch (Exception e) {
147147
return Mono.error(new InvalidBearerTokenException(e.getMessage()));
148148
}

0 commit comments

Comments
 (0)