Skip to content

Commit

Permalink
Don't use Akka deserialization when using LegacySerialization is on. (#…
Browse files Browse the repository at this point in the history
…135)

Co-authored-by: Jack Wild <jackyoulend@outlook.com>
  • Loading branch information
jackowild and Jack Wild authored May 12, 2020
1 parent 86cf35f commit 3bd8c63
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/Akka.Persistence.MongoDb/Journal/MongoDbJournal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,19 @@ private JournalEntry ToJournalEntry(IPersistentRepresentation message)

private Persistent ToPersistenceRepresentation(JournalEntry entry, IActorRef sender)
{
if (_settings.LegacySerialization)
{
var manifest = string.IsNullOrEmpty(entry.Manifest) ? entry.Payload.GetType().TypeQualifiedName() : entry.Manifest;

return new Persistent(
entry.Payload,
entry.SequenceNr,
entry.PersistenceId,
manifest,
entry.IsDeleted,
sender);
}

var legacy = entry.SerializerId.HasValue || !string.IsNullOrEmpty(entry.Manifest);
if (!legacy)
{
Expand Down
10 changes: 10 additions & 0 deletions src/Akka.Persistence.MongoDb/Snapshot/MongoDbSnapshotStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,16 @@ private SnapshotEntry ToSnapshotEntry(SnapshotMetadata metadata, object snapshot

private SelectedSnapshot ToSelectedSnapshot(SnapshotEntry entry)
{
if (_settings.LegacySerialization)
{
return new SelectedSnapshot(
new SnapshotMetadata(
entry.PersistenceId,
entry.SequenceNr,
new DateTime(entry.Timestamp)),
entry.Snapshot);
}

var legacy = entry.SerializerId.HasValue || !string.IsNullOrEmpty(entry.Manifest);

if (!legacy)
Expand Down

0 comments on commit 3bd8c63

Please sign in to comment.