Merge pull request #9123 from Icinga/bugfix/icinga2-crashes-when-sending-notifications-8186

Avoid "type" key in dicts being part of object state attrs
This commit is contained in:
Julian Brost 2022-01-19 11:48:40 +01:00 committed by GitHub
commit 6390911262
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View File

@ -75,7 +75,7 @@ void Checkable::SendNotifications(NotificationType type, const CheckResult::Ptr&
<< "Notification '" << notification->GetName() << "': there are some stashed notifications. Stashing notification to preserve order.";
stashedNotifications->Add(new Dictionary({
{"type", type},
{"notification_type", type},
{"cr", cr},
{"force", force},
{"reminder", false},
@ -100,7 +100,7 @@ void Checkable::SendNotifications(NotificationType type, const CheckResult::Ptr&
<< "Notification '" << notification->GetName() << "': object authority hasn't been updated, yet. Stashing notification.";
notification->GetStashedNotifications()->Add(new Dictionary({
{"type", type},
{"notification_type", type},
{"cr", cr},
{"force", force},
{"reminder", false},

View File

@ -183,12 +183,15 @@ void NotificationComponent::NotificationTimerHandler()
ObjectLock olock(unstashedNotifications);
for (Dictionary::Ptr unstashedNotification : unstashedNotifications) {
if (!unstashedNotification)
continue;
try {
Log(LogNotice, "NotificationComponent")
<< "Attempting to send stashed notification '" << notificationName << "'.";
notification->BeginExecuteNotification(
(NotificationType)(int)unstashedNotification->Get("type"),
(NotificationType)(int)unstashedNotification->Get("notification_type"),
(CheckResult::Ptr)unstashedNotification->Get("cr"),
(bool)unstashedNotification->Get("force"),
(bool)unstashedNotification->Get("reminder"),