This is an automated email from the ASF dual-hosted git repository.
fanningpj pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-pekko.git
The following commit(s) were added to refs/heads/main by this push:
new 7332626430 Use recoverWith instead of recover in SnapshotSerializer
akka backwards compatibility (#841) (#843)
7332626430 is described below
commit 7332626430904432bb71484727dd28af9d832454
Author: PJ Fanning <[email protected]>
AuthorDate: Tue Dec 12 11:34:18 2023 +0100
Use recoverWith instead of recover in SnapshotSerializer akka backwards
compatibility (#841) (#843)
Co-authored-by: Ćukasz Krenski <[email protected]>
---
.../pekko/persistence/serialization/SnapshotSerializer.scala | 2 +-
.../pekko/persistence/serialization/SnapshotSerializerSpec.scala | 7 ++-----
2 files changed, 3 insertions(+), 6 deletions(-)
diff --git
a/persistence/src/main/scala/org/apache/pekko/persistence/serialization/SnapshotSerializer.scala
b/persistence/src/main/scala/org/apache/pekko/persistence/serialization/SnapshotSerializer.scala
index e8e1c11927..d9926f2a35 100644
---
a/persistence/src/main/scala/org/apache/pekko/persistence/serialization/SnapshotSerializer.scala
+++
b/persistence/src/main/scala/org/apache/pekko/persistence/serialization/SnapshotSerializer.scala
@@ -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"))
diff --git
a/persistence/src/test/scala/org/apache/pekko/persistence/serialization/SnapshotSerializerSpec.scala
b/persistence/src/test/scala/org/apache/pekko/persistence/serialization/SnapshotSerializerSpec.scala
index 824ff9c51f..bcadc2e8bd 100644
---
a/persistence/src/test/scala/org/apache/pekko/persistence/serialization/SnapshotSerializerSpec.scala
+++
b/persistence/src/test/scala/org/apache/pekko/persistence/serialization/SnapshotSerializerSpec.scala
@@ -24,7 +24,6 @@ import pekko.serialization.SerializationExtension
import pekko.testkit.PekkoSpec
import java.util.Base64
-import scala.util.Success
class SnapshotSerializerSpec extends PekkoSpec {
@@ -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)
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]