Skip to content
This repository has been archived by the owner on Apr 24, 2022. It is now read-only.

Commit

Permalink
Merge pull request #68 from boswelja/fix-serialization-receiver-crash
Browse files Browse the repository at this point in the history
fix: Only pass on deserialized message if the path matches the serializer
  • Loading branch information
boswelja authored Nov 17, 2021
2 parents 3cb069f + 783d001 commit db4c797
Showing 1 changed file with 17 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,24 @@ public abstract class MessageReceiver<T>(
// Get message details
val message = MessageReceiverUtils.getReceivedMessageFromIntent(intent)

val pendingResult = goAsync()
coroutineScope.launch {
// Deserialize and pass message on
val deserializedData = serializer.deserialize(message.data)
try {
onMessageReceived(
context,
ReceivedMessage(
message.sourceUid,
message.path,
deserializedData
if (serializer.messagePaths.contains(message.path)) {
val pendingResult = goAsync()
coroutineScope.launch {
// Deserialize and pass message on
val deserializedData = serializer.deserialize(message.data)
try {
onMessageReceived(
context,
ReceivedMessage(
message.sourceUid,
message.path,
deserializedData
)
)
)
} finally {
pendingResult.finish()
coroutineScope.cancel()
} finally {
pendingResult.finish()
coroutineScope.cancel()
}
}
}
}
Expand Down

0 comments on commit db4c797

Please sign in to comment.