Skip to content

Commit

Permalink
Fix SaveSnapshot timestamp metadata (#7334)
Browse files Browse the repository at this point in the history
  • Loading branch information
Arkatufus committed Sep 4, 2024
1 parent e8beec4 commit cb11702
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/core/Akka.Persistence/Snapshot/SnapshotStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,15 @@ private bool ReceiveSnapshotStore(object message)
}
else if (message is SaveSnapshot saveSnapshot)
{
var metadata = new SnapshotMetadata(saveSnapshot.Metadata.PersistenceId, saveSnapshot.Metadata.SequenceNr, DateTime.UtcNow);
var metadata = new SnapshotMetadata(saveSnapshot.Metadata.PersistenceId, saveSnapshot.Metadata.SequenceNr, saveSnapshot.Metadata.Timestamp == DateTime.MinValue ? DateTime.UtcNow : saveSnapshot.Metadata.Timestamp);

_breaker.WithCircuitBreaker(() => SaveAsync(metadata, saveSnapshot.Snapshot))
.ContinueWith(t => (!t.IsFaulted && !t.IsCanceled)
? new SaveSnapshotSuccess(metadata) as ISnapshotResponse
: new SaveSnapshotFailure(saveSnapshot.Metadata,
t.IsFaulted
? TryUnwrapException(t.Exception)
: new OperationCanceledException("SaveAsync canceled, possibly due to timing out.")),
: new OperationCanceledException("SaveAsync canceled, possibly due to timing out.", TryUnwrapException(t.Exception))),
_continuationOptions)
.PipeTo(self, senderPersistentActor);
}
Expand Down Expand Up @@ -196,8 +196,7 @@ private bool ReceiveSnapshotStore(object message)

private Exception TryUnwrapException(Exception e)
{
var aggregateException = e as AggregateException;
if (aggregateException != null)
if (e is AggregateException aggregateException)
{
aggregateException = aggregateException.Flatten();
if (aggregateException.InnerExceptions.Count == 1)
Expand Down

0 comments on commit cb11702

Please sign in to comment.