mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-27 12:05:22 +00:00
Don't crash on unexpected deserialization error
This commit is contained in:
parent
bb850cf99e
commit
c5e0589751
@ -22,6 +22,6 @@ interface Job {
|
|||||||
|
|
||||||
interface Factory<T : Job> {
|
interface Factory<T : Job> {
|
||||||
|
|
||||||
fun create(data: Data): T
|
fun create(data: Data): T?
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -104,17 +104,29 @@ class MessageSendJob(val message: Message, val destination: Destination) : Job {
|
|||||||
|
|
||||||
class Factory : Job.Factory<MessageSendJob> {
|
class Factory : Job.Factory<MessageSendJob> {
|
||||||
|
|
||||||
override fun create(data: Data): MessageSendJob {
|
override fun create(data: Data): MessageSendJob? {
|
||||||
val serializedMessage = data.getByteArray(MESSAGE_KEY)
|
val serializedMessage = data.getByteArray(MESSAGE_KEY)
|
||||||
val serializedDestination = data.getByteArray(DESTINATION_KEY)
|
val serializedDestination = data.getByteArray(DESTINATION_KEY)
|
||||||
val kryo = Kryo()
|
val kryo = Kryo()
|
||||||
// Message
|
// Message
|
||||||
val messageInput = Input(serializedMessage)
|
val messageInput = Input(serializedMessage)
|
||||||
val message = kryo.readClassAndObject(messageInput) as Message
|
val message: Message
|
||||||
|
try {
|
||||||
|
message = kryo.readClassAndObject(messageInput) as Message
|
||||||
|
} catch (e: Exception) {
|
||||||
|
Log.e("Loki", "Couldn't deserialize message send job.", e)
|
||||||
|
return null
|
||||||
|
}
|
||||||
messageInput.close()
|
messageInput.close()
|
||||||
// Destination
|
// Destination
|
||||||
val destinationInput = Input(serializedDestination)
|
val destinationInput = Input(serializedDestination)
|
||||||
val destination = kryo.readClassAndObject(destinationInput) as Destination
|
val destination: Destination
|
||||||
|
try {
|
||||||
|
destination = kryo.readClassAndObject(destinationInput) as Destination
|
||||||
|
} catch (e: Exception) {
|
||||||
|
Log.e("Loki", "Couldn't deserialize message send job.", e)
|
||||||
|
return null
|
||||||
|
}
|
||||||
destinationInput.close()
|
destinationInput.close()
|
||||||
// Return
|
// Return
|
||||||
return MessageSendJob(message, destination)
|
return MessageSendJob(message, destination)
|
||||||
|
Loading…
Reference in New Issue
Block a user