Skip to content

Commit 7332626

Browse files
pjfanningSakulK
andauthored
Use recoverWith instead of recover in SnapshotSerializer akka backwards compatibility (#841) (#843)
Co-authored-by: Łukasz Krenski <[email protected]>
1 parent d8943ce commit 7332626

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

persistence/src/main/scala/org/apache/pekko/persistence/serialization/SnapshotSerializer.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ class SnapshotSerializer(val system: ExtendedActorSystem) extends BaseSerializer
115115
// suggested in https://github.com/scullxbones/pekko-persistence-mongo/pull/14#issuecomment-1847223850
116116
serialization
117117
.deserialize(snapshotBytes, serializerId, manifest)
118-
.recover {
118+
.recoverWith {
119119
case _: NotSerializableException if manifest.startsWith("akka") =>
120120
serialization
121121
.deserialize(snapshotBytes, serializerId, manifest.replaceFirst("akka", "org.apache.pekko"))

persistence/src/test/scala/org/apache/pekko/persistence/serialization/SnapshotSerializerSpec.scala

+2-5
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import pekko.serialization.SerializationExtension
2424
import pekko.testkit.PekkoSpec
2525

2626
import java.util.Base64
27-
import scala.util.Success
2827

2928
class SnapshotSerializerSpec extends PekkoSpec {
3029

@@ -38,10 +37,8 @@ class SnapshotSerializerSpec extends PekkoSpec {
3837
val bytes = Base64.getDecoder.decode(data)
3938
val result = serialization.deserialize(bytes, classOf[Snapshot]).get
4039
val deserialized = result.data
41-
deserialized shouldBe a[Success[_]]
42-
val innerResult = deserialized.asInstanceOf[Success[_]].get
43-
innerResult shouldBe a[PersistentFSMSnapshot[_]]
44-
val persistentFSMSnapshot = innerResult.asInstanceOf[PersistentFSMSnapshot[_]]
40+
deserialized shouldBe a[PersistentFSMSnapshot[_]]
41+
val persistentFSMSnapshot = deserialized.asInstanceOf[PersistentFSMSnapshot[_]]
4542
persistentFSMSnapshot shouldEqual PersistentFSMSnapshot[String]("test-identifier", "test-data", None)
4643
}
4744
}

0 commit comments

Comments
 (0)