I cannot delete from DB if I throw an exception immediately on the next line.
public void verifyExpiration(RefreshToken token) {
if (token.getExpiryDate().compareTo(Instant.now()) < 0) {
this.delete(token.getToken());
throw new TokenException("Refresh token was expired: " + token.getToken());
}
}
public void delete(String token) {
this.refreshTokenRepository.deleteByToken(token);
}
What am I missing?