Calculating the next refresh interval - #24
Conversation
| List<AuthStateListener> listenersCopy = null; | ||
| if (!newToken.equals(oldToken)) { | ||
| long refreshDelay = googleOAuthToken.getExpiryTime() - clock.now() | ||
| - TimeUnit.MINUTES.toMillis(5); |
There was a problem hiding this comment.
Can we move this code below to where it's actually used?
| if (currentToken.compareAndSet(oldToken, newToken)) { | ||
| listenersCopy = ImmutableList.copyOf(authStateListeners); | ||
| tokenRefresher.scheduleRefresh(TOKEN_REFRESH_INTERVAL_MILLIS); | ||
| if (refreshDelay > 0) { |
There was a problem hiding this comment.
<= 0 would likely indicate a bug, right? Should we at least log a message? If we were confident it should never happen, I'd throw an Exception... but I guess a developer-provided credentials class could generate tokens that expire in less than 5 minutes or something.
There was a problem hiding this comment.
Added a log statement
|
Made the suggested changes. |
| tokenRefresher.scheduleRefresh(refreshDelay); | ||
| } else { | ||
| Log.w("FirebaseApp", "Token validity period is less than 5 " | ||
| + "minutes. Not scheduling a proactive refresh event."); |
There was a problem hiding this comment.
FWIW, if we see this log message, something is probably broken and having as much information as possible will help figure it out sooner. So I would do something like:
Log.w("FirebaseApp", "Token expiry (" + googleOAuthToken.getExpiryTime() + ") is less than 5 minutes in the future. Not scheduling a proactive refresh.");
This would probably be enough to determine if: 1) the expiration time is in the past for some reason, 2) the expiration time is super short for some reason, 3) the expiration time is fine so maybe the local clock is wrong.
Not a big deal, but consider tweaking before merging...
There was a problem hiding this comment.
Good point. Updated the log statement as suggested.
No description provided.