Details

    • Fix Priority:
      3

      Description

      Hi!

      I face some issues with Calendar portlet: it can send one of two configured reminders; or sometimes it sends double notification for a single reminder..

      I looked through the sources and found the algorithm of sending to be quite strange.

      protected void remindUser(
      CalEvent event, User user, Calendar startCalendar,
      Calendar nowCalendar) {

      Date startDate = startCalendar.getTime();

      long startTime = startDate.getTime();

      Date nowDate = nowCalendar.getTime();

      long nowTime = nowDate.getTime();

      if (startTime < nowTime)

      { return; }

      long diff = (startTime - nowTime) / _CALENDAR_EVENT_CHECK_INTERVAL;

      if ((diff ==
      (event.getFirstReminder() / _CALENDAR_EVENT_CHECK_INTERVAL)) ||
      (diff ==
      (event.getSecondReminder() / _CALENDAR_EVENT_CHECK_INTERVAL)))

      { remindUser(event, user, startCalendar); }

      }

      https://github.com/liferay/liferay-portal/blob/62941e6773b54d697961006c07f5070991e1c631/portal-impl/src/com/liferay/portlet/calendar/service/impl/CalEventLocalServiceImpl.java#L1312

      It seems to do its job in most of cases, but the code looks over-engineered.

      What is more important, it can send double reminders, e.g.:

      • scheduler runs every 5 minutes: 9:55, 10:00, 10:05,..
      • I've configured the calendar to send a single reminder 5 minutes before the event that starts at 10:00

      nowTime is not exact time (in ms). It might be a bit greater or less than it is expected, thus e.g. at 9.55 (startTime - nowTime) might be either 300000 or 299999 and 'diff' might be either 1 or 0. The next time when scheduler runs (10:00) it may happen that diff will become 0, once again. As a result - double reminders. We may lose notifications, as well, for the same reason.

      For the moment I don't know exactly if this is the reason for my issue, but I deem the code of this method should be somehow rewritten to be more robust and easier to understand.

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Days since last comment:
                3 years, 7 weeks ago

                Packages

                Version Package
                6.2.0 CE GA1