Skip to content

Commit d5e5b81

Browse files
author
Taichi Yamakawa
committed
SnapshotStore can reply with SnapshotNotFound if it is saving an EntitySnapshot
1 parent c4b5747 commit d5e5b81

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/main/scala/lerna/akka/entityreplication/raft/snapshot/SnapshotStore.scala

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,11 @@ private[entityreplication] class SnapshotStore(
9696
cmd.entityId,
9797
)
9898
case FetchSnapshot(_, replyTo) =>
99-
prevSnapshot.foreach { s =>
100-
replyTo ! SnapshotProtocol.SnapshotFound(s)
99+
prevSnapshot match {
100+
case Some(prevSnapshot) =>
101+
replyTo ! SnapshotProtocol.SnapshotFound(prevSnapshot)
102+
case None =>
103+
replyTo ! SnapshotProtocol.SnapshotNotFound(entityId)
101104
}
102105
}
103106
case _: persistence.SaveSnapshotSuccess =>

src/test/scala/lerna/akka/entityreplication/raft/snapshot/ShardSnapshotStoreFailureSpec.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ class ShardSnapshotStoreFailureSpec
109109
}
110110

111111
"reply with `SnapshotNotFound` to `FetchSnapshot` if it has no EntitySnapshot and is saving an EntitySnapshot" in {
112-
// TODO Change SnapshotStore.savingSnapshot such that this test passes.
113112
val entityId = generateUniqueEntityId()
114113
val shardSnapshotStore = createShardSnapshotStore()
115114
val metadata = EntitySnapshotMetadata(entityId, LogEntryIndex(1))
@@ -123,7 +122,7 @@ class ShardSnapshotStoreFailureSpec
123122

124123
// Test:
125124
shardSnapshotStore ! FetchSnapshot(entityId, replyTo = testActor)
126-
expectMsg(SnapshotNotFound)
125+
expectMsg(SnapshotNotFound(entityId))
127126
} finally {
128127
// Cleanup:
129128
// The succeeding tests will fail unless the promise is fulfilled.

0 commit comments

Comments
 (0)