Skip to content

Commit

Permalink
Update cache when awsconfig file changes (#2946)
Browse files Browse the repository at this point in the history
* Update cache when awsconfig file changes

* added comment to the change

Co-authored-by: Banji Jolaoso <banjij@amazon.com>
  • Loading branch information
banji180 and Banji Jolaoso authored Aug 23, 2022
1 parent 157fd45 commit a91f1d4
Showing 1 changed file with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -705,19 +705,18 @@ JSONObject getHostedUIJSON() {
JSONObject getHostedUIJSON(final AWSConfiguration awsConfig) {
try {
JSONObject hostedUIJSONFromJSON = getHostedUIJSONFromJSON(awsConfig);
if (hostedUIJSONFromJSON == null) {
return null;
}

final String hostedUIString = mStore.get(HOSTED_UI_KEY);
JSONObject hostedUIJSON = null;
try {
hostedUIJSON = new JSONObject(hostedUIString);
} catch (Exception e) {
Log.w(TAG,
"Failed to parse HostedUI settings from store. Defaulting to awsconfiguration.json", e);
"Failed to parse HostedUI settings from store", e);
}
if (hostedUIJSON == null && hostedUIJSONFromJSON != null) {

// Since there is no file watcher to keep track of when config file changes, this logic is intended to always check if the config file is different from mstore cache and updates the later accordingly.
// If config file cannot be loaded, the mstore data still prevails.
if (hostedUIJSONFromJSON != null && (hostedUIJSON == null || hostedUIJSON.toString() != hostedUIJSONFromJSON.toString())) {
hostedUIJSON = new JSONObject(hostedUIJSONFromJSON.toString());
mStore.set(HOSTED_UI_KEY, hostedUIJSON.toString());
}
Expand Down

0 comments on commit a91f1d4

Please sign in to comment.