Skip to content

Commit

Permalink
Use recoverWith instead of recover in SnapshotSerializer akka backwar…
Browse files Browse the repository at this point in the history
…ds compatibility
  • Loading branch information
SakulK committed Dec 11, 2023
1 parent 15aee50 commit 75c09a4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class SnapshotSerializer(val system: ExtendedActorSystem) extends BaseSerializer
// suggested in https://github.com/scullxbones/pekko-persistence-mongo/pull/14#issuecomment-1847223850
serialization
.deserialize(snapshotBytes, serializerId, manifest)
.recover {
.recoverWith {
case _: NotSerializableException if manifest.startsWith("akka") =>
serialization
.deserialize(snapshotBytes, serializerId, manifest.replaceFirst("akka", "org.apache.pekko"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import pekko.serialization.SerializationExtension
import pekko.testkit.PekkoSpec

import java.util.Base64
import scala.util.Success

class SnapshotSerializerSpec extends PekkoSpec {

Expand All @@ -38,10 +37,8 @@ class SnapshotSerializerSpec extends PekkoSpec {
val bytes = Base64.getDecoder.decode(data)
val result = serialization.deserialize(bytes, classOf[Snapshot]).get
val deserialized = result.data
deserialized shouldBe a[Success[_]]
val innerResult = deserialized.asInstanceOf[Success[_]].get
innerResult shouldBe a[PersistentFSMSnapshot[_]]
val persistentFSMSnapshot = innerResult.asInstanceOf[PersistentFSMSnapshot[_]]
deserialized shouldBe a[PersistentFSMSnapshot[_]]
val persistentFSMSnapshot = deserialized.asInstanceOf[PersistentFSMSnapshot[_]]
persistentFSMSnapshot shouldEqual PersistentFSMSnapshot[String]("test-identifier", "test-data", None)
}
}
Expand Down

0 comments on commit 75c09a4

Please sign in to comment.