From f6caceb63c82ccfd0ec6e6bdabc2b3325b95ecbe Mon Sep 17 00:00:00 2001 From: Torsten Grote Date: Tue, 5 Mar 2024 15:05:19 -0300 Subject: [PATCH] [index] treat empty string like null when deserializing FileV2 objects we've seen serialized FileV2 objects becoming an empty string after parcelizing them, so we need to account for null *and* empty string here. Fixes acra-crash-reports#617 --- .../kotlin/org/fdroid/index/v2/IndexV2.kt | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/libs/index/src/commonMain/kotlin/org/fdroid/index/v2/IndexV2.kt b/libs/index/src/commonMain/kotlin/org/fdroid/index/v2/IndexV2.kt index d9acb48d3..e925cc7bc 100644 --- a/libs/index/src/commonMain/kotlin/org/fdroid/index/v2/IndexV2.kt +++ b/libs/index/src/commonMain/kotlin/org/fdroid/index/v2/IndexV2.kt @@ -2,7 +2,6 @@ package org.fdroid.index.v2 import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable -import kotlinx.serialization.SerializationException import kotlinx.serialization.decodeFromString import kotlinx.serialization.encodeToString import org.fdroid.IndexFile @@ -56,14 +55,10 @@ public data class FileV2( public companion object { @JvmStatic public fun deserialize(string: String?): FileV2? { - if (string == null) return null - return try { - json.decodeFromString(string) - } catch (e: SerializationException) { - // TODO remove temporary hack to debug mystery JsonDecodingException - // from unparceled strings in Android once resolved - throw IllegalArgumentException("|$string|", e) - } + // we've seen serialized FileV2 objects becoming an empty string after parcelizing them, + // so we need to account for null *and* empty string here. + if (string.isNullOrEmpty()) return null + return json.decodeFromString(string) } @JvmStatic