Skip to content

Commit 816d098

Browse files
authored
Fix compiler complaining that tagged might have not been initialized (#381)
* Fix compiler complaining that tagged might have not been initialized * Fix CI/CD compiler issue * Refactor list to array
1 parent bedb9c7 commit 816d098

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/Akka.Persistence.MongoDb/Journal/MongoDbJournal.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -369,11 +369,17 @@ await MaybeWithTransaction(async (session, token) =>
369369

370370
private JournalEntry ToJournalEntry(IPersistentRepresentation message)
371371
{
372-
object payload = message.Payload;
372+
string[] tags;
373+
var payload = message.Payload;
373374
if (message.Payload is Tagged tagged)
374375
{
375376
payload = tagged.Payload;
376377
message = message.WithPayload(payload); // need to update the internal payload when working with tags
378+
tags = tagged.Tags.ToArray();
379+
}
380+
else
381+
{
382+
tags = Array.Empty<string>();
377383
}
378384

379385
// per https://github.com/akkadotnet/Akka.Persistence.MongoDB/issues/107
@@ -392,7 +398,7 @@ private JournalEntry ToJournalEntry(IPersistentRepresentation message)
392398
PersistenceId = message.PersistenceId,
393399
SequenceNr = message.SequenceNr,
394400
Manifest = manifest,
395-
Tags = tagged.Tags?.ToList(),
401+
Tags = tags,
396402
SerializerId = null // don't need a serializer ID here either; only for backwards-compat
397403
};
398404
}
@@ -411,7 +417,7 @@ private JournalEntry ToJournalEntry(IPersistentRepresentation message)
411417
PersistenceId = message.PersistenceId,
412418
SequenceNr = message.SequenceNr,
413419
Manifest = string.Empty, // don't need a manifest here - it's embedded inside the PersistentMessage
414-
Tags = tagged.Tags?.ToList(),
420+
Tags = tags,
415421
SerializerId = null // don't need a serializer ID here either; only for backwards-compat
416422
};
417423
}

0 commit comments

Comments
 (0)