Bug 1171020 - Wrong backup file names by PeriodicRotatingFileHandler when suffix "yyyy-ww"
Summary: Wrong backup file names by PeriodicRotatingFileHandler when suffix "yyyy-ww"
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: JBoss Enterprise Application Platform 6
Classification: JBoss
Component: Logging
Version: 6.2.4
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
: ---
Assignee: James Perkins
QA Contact: Nikoleta Hlavickova
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-12-05 09:36 UTC by Osamu Nagano
Modified: 2018-12-09 19:18 UTC (History)
4 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2015-01-13 21:09:46 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker LOGMGR-119 0 Major Closed Wrong backup file names by PeriodicRotatingFileHandler when suffix "yyyy-ww" 2014-12-16 17:24:50 UTC

Description Osamu Nagano 2014-12-05 09:36:03 UTC
Description of problem:
When PeriodicRotatingFileHandler with suffix "yyyy-ww" rotates a log file over a year, file that belongs to the new year is incorrectly named using the previous year.


Version-Release number of selected component (if applicable):
JBoss LogManager 1.5.2.Final


How reproducible:
Always.


Steps to Reproduce:
1. Copy and paste the following code into src/test/java/org/jboss/logmanager/handlers/PeriodicSizeRotatingFileHandlerTests.java.
~~~
    @Test
    public void testPeriodicRotateWeekOfYear() throws Exception {
        SimpleDateFormat fmt = periodFormatMap.get(Calendar.WEEK_OF_YEAR);
        Calendar cal = Calendar.getInstance(java.util.TimeZone.getTimeZone("GMT"));
        
        PeriodicRotatingFileHandler handler = new PeriodicRotatingFileHandler();
        handler.setAutoFlush(true);
        handler.setFormatter(new PatternFormatter("%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"));
        handler.setSuffix("." + fmt.toPattern());
        handler.setFile(logFile);
        
        cal.set(Calendar.YEAR, 2014);
        cal.set(Calendar.MONTH, 12 - 1);
        cal.set(Calendar.DAY_OF_MONTH, 24);
        cal.set(Calendar.HOUR_OF_DAY, 12);
        
        for (int i = 0; i < 14; i++) {
                long tim = cal.getTimeInMillis();
                String fdate = fmt.format(tim);
                ExtLogRecord record = createLogRecord("%02d th formatted date is %s", i, fdate);
                record.setMillis(tim);
            handler.publish(record);
            
                cal.add(Calendar.DAY_OF_MONTH, 1);
        }
        
        handler.close();
        
        for (String logFile : BASE_LOG_DIR.list()) {
                System.out.println(logFile);
        }

        Assert.assertTrue("Succeed.", true);
    }
~~~

2. Run the above test code by the following command
mvn compile test -Dtest=PeriodicSizeRotatingFileHandlerTests#testPeriodicRotateWeekOfYear

(You may need "-Dmaven.surefire.debug" as well to stop the test because the resulting files under target/logs will be deleted after every test.)


Actual results:
~~~
% ll logs                                                                                  
total 12K
-rw-r--r--. 1 onagano onagano 228 Dec  5 17:09 rotating-file-handler.log
-rw-r--r--. 1 onagano onagano 532 Dec  5 17:09 rotating-file-handler.log.2014-01
-rw-r--r--. 1 onagano onagano   0 Dec  5 17:09 rotating-file-handler.log.2014-49
-rw-r--r--. 1 onagano onagano 304 Dec  5 17:09 rotating-file-handler.log.2014-52
% cat logs/rotating-file-handler.log.2014-52                                               
2014-12-24 21:09:43,921 INFO  [null] (main) 00 th formatted date is 2014-52
2014-12-25 21:09:43,921 INFO  [null] (main) 01 th formatted date is 2014-52
2014-12-26 21:09:43,921 INFO  [null] (main) 02 th formatted date is 2014-52
2014-12-27 21:09:43,921 INFO  [null] (main) 03 th formatted date is 2014-52
% cat logs/rotating-file-handler.log.2014-01                                               
2014-12-28 21:09:43,921 INFO  [null] (main) 04 th formatted date is 2014-01
2014-12-29 21:09:43,921 INFO  [null] (main) 05 th formatted date is 2014-01
2014-12-30 21:09:43,921 INFO  [null] (main) 06 th formatted date is 2014-01
2014-12-31 21:09:43,921 INFO  [null] (main) 07 th formatted date is 2014-01
2015-01-01 21:09:43,921 INFO  [null] (main) 08 th formatted date is 2015-01
2015-01-02 21:09:43,921 INFO  [null] (main) 09 th formatted date is 2015-01
2015-01-03 21:09:43,921 INFO  [null] (main) 10 th formatted date is 2015-01
% cat logs/rotating-file-handler.log                                                       
2015-01-04 21:09:43,921 INFO  [null] (main) 11 th formatted date is 2015-02
2015-01-05 21:09:43,921 INFO  [null] (main) 12 th formatted date is 2015-02
2015-01-06 21:09:43,921 INFO  [null] (main) 13 th formatted date is 2015-02
~~~


Expected results:
File name "rotating-file-handler.log.2014-01" should be "*.2015-01".
Zero-sized "rotating-file-handler.log.2014-49" and lacking #50 and #51 are also strange.

Comment 5 JBoss JIRA Server 2014-12-16 17:24:50 UTC
James Perkins <jperkins> updated the status of jira LOGMGR-119 to Closed


Note You need to log in before you can comment on or make changes to this bug.