You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by ra...@apache.org on 2026/10/18 14:44:35 UTC
(logging-log4j2) branch 2.x updated: Fix intermittent failsures in CronExpressionTest (#4405)
This is an automated email from the ASF dual-hosted git repository.
ramanathan1504 pushed a commit to branch 2.x
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git
The following commit(s) were added to refs/heads/2.x by this push:
new fcaa90b5bc Fix intermittent failsures in CronExpressionTest (#4405)
fcaa90b5bc is described below
commit fcaa90b5bc40c49edd1854c604787521f52bd9cf
Author: Ralph Goers <rg...@apache.org>
AuthorDate: Sun Oct 18 07:44:29 2026 -0700
Fix intermittent failsures in CronExpressionTest (#4405)
---
.../apache/logging/log4j/core/util/CronExpressionTest.java | 6 ++++++
.../org/apache/logging/log4j/core/util/CronExpression.java | 3 ++-
src/changelog/.2.x.x/fix_cron_expression_min_date.xml | 11 +++++++++++
3 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/util/CronExpressionTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/util/CronExpressionTest.java
index 38c4c419ac..23528e7ce5 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/util/CronExpressionTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/util/CronExpressionTest.java
@@ -183,6 +183,12 @@ class CronExpressionTest {
assertEquals(expected, fireDate, "Dates not equal.");
}
+ @Test
+ void testMinDateIsEpoch() {
+ assertThat(CronExpression.MIN_DATE.getTime()).isZero();
+ assertThat(CronExpression.MIN_CAL.getTimeInMillis()).isZero();
+ }
+
@Test
@Timeout(value = 1, unit = TimeUnit.SECONDS)
void testPrevFireTimeAtEpochReturnsNullPromptly() throws Exception {
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/CronExpression.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/CronExpression.java
index 6c93647a45..04a4bf159f 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/CronExpression.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/CronExpression.java
@@ -257,7 +257,8 @@ public final class CronExpression {
public static final Calendar MIN_CAL = Calendar.getInstance();
static {
- MIN_CAL.set(1970, 0, 1);
+ // The epoch, independent of the time of day and the default time zone
+ MIN_CAL.setTimeInMillis(0);
}
public static final Date MIN_DATE = MIN_CAL.getTime();
diff --git a/src/changelog/.2.x.x/fix_cron_expression_min_date.xml b/src/changelog/.2.x.x/fix_cron_expression_min_date.xml
new file mode 100644
index 0000000000..cdb1b82979
--- /dev/null
+++ b/src/changelog/.2.x.x/fix_cron_expression_min_date.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<entry xmlns="https://logging.apache.org/xml/ns"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ https://logging.apache.org/xml/ns
+ https://logging.apache.org/xml/ns/log4j-changelog-0.xsd"
+ type="fixed">
+ <description format="asciidoc">
+ Fix `CronExpression.MIN_DATE` to be the epoch instead of depending on the JVM start time and default time zone.
+ </description>
+</entry>