• Fix Priority:



      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); }


      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.




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


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


                Version Package
                6.2.0 CE GA1