Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use recoverWith instead of recover in SnapshotSerializer akka backwards compatibility #843

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading