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
This commit is contained in:
Gregorius Soedharmo 2024-08-06 19:50:55 +07:00 коммит произвёл GitHub
Родитель bedb9c7395
Коммит 816d098f1e
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
1 изменённых файлов: 9 добавлений и 3 удалений

Просмотреть файл

@ -369,11 +369,17 @@ namespace Akka.Persistence.MongoDb.Journal
private JournalEntry ToJournalEntry(IPersistentRepresentation message)
{
object payload = message.Payload;
string[] tags;
var payload = message.Payload;
if (message.Payload is Tagged tagged)
{
payload = tagged.Payload;
message = message.WithPayload(payload); // need to update the internal payload when working with tags
tags = tagged.Tags.ToArray();
}
else
{
tags = Array.Empty<string>();
}
// per https://github.com/akkadotnet/Akka.Persistence.MongoDB/issues/107
@ -392,7 +398,7 @@ namespace Akka.Persistence.MongoDb.Journal
PersistenceId = message.PersistenceId,
SequenceNr = message.SequenceNr,
Manifest = manifest,
Tags = tagged.Tags?.ToList(),
Tags = tags,
SerializerId = null // don't need a serializer ID here either; only for backwards-compat
};
}
@ -411,7 +417,7 @@ namespace Akka.Persistence.MongoDb.Journal
PersistenceId = message.PersistenceId,
SequenceNr = message.SequenceNr,
Manifest = string.Empty, // don't need a manifest here - it's embedded inside the PersistentMessage
Tags = tagged.Tags?.ToList(),
Tags = tags,
SerializerId = null // don't need a serializer ID here either; only for backwards-compat
};
}