Skip to content

Commit 7f81b51

Browse files
jaykataria1111Jay Katariyappkarwasz
authored
Feat(SystemClock): Added PreciseClock implementation to the system clock class, for the benefit of Java 8 users. (#3217)
Added PreciseClock implementation to the system clock class, for the benefit of Java 8 users. Co-authored-by: Jay Katariya <[email protected]> Co-authored-by: Piotr P. Karwasz <[email protected]>
1 parent e71820a commit 7f81b51

File tree

11 files changed

+40
-358
lines changed

11 files changed

+40
-358
lines changed

log4j-core-java9/src/assembly/java9.xml

-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
<include>org/apache/logging/log4j/core/jackson/Log4jStackTraceElementDeserializer.class</include>
3232
<include>org/apache/logging/log4j/core/jackson/StackTraceElementMixIn.class</include>
3333
<include>org/apache/logging/log4j/core/util/internal/UnsafeUtil*.class</include>
34-
<include>org/apache/logging/log4j/core/util/SystemClock.class</include>
3534
</includes>
3635
</fileSet>
3736
</fileSets>

log4j-core-java9/src/main/java/org/apache/logging/log4j/core/time/Instant.java

-77
This file was deleted.

log4j-core-java9/src/main/java/org/apache/logging/log4j/core/time/MutableInstant.java

-157
This file was deleted.

log4j-core-java9/src/main/java/org/apache/logging/log4j/core/time/PreciseClock.java

-38
This file was deleted.

log4j-core-java9/src/main/java/org/apache/logging/log4j/core/util/Clock.java

-32
This file was deleted.

log4j-core-java9/src/main/java/org/apache/logging/log4j/core/util/SystemClock.java

-46
This file was deleted.

log4j-core/src/main/java/org/apache/logging/log4j/core/util/SystemClock.java

+11-1
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,14 @@
1616
*/
1717
package org.apache.logging.log4j.core.util;
1818

19+
import java.time.Instant;
20+
import org.apache.logging.log4j.core.time.MutableInstant;
21+
import org.apache.logging.log4j.core.time.PreciseClock;
22+
1923
/**
2024
* Implementation of the {@code Clock} interface that returns the system time.
2125
*/
22-
public final class SystemClock implements Clock {
26+
public final class SystemClock implements Clock, PreciseClock {
2327

2428
/**
2529
* Returns the system time.
@@ -29,4 +33,10 @@ public final class SystemClock implements Clock {
2933
public long currentTimeMillis() {
3034
return System.currentTimeMillis();
3135
}
36+
37+
@Override
38+
public void init(final MutableInstant mutableInstant) {
39+
final Instant instant = java.time.Clock.systemUTC().instant();
40+
mutableInstant.initFromEpochSecond(instant.getEpochSecond(), instant.getNano());
41+
}
3242
}

log4j-core/src/main/java/org/apache/logging/log4j/core/util/package-info.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
* Log4j 2 helper classes.
1919
*/
2020
@Export
21-
@Version("2.24.2")
21+
@Version("2.25.0")
2222
package org.apache.logging.log4j.core.util;
2323

2424
import org.osgi.annotation.bundle.Export;

0 commit comments

Comments
 (0)