Skip to content

Commit a91f1d4

Browse files
banji180Banji Jolaoso
andauthored
Update cache when awsconfig file changes (#2946)
* Update cache when awsconfig file changes * added comment to the change Co-authored-by: Banji Jolaoso <[email protected]>
1 parent 157fd45 commit a91f1d4

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

aws-android-sdk-mobile-client/src/main/java/com/amazonaws/mobile/client/AWSMobileClient.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -705,19 +705,18 @@ JSONObject getHostedUIJSON() {
705705
JSONObject getHostedUIJSON(final AWSConfiguration awsConfig) {
706706
try {
707707
JSONObject hostedUIJSONFromJSON = getHostedUIJSONFromJSON(awsConfig);
708-
if (hostedUIJSONFromJSON == null) {
709-
return null;
710-
}
711-
712708
final String hostedUIString = mStore.get(HOSTED_UI_KEY);
713709
JSONObject hostedUIJSON = null;
714710
try {
715711
hostedUIJSON = new JSONObject(hostedUIString);
716712
} catch (Exception e) {
717713
Log.w(TAG,
718-
"Failed to parse HostedUI settings from store. Defaulting to awsconfiguration.json", e);
714+
"Failed to parse HostedUI settings from store", e);
719715
}
720-
if (hostedUIJSON == null && hostedUIJSONFromJSON != null) {
716+
717+
// 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.
718+
// If config file cannot be loaded, the mstore data still prevails.
719+
if (hostedUIJSONFromJSON != null && (hostedUIJSON == null || hostedUIJSON.toString() != hostedUIJSONFromJSON.toString())) {
721720
hostedUIJSON = new JSONObject(hostedUIJSONFromJSON.toString());
722721
mStore.set(HOSTED_UI_KEY, hostedUIJSON.toString());
723722
}

0 commit comments

Comments
 (0)