Skip to content

Commit 1a177c5

Browse files
authored
Version 2.8.3 (#75)
## [2.8.3] - 2019-05-22 ### Added - Improved error handling on flag store migration. ### Fixed - ClassCastException when migrating flag store from certain early Android SDK versions.
1 parent 667ef8a commit 1a177c5

File tree

4 files changed

+28
-8
lines changed

4 files changed

+28
-8
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33

44
All notable changes to the LaunchDarkly Android SDK will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org).
55

6+
## [2.8.3] - 2019-05-22
7+
### Added
8+
- Improved error handling on flag store migration.
9+
### Fixed
10+
- ClassCastException when migrating flag store from certain early Android SDK versions.
11+
612
## [2.8.2] - 2019-05-14
713
### Fixed
814
- Thread leak (introduced in 2.8.0) when calling `identify()` on `LDClient` instances.

example/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ dependencies {
4646
implementation 'com.android.support:appcompat-v7:26.1.0'
4747
implementation project(path: ':launchdarkly-android-client-sdk')
4848
// Comment the previous line and uncomment this one to depend on the published artifact:
49-
//implementation 'com.launchdarkly:launchdarkly-android-client-sdk:2.8.2'
49+
//implementation 'com.launchdarkly:launchdarkly-android-client-sdk:2.8.3'
5050

5151
implementation 'com.jakewharton.timber:timber:4.7.1'
5252

launchdarkly-android-client-sdk/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ apply plugin: 'io.codearte.nexus-staging'
77

88
allprojects {
99
group = 'com.launchdarkly'
10-
version = '2.8.2'
10+
version = '2.8.3'
1111
sourceCompatibility = 1.7
1212
targetCompatibility = 1.7
1313
}

launchdarkly-android-client-sdk/src/main/java/com/launchdarkly/android/Migration.java

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)