Bug 45636

Summary: 2 tests for DateLayout are failing because of ill initialized DateFormat
Product: Log4j - Now in Jira Reporter: Philippe Haution <philippe.haution>
Component: OtherAssignee: log4j-dev <log4j-dev>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P2    
Version: 1.2   
Target Milestone: ---   
Hardware: All   
OS: Linux   

Description Philippe Haution 2008-08-15 08:37:35 UTC
Inside org.apache.log4j.helpers.DateLayoutTest, testISO8601Format() and testDateTimeFormat() necessarily result in failures when run through an mvn test in the root directory.

Indeed the ISO8601DateFormat and DateTimeFormat object responsible for this issue have a memory of the previous date they formatted (kept as a long representing the specified number of milliseconds since the standard base time known as "the epoch", namely January 1, 1970, 00:00:00 GMT) and the resulting String.

If they are asked again to format the same time, then they just return the corresponding String without having to do the formatting again.

But both test cases require to format a date precisely corresponding to 01 Jan 1970 00:00, that is to say 0 ms since "the epoch", which is their initial state.

The problem is the corresponding String is not properly initialized by their constructor so they return a value of "000" and "01 Jan 1970 000" instead of "1970-01-01 00:00:00,000" and "01 Jan 1970 00:00:00,000".
Comment 1 Curt Arnold 2008-08-15 16:11:55 UTC
Committed fix in rev 686415 that checks if the "cached" value has been initialized.

I believe the test failures would only show up if your default TimeZone is GMT.