mirror of
https://github.com/f-droid/fdroidclient.git
synced 2026-04-20 06:47:06 -04:00
[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
This commit is contained in:
committed by
Hans-Christoph Steiner
parent
bbb65e7841
commit
f6caceb63c
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user