Bug 981544 - PeriodicRotatingFileHandler does not roll the File on 12AM but 12PM
Summary: PeriodicRotatingFileHandler does not roll the File on 12AM but 12PM
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: JBoss Enterprise Application Platform 6
Classification: JBoss
Component: Logging
Version: 6.1.0
Hardware: Unspecified
OS: Unspecified
unspecified
high
Target Milestone: ER7
: EAP 6.1.1
Assignee: James Perkins
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks: 975555 987125 1067555
TreeView+ depends on / blocked
 
Reported: 2013-07-05 06:26 UTC by Takayoshi Kimura
Modified: 2018-12-03 19:16 UTC (History)
8 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
A bug was found in previous versions of Red Hat JBoss Enterprise Application Platform 6 that caused the LogManager to not rotate the log file the day after a restart. The bug presented if the server was restarted in the 'PM' hour range. It was caused by the LogManager not correctly handling half-day periods. This bug has been resolved with an update to the LogManager version.
Clone Of:
: 1067555 (view as bug list)
Environment:
Last Closed: 2013-09-16 20:24:41 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker LOGMGR-68 0 Major Resolved periodic-rotating-file-handler not rotating 2018-11-15 01:44:43 UTC

Comment 1 Takayoshi Kimura 2013-07-05 06:30:08 UTC
If the base time (boot time) is pm, the next rolling time will be set to 12pm because it doesn't clear AM_PM before setting 0 to HOUR.

Comment 2 Kyle Lape 2013-07-05 18:03:02 UTC
I actually asked James about this issue a couple of days ago.  I developed a patch similar to Takayoshi's:

index 406ff7d..28deb97 100644
--- a/src/main/java/org/jboss/logmanager/handlers/PeriodicRotatingFileHandler.java
+++ b/src/main/java/org/jboss/logmanager/handlers/PeriodicRotatingFileHandler.java
@@ -214,6 +214,7 @@ public class PeriodicRotatingFileHandler extends FileHandler {
                 calendar.clear(Calendar.DAY_OF_WEEK_IN_MONTH);
             case DAY:
                 calendar.set(Calendar.HOUR_OF_DAY, 0);
+                calendar.set(Calendar.AM_PM, 0);
             case HALF_DAY:
                 calendar.set(Calendar.HOUR, 0);
             case HOUR:

And James's response:

I started looking at this briefly, but didn't dig into it yet. I was trying to get a test case to break it, but I haven't yet. I'll have a look soon at that though. It could be as simple as that for sure. In fact, my gut is telling me that's exactly what it is.

Comment 3 JBoss JIRA Server 2013-07-05 22:41:06 UTC
Paul V <pvs.1.email> made a comment on jira LOGMGR-68

This will not fix the problem. The set methods of Calendar do not recalculate its time. My previous comment has a fix for this problem.

From the java doc for Calendar

Getting and Setting Calendar Field Values

The calendar field values can be set by calling the set methods. Any field values set in a Calendar will not be interpreted until it needs to calculate its time value (milliseconds from the Epoch) or values of the calendar fields. Calling the get, getTimeInMillis, getTime, add and roll involves such calculation.

Comment 4 JBoss JIRA Server 2013-07-06 04:14:43 UTC
Takayoshi Kimura <tkimura> made a comment on jira LOGMGR-68

Thanks Paul, you're right. HOUR should not be set other than the HALF_DAY case. Updated the pull req.

Also I'm wondering if we can change the calcNextRollover method to protected or package private for unit testing.

Comment 5 JBoss JIRA Server 2013-07-09 22:53:01 UTC
Kyle Lape <kyle.lape> made a comment on jira LOGMGR-68

I've talked with [~jamezp] about this case, and we worked through this issue.  He suggested a fix that included pieces from both proposed solutions.  I had also created some more tests and fixed another issue regarding the {{WEEK}} period.  I submitted a new PR: https://github.com/jboss-logging/jboss-logmanager/pull/32

Comment 6 JBoss JIRA Server 2013-07-10 14:28:40 UTC
Bertrand Donnet <bertrand.donnet> made a comment on jira LOGMGR-68

We also noticed this problem when migrating from JBoss EAP 6.0.1 to 6.1.0, which means LogManager from 1.3.2 to 1.4.0

Thanks for the feedback and we will wait for the fix.

Comment 8 JBoss JIRA Server 2013-07-22 16:49:56 UTC
James Perkins <jperkins> made a comment on jira LOGMGR-68

Pull request merged

Comment 9 Kyle Lape 2013-07-22 18:11:47 UTC
Setting the EAP 6.1.1 flag since this has already been committed for the logmanager release for 6.1.1.

Comment 10 Petr Kremensky 2013-08-26 13:42:41 UTC
This was fixed with new version of log manager (BZ975555). PeriodicRotatingFileHandler now roll the File on 12AM even if its base time (boot time) is pm. 

Verified with EAP 6.1.1 ER7

Comment 11 Scott Mumford 2013-08-30 05:24:41 UTC
Added a draft release note.

Setting NEEDINFO flag to request technical verification from assignee, however, at this late stage, a verification from anyone involved in the resolution of this issue will be sufficient.

If the note above is inaccurate, please reset the 'requires_doc_text' flag to '?' and leave comment with corrections.

Comment 12 James Perkins 2013-08-30 15:37:00 UTC
I think that doc text is fine. I didn't work on the problem, but from my understanding you've explained it well.


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