Uploaded image for project: 'logback'
  1. logback
  2. LOGBACK-1344

RollingCalendar invalid "period barrier crossed" computation

    Details

      Description

      In RollingCalendar method periodBarriersCrossed, when periods are computed for TOP_OF_HOUR periodicity, unnecessary (and invalid) type cast is performed:

      case TOP_OF_HOUR:
       return (int) diff / MILLIS_IN_ONE_HOUR;

      in case diff > MAX_INT, return from method is wrong.

      example: 

      <fileNamePattern>logs/%d{yyyy/MM/dd,aux}/eps_%d{yyyyMMdd-HH}h.%i.log.zip</fileNamePattern>
       <cleanHistoryOnStart>true</cleanHistoryOnStart>

       

      After i start application, method TimeBasedArchiverRemover.clean(Date now) is in some point called. Then, computation of period elapsed since last clean is called with parameters:

      periodsElapsed = this.rc.periodBarriersCrossed(nowInMillis, nowInMillis + 2764800000L)

      where nowInMillis = 1507034734848 (date = Tue Oct 03 14:45:34 CEST 2017)

      In method, diff is computed (diff = 2761200000). This value > MAX_INT, so expression 

       

      return (int) diff / MILLIS_IN_ONE_HOUR =  -426

      so no clean up is performed

        Attachments

          Activity

            People

            • Assignee:
              logback-dev Logback dev list
              Reporter:
              jerzy.burzek Boris Brinza
            • Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: