ramanathan1504 commented on code in PR #4372:
URL: https://github.com/apache/logging-log4j2/pull/4372#discussion_r4329008949


##########
log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/OnStartupTriggeringPolicyTest.java:
##########
@@ -51,6 +52,15 @@ class OnStartupTriggeringPolicyTest {
     @TempDir
     Path tempDir;
 
+    @Test
+    void 
testFileCreatedAfterJvmStartIsNotOlderThanStartTimeAtSecondPrecision() {
+        final long startupTime = 1755031147175L;
+        final long fileCreationTime = 1755031147480L;
+        final long fileTime = 
RollingFileManager.alignMillisToSecond(fileCreationTime);
+        assertFalse(OnStartupTriggeringPolicy.isFileOlderThanStartup(fileTime, 
startupTime));
+        assertTrue(OnStartupTriggeringPolicy.isFileOlderThanStartup(fileTime - 
1000, startupTime));

Review Comment:
   After a rollover the file time is not rounded. This case covers a start time 
that rounds up past it.
   ```suggestion
           assertTrue(OnStartupTriggeringPolicy.isFileOlderThanStartup(fileTime 
- 1000, startupTime));
           
assertFalse(OnStartupTriggeringPolicy.isFileOlderThanStartup(1755031147900L, 
1755031147600L));
   ```



##########
log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/OnStartupTriggeringPolicy.java:
##########
@@ -77,7 +77,7 @@ private static long initStartTime() {
      */
     @Override
     public void initialize(final RollingFileManager manager) {
-        if (manager.getFileTime() < JVM_START_TIME && manager.getFileSize() >= 
minSize) {
+        if (isFileOlderThanStartup(manager.getFileTime(), JVM_START_TIME) && 
manager.getFileSize() >= minSize) {

Review Comment:
   No test fails if this line goes back to `manager.getFileTime() < 
JVM_START_TIME`. Can a test call `initialize` with a mocked 
`RollingFileManager` and a start time passed in? The closed #4398 has one.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to