[logback-dev] [JIRA] (LOGBACK-1344) RollingCalendar invalid period barrier closed computation

QOS.CH (JIRA) noreply-jira at qos.ch
Tue Oct 3 14:54:00 CEST 2017

Boris Brinza created LOGBACK-1344:

             Summary: RollingCalendar invalid period barrier closed computation
                 Key: LOGBACK-1344
                 URL: https://jira.qos.ch/browse/LOGBACK-1344
             Project: logback
          Issue Type: Bug
          Components: logback-core
    Affects Versions: 1.2.3
            Reporter: Boris Brinza
            Assignee: Logback dev list

In RollingCalendar method periodBarriersCrossed, when periods are computed for TOP_OF_HOUR periodicity, unnecessary (and invalid) type cast is performed:
 return (long)((int)diff) / 3600000L;{code}
in case diff > MAX_INT, return from method is wrong.


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){code}
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 

(long)((int)diff) / 3600000L =  -426{code}
so no clean up is performed

This message was sent by Atlassian JIRA

More information about the logback-dev mailing list