@@ -29,11 +29,19 @@ static void migrateWhenNeeded(Application application, LDConfig config) {
2929 }
3030
3131 if (!migrations .contains ("v2.6.0" )) {
32- migrate_2_7_fresh (application , config );
32+ try {
33+ migrate_2_7_fresh (application , config );
34+ } catch (Exception ex ) {
35+ Timber .w (ex , "Exception while performing fresh v2.7.0 store migration" );
36+ }
3337 }
3438
3539 if (migrations .contains ("v2.6.0" ) && !migrations .contains ("v2.7.0" )) {
36- migrate_2_7_from_2_6 (application );
40+ try {
41+ migrate_2_7_from_2_6 (application );
42+ } catch (Exception ex ) {
43+ Timber .w (ex , "Exception while performing v2.6.0 to v2.7.0 store migration" );
44+ }
3745 }
3846 }
3947
@@ -75,8 +83,11 @@ private static void migrate_2_7_fresh(Application application, LDConfig config)
7583 String prefsKey = LDConfig .SHARED_PREFS_BASE_KEY + mobileKey + key + "-flags" ;
7684 SharedPreferences .Editor userFlagStoreEditor = application .getSharedPreferences (prefsKey , Context .MODE_PRIVATE ).edit ();
7785 for (String flagKey : flagKeys ) {
78- String flagString = reconstructFlag (flagKey , (String ) flagData .get (flagKey ), flagValues .get (flagKey ));
79- userFlagStoreEditor .putString (flagKey , flagString );
86+ Object flagVersionData = flagData .get (flagKey );
87+ if (flagVersionData instanceof String ) {
88+ String flagString = reconstructFlag (flagKey , (String ) flagVersionData , flagValues .get (flagKey ));
89+ userFlagStoreEditor .putString (flagKey , flagString );
90+ }
8091 }
8192 stores = stores && userFlagStoreEditor .commit ();
8293 }
@@ -114,8 +125,11 @@ private static void migrate_2_7_from_2_6(Application application) {
114125 Map <String , ?> flagValues = application .getSharedPreferences (LDConfig .SHARED_PREFS_BASE_KEY + mobileKey + key + "-user" , Context .MODE_PRIVATE ).getAll ();
115126 SharedPreferences .Editor userFlagStoreEditor = application .getSharedPreferences (LDConfig .SHARED_PREFS_BASE_KEY + mobileKey + key + "-flags" , Context .MODE_PRIVATE ).edit ();
116127 for (String flagKey : flagKeys ) {
117- String flagString = reconstructFlag (flagKey , (String ) flagData .get (flagKey ), flagValues .get (flagKey ));
118- userFlagStoreEditor .putString (flagKey , flagString );
128+ Object flagVersionData = flagData .get (flagKey );
129+ if (flagVersionData instanceof String ) {
130+ String flagString = reconstructFlag (flagKey , (String ) flagVersionData , flagValues .get (flagKey ));
131+ userFlagStoreEditor .putString (flagKey , flagString );
132+ }
119133 }
120134 allSuccess = allSuccess && userFlagStoreEditor .commit ();
121135 }
0 commit comments