-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SWC-7044 - Handle error when fetching feature flag configuration #5587
Conversation
attempt to recover on a BadRequestException by re-initializing the client
"JSONObjectAdapterException occurred in default configuration", | ||
e | ||
); | ||
throw new RuntimeException(e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we can't serialize a constant string "{}"
, we have bigger problems
if (configurationToken == null) { | ||
logger.log(Level.SEVERE, "returning default config"); | ||
return new JSONObjectAdapterImpl(DEFAULT_CONFIG_VALUE); | ||
logger.log( | ||
Level.SEVERE, | ||
"The configuration token is null, the last config value will be returned." + | ||
" This usually means that the initial call to initialize the configuration session failed." | ||
); | ||
return getLastConfigValueOrDefault(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like this error case will only happen when initialization failed, so I updated the log message to give context.
} catch (BadRequestException | InternalServerException e) { | ||
// Invalid token or server error, re-initialize the session to try to recover. | ||
logger.log( | ||
Level.SEVERE, | ||
"Failed to get latest configuration, returning last or default configuration and attempting to re-initialize the session.", | ||
e | ||
); | ||
initializeAppConfigClient(); | ||
return getLastConfigValueOrDefault(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the logs, a BadRequestException
was thrown with message "Token not valid"
. The tokens are one-time-use and my hypothesis is that we probably used a token more than once (maybe some network failure occurred and we didn't get the response containing a new token). Attempt to recover by re-initializing the session and getting a fresh token.
attempt to recover on a BadRequestException by re-initializing the client