Instantiate exceptions lazily
Add lazy Exception instantiation to reduce allocations Fixes gh-7995
This commit is contained in:
parent
727fee1e12
commit
04e671fb4d
|
@ -121,7 +121,7 @@ public final class JwtIssuerReactiveAuthenticationManagerResolver
|
||||||
return this.issuerConverter.convert(exchange)
|
return this.issuerConverter.convert(exchange)
|
||||||
.flatMap(issuer ->
|
.flatMap(issuer ->
|
||||||
this.issuerAuthenticationManagerResolver.resolve(issuer).switchIfEmpty(
|
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 {
|
try {
|
||||||
String issuer = JWTParser.parse(token.getToken()).getJWTClaimsSet().getIssuer();
|
String issuer = JWTParser.parse(token.getToken()).getJWTClaimsSet().getIssuer();
|
||||||
return Mono.justOrEmpty(issuer).switchIfEmpty(
|
return Mono.justOrEmpty(issuer).switchIfEmpty(
|
||||||
Mono.error(new InvalidBearerTokenException("Missing issuer")));
|
Mono.error(() -> new InvalidBearerTokenException("Missing issuer")));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return Mono.error(new InvalidBearerTokenException(e.getMessage()));
|
return Mono.error(new InvalidBearerTokenException(e.getMessage()));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue