[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:
{code:java}
case TOP_OF_HOUR:
 return (long)((int)diff) / 3600000L;{code}
in case diff > MAX_INT, return from method is wrong.

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

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:
{code:java}
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 

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



--
This message was sent by Atlassian JIRA
(v7.3.1#73012)


More information about the logback-dev mailing list