# Notification grace period - bugfix

**URL:** <https://community.graylog.org/t/notification-grace-period-bugfix/15163>\
**Category:** Development\
**Created:** [April 27, 2020, 1:07pm UTC](https://community.graylog.org/t/notification-grace-period-bugfix/15163 "2020-04-27T13:07:34Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![sergei.melnichenko](https://avatars.discourse-cdn.com/v4/letter/s/9d8465/32.png) [@sergei.melnichenko](https://community.graylog.org/u/sergei.melnichenko)\
**Post date:** [April 27, 2020, 1:07pm UTC](https://community.graylog.org/t/notification-grace-period-bugfix/15163/1 "2020-04-27T13:07:34Z")

</div>

> <https://github.com/Graylog2/graylog2-server/blob/master/graylog2-server/src/main/java/org/graylog/events/notifications/NotificationGracePeriodService.java>

NotificationGracePeriodService.inGracePeriod() method does not update cache if lastEventTime.isPresent() is true, but the period is over.  
I would suggest the following change:

```
public boolean inGracePeriod(EventDefinition definition, String notificationId, Event event) {
    if (definition.notificationSettings().gracePeriodMs() <= 0) {
        return false;
    }
    final Optional<DateTime> lastEventTime = get(definition.id(), notificationId, event.toDto().key());
    final boolean isInGracePeriod = lastEventTime.isPresent() ?
            lastEventTime.get().isAfter(event.getEventTimestamp().minus(definition.notificationSettings().gracePeriodMs())) :
            false;
    put(definition.id(), notificationId, event.toDto().key(), event.getEventTimestamp());
    return isInGracePeriod;
}

```

Regards,

SM

---

<div class="post-metadata">

**Author:** ![jan](https://sea2.discourse-cdn.com/flex016/user_avatar/community.graylog.org/jan/32/11_2.png) [@jan](https://community.graylog.org/u/jan)\
**Post date:** [May 6, 2020, 2:13pm UTC](https://community.graylog.org/t/notification-grace-period-bugfix/15163/2 "2020-05-06T14:13:40Z")

</div>

do you mind opening a pull request over at github?

> **[Graylog2/graylog2-server](https://github.com/Graylog2/graylog2-server)**
>
> Free and open source log management. Contribute to Graylog2/graylog2-server development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![sergei.melnichenko](https://avatars.discourse-cdn.com/v4/letter/s/9d8465/32.png) [@sergei.melnichenko](https://community.graylog.org/u/sergei.melnichenko)\
**Post date:** [May 6, 2020, 2:55pm UTC](https://community.graylog.org/t/notification-grace-period-bugfix/15163/3 "2020-05-06T14:55:29Z")

</div>

feel free to do anything you like.  
i just solved my problem.

ср, 6 мая 2020 г., 17:23 Jan Doberstein via Graylog Community \<[graylog@discoursemail.com](mailto:graylog@discoursemail.com)\>:

---

<div class="post-metadata">

**Author:** ![mpfz0r](https://avatars.discourse-cdn.com/v4/letter/m/eb9ed0/32.png) [@mpfz0r](https://community.graylog.org/u/mpfz0r)\
**Post date:** [May 8, 2020, 9:29am UTC](https://community.graylog.org/t/notification-grace-period-bugfix/15163/4 "2020-05-08T09:29:13Z")

</div>

Thank you @sergei.melnichenko for the fix. 🙂  
You can track it’s progress here: [https://github.com/Graylog2/graylog2-server/pull/8067](https://github.com/Graylog2/graylog2-server/pull/8067)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/graylog/original/3X/c/7/c7c09c6b5099570133d6502b83f50ba4430de5b6.png) [@system](https://community.graylog.org/u/system)\
**Post date:** [May 22, 2020, 9:29am UTC](https://community.graylog.org/t/notification-grace-period-bugfix/15163/5 "2020-05-22T09:29:23Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
