Skip to content

Commit 2130317

Browse files
authored
fix: log error when token is invalid (#1313)
Fixes #1174
1 parent 2694cc5 commit 2130317

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

core/src/main/java/com/google/cloud/sql/core/SqlAdminApiFetcher.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -358,17 +358,21 @@ private void validateAccessToken(AccessToken accessToken) {
358358
DateTimeFormatter formatter = DateTimeFormatter.ISO_INSTANT.withZone(ZoneId.of("UTC"));
359359
String nowFormat = formatter.format(now);
360360
String expirationFormat = formatter.format(expirationTime);
361-
throw new RuntimeException(
361+
String errorMessage =
362362
"Access Token expiration time is in the past. Now = "
363363
+ nowFormat
364364
+ " Expiration = "
365-
+ expirationFormat);
365+
+ expirationFormat;
366+
logger.warning(errorMessage);
367+
throw new RuntimeException(errorMessage);
366368
}
367369
}
368370

369371
// Is the token empty?
370372
if (tokenValue.length() == 0) {
371-
throw new RuntimeException("Access Token has length of zero");
373+
String errorMessage = "Access Token has length of zero";
374+
logger.warning(errorMessage);
375+
throw new RuntimeException(errorMessage);
372376
}
373377
}
374378

0 commit comments

Comments
 (0)