Skip to content

Commit 209f8dc

Browse files
committed
Fix exception when parsing app-bundled remote config
1 parent 864b1d1 commit 209f8dc

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

app-tracking-protection/vpn-impl/src/main/java/com/duckduckgo/mobile/android/vpn/feature/settings/ExceptionListsSettingStore.kt

+2-4
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,7 @@ class ExceptionListsSettingStore @Inject constructor(
5050
override fun store(jsonString: String) {
5151
logcat { "Received configuration: $jsonString" }
5252
runCatching {
53-
jsonAdapter.fromJson(jsonString)?.let { model ->
54-
55-
val exceptionLists = model.exceptionLists
53+
jsonAdapter.fromJson(jsonString)?.exceptionLists?.let { exceptionLists ->
5654

5755
val appTrackerExceptionRuleList = exceptionLists.appTrackerAllowList.map { appTrackerAllowRule ->
5856
AppTrackerExceptionRule(
@@ -78,7 +76,7 @@ class ExceptionListsSettingStore @Inject constructor(
7876
}
7977

8078
private data class JsonConfigModel(
81-
val exceptionLists: JsonExceptionListsModel,
79+
val exceptionLists: JsonExceptionListsModel?,
8280
)
8381

8482
private data class JsonExceptionListsModel(

app-tracking-protection/vpn-impl/src/test/java/com/duckduckgo/mobile/android/vpn/feature/settings/ExceptionListsSettingStoreTest.kt

+6
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,12 @@ class ExceptionListsSettingStoreTest {
9696

9797
@Test
9898
fun whenEmptyJsonStoreNothing() {
99+
exceptionListsSettingStore.store("{}")
100+
verifyNoInteractions(mockVpnDatabase)
101+
}
102+
103+
@Test
104+
fun whenInvalidJsonStoreNothingAndDoNotCrash() {
99105
exceptionListsSettingStore.store("")
100106
verifyNoInteractions(mockVpnDatabase)
101107
}

0 commit comments

Comments
 (0)