Skip to content

Commit 89354df

Browse files
committed
fix: return null if cannot parse jwt
1 parent d529bfd commit 89354df

File tree

1 file changed

+2
-1
lines changed
  • src/main/java/fr/redfroggy/ilg/spring/boot/autoconfigure/client/cache

1 file changed

+2
-1
lines changed

src/main/java/fr/redfroggy/ilg/spring/boot/autoconfigure/client/cache/JwtCache.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,13 @@ public AuthenticationJwt get(String key, Supplier<AuthenticationJwt> getNewToken
3434
public AuthenticationJwt putAndGet(String key, Supplier<AuthenticationJwt> getNewToken) {
3535
AuthenticationJwt jwt = getNewToken.get();
3636
JWT accessToken;
37-
Date expirationTime = null;
37+
Date expirationTime;
3838
try {
3939
accessToken = JWTParser.parse(jwt.getToken());
4040
expirationTime = accessToken.getJWTClaimsSet().getExpirationTime();
4141
} catch (ParseException e) {
4242
log.error("Cannot parse authentication jwt.",e);
43+
return null;
4344
}
4445
Duration durationCache = Duration.between(Instant.now().plusSeconds(5), expirationTime.toInstant());
4546
if (!(durationCache.getSeconds() == this.durationCache.getSeconds())) {

0 commit comments

Comments
 (0)