You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by vy...@apache.org on 2023/12/01 20:40:08 UTC

(logging-log4j2) branch 2.x-java-17 updated (a42283bd50 -> 190092d0e5)

This is an automated email from the ASF dual-hosted git repository.

vy pushed a change to branch 2.x-java-17
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git


    from a42283bd50 Fix Java 8 test runs
     new 293e3c20ff Revert irrelevant `DatePatternConverterTestBase` changes
     new 190092d0e5 More Java 8 fixes

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 log4j-1.2-api/pom.xml                              | 12 +++--
 log4j-core-test/pom.xml                            | 27 ++++++----
 .../core/pattern/DatePatternConverterTestBase.java | 58 +++++++++++-----------
 log4j-jpa/pom.xml                                  | 12 +++--
 log4j-osgi-test/pom.xml                            | 12 +++--
 5 files changed, 67 insertions(+), 54 deletions(-)


(logging-log4j2) 01/02: Revert irrelevant `DatePatternConverterTestBase` changes

Posted by vy...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

vy pushed a commit to branch 2.x-java-17
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git

commit 293e3c20ffe3c218a44a0afee443a22f90710577
Author: Volkan Yazıcı <vo...@yazi.ci>
AuthorDate: Fri Dec 1 21:39:14 2023 +0100

    Revert irrelevant `DatePatternConverterTestBase` changes
---
 .../core/pattern/DatePatternConverterTestBase.java | 58 +++++++++++-----------
 1 file changed, 29 insertions(+), 29 deletions(-)

diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/pattern/DatePatternConverterTestBase.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/pattern/DatePatternConverterTestBase.java
index 6bcf5242f9..b9680290a0 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/pattern/DatePatternConverterTestBase.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/pattern/DatePatternConverterTestBase.java
@@ -105,12 +105,12 @@ abstract class DatePatternConverterTestBase {
     }
 
     @Test
-    void testFormatDateStringBuilderDefaultPattern() {
+    public void testFormatDateStringBuilderDefaultPattern() {
         assertDatePattern(null, date(2001, 1, 1), "2001-02-01 14:15:16,123");
     }
 
     @Test
-    void testFormatDateStringBuilderIso8601() {
+    public void testFormatDateStringBuilderIso8601() {
         final DatePatternConverter converter = DatePatternConverter.newInstance(ISO8601_FORMAT_OPTIONS);
         final StringBuilder sb = new StringBuilder();
         converter.format(date(2001, 1, 1), sb);
@@ -120,19 +120,19 @@ abstract class DatePatternConverterTestBase {
     }
 
     @Test
-    void testFormatDateStringBuilderIso8601BasicWithPeriod() {
+    public void testFormatDateStringBuilderIso8601BasicWithPeriod() {
         assertDatePattern(
                 FixedDateFormat.FixedFormat.ISO8601_BASIC_PERIOD.name(), date(2001, 1, 1), "20010201T141516.123");
     }
 
     @Test
-    void testFormatDateStringBuilderIso8601WithPeriod() {
+    public void testFormatDateStringBuilderIso8601WithPeriod() {
         assertDatePattern(
                 FixedDateFormat.FixedFormat.ISO8601_PERIOD.name(), date(2001, 1, 1), "2001-02-01T14:15:16.123");
     }
 
     @Test
-    void testFormatDateStringBuilderIso8601WithPeriodMicroseconds() {
+    public void testFormatDateStringBuilderIso8601WithPeriodMicroseconds() {
         final String[] pattern = {FixedDateFormat.FixedFormat.ISO8601_PERIOD_MICROS.name(), "Z"};
         final DatePatternConverter converter = DatePatternConverter.newInstance(pattern);
         final StringBuilder sb = new StringBuilder();
@@ -148,12 +148,12 @@ abstract class DatePatternConverterTestBase {
     }
 
     @Test
-    void testFormatDateStringBuilderOriginalPattern() {
+    public void testFormatDateStringBuilderOriginalPattern() {
         assertDatePattern("yyyy/MM/dd HH-mm-ss.SSS", date(2001, 1, 1), "2001/02/01 14-15-16.123");
     }
 
     @Test
-    void testFormatLogEventStringBuilderDefaultPattern() {
+    public void testFormatLogEventStringBuilderDefaultPattern() {
         final LogEvent event = new MyLogEvent();
         final DatePatternConverter converter = DatePatternConverter.newInstance(null);
         final StringBuilder sb = new StringBuilder();
@@ -164,7 +164,7 @@ abstract class DatePatternConverterTestBase {
     }
 
     @Test
-    void testFormatLogEventStringBuilderIso8601() {
+    public void testFormatLogEventStringBuilderIso8601() {
         final LogEvent event = new MyLogEvent();
         final DatePatternConverter converter = DatePatternConverter.newInstance(ISO8601_FORMAT_OPTIONS);
         final StringBuilder sb = new StringBuilder();
@@ -175,7 +175,7 @@ abstract class DatePatternConverterTestBase {
     }
 
     @Test
-    void testFormatAmericanPatterns() {
+    public void testFormatAmericanPatterns() {
         final Date date = date(2011, 2, 11);
         assertDatePattern("US_MONTH_DAY_YEAR4_TIME", date, "11/03/2011 14:15:16.123");
         assertDatePattern("US_MONTH_DAY_YEAR2_TIME", date, "11/03/11 14:15:16.123");
@@ -194,7 +194,7 @@ abstract class DatePatternConverterTestBase {
     }
 
     @Test
-    void testFormatLogEventStringBuilderIso8601TimezoneJST() {
+    public void testFormatLogEventStringBuilderIso8601TimezoneJST() {
         final LogEvent event = new MyLogEvent();
         final String[] optionsWithTimezone = {ISO8601, "JST"};
         final DatePatternConverter converter = DatePatternConverter.newInstance(optionsWithTimezone);
@@ -212,7 +212,7 @@ abstract class DatePatternConverterTestBase {
     }
 
     @Test
-    void testFormatLogEventStringBuilderIso8601TimezoneOffsetHHCMM() {
+    public void testFormatLogEventStringBuilderIso8601TimezoneOffsetHHCMM() {
         final LogEvent event = new MyLogEvent();
         final String[] optionsWithTimezone = {ISO8601_OFFSET_DATE_TIME_HHCMM};
         final DatePatternConverter converter = DatePatternConverter.newInstance(optionsWithTimezone);
@@ -226,7 +226,7 @@ abstract class DatePatternConverterTestBase {
     }
 
     @Test
-    void testFormatLogEventStringBuilderIso8601TimezoneOffsetHHMM() {
+    public void testFormatLogEventStringBuilderIso8601TimezoneOffsetHHMM() {
         final LogEvent event = new MyLogEvent();
         final String[] optionsWithTimezone = {ISO8601_OFFSET_DATE_TIME_HHMM};
         final DatePatternConverter converter = DatePatternConverter.newInstance(optionsWithTimezone);
@@ -240,7 +240,7 @@ abstract class DatePatternConverterTestBase {
     }
 
     @Test
-    void testFormatLogEventStringBuilderIso8601TimezoneUTC() {
+    public void testFormatLogEventStringBuilderIso8601TimezoneUTC() {
         final LogEvent event = new MyLogEvent();
         final DatePatternConverter converter = DatePatternConverter.newInstance(new String[] {"ISO8601", "UTC"});
         final StringBuilder sb = new StringBuilder();
@@ -256,7 +256,7 @@ abstract class DatePatternConverterTestBase {
     }
 
     @Test
-    void testFormatLogEventStringBuilderIso8601TimezoneZ() {
+    public void testFormatLogEventStringBuilderIso8601TimezoneZ() {
         final LogEvent event = new MyLogEvent();
         final String[] optionsWithTimezone = {ISO8601, "Z"};
         final DatePatternConverter converter = DatePatternConverter.newInstance(optionsWithTimezone);
@@ -273,7 +273,7 @@ abstract class DatePatternConverterTestBase {
     }
 
     @Test
-    void testFormatObjectStringBuilderDefaultPattern() {
+    public void testFormatObjectStringBuilderDefaultPattern() {
         final DatePatternConverter converter = DatePatternConverter.newInstance(null);
         final StringBuilder sb = new StringBuilder();
         converter.format("nondate", sb);
@@ -283,7 +283,7 @@ abstract class DatePatternConverterTestBase {
     }
 
     @Test
-    void testFormatStringBuilderObjectArrayDefaultPattern() {
+    public void testFormatStringBuilderObjectArrayDefaultPattern() {
         final DatePatternConverter converter = DatePatternConverter.newInstance(null);
         final StringBuilder sb = new StringBuilder();
         converter.format(sb, date(2001, 1, 1), date(2002, 2, 2), date(2003, 3, 3));
@@ -293,7 +293,7 @@ abstract class DatePatternConverterTestBase {
     }
 
     @Test
-    void testFormatStringBuilderObjectArrayIso8601() {
+    public void testFormatStringBuilderObjectArrayIso8601() {
         final DatePatternConverter converter = DatePatternConverter.newInstance(ISO8601_FORMAT_OPTIONS);
         final StringBuilder sb = new StringBuilder();
         converter.format(sb, date(2001, 1, 1), date(2002, 2, 2), date(2003, 3, 3));
@@ -303,49 +303,49 @@ abstract class DatePatternConverterTestBase {
     }
 
     @Test
-    void testGetPatternReturnsDefaultForEmptyOptionsArray() {
+    public void testGetPatternReturnsDefaultForEmptyOptionsArray() {
         assertEquals(
                 DEFAULT_PATTERN,
                 DatePatternConverter.newInstance(Strings.EMPTY_ARRAY).getPattern());
     }
 
     @Test
-    void testGetPatternReturnsDefaultForInvalidPattern() {
+    public void testGetPatternReturnsDefaultForInvalidPattern() {
         final String[] invalid = {"ABC I am not a valid date pattern"};
         assertEquals(DEFAULT_PATTERN, DatePatternConverter.newInstance(invalid).getPattern());
     }
 
     @Test
-    void testGetPatternReturnsDefaultForNullOptions() {
+    public void testGetPatternReturnsDefaultForNullOptions() {
         assertEquals(DEFAULT_PATTERN, DatePatternConverter.newInstance(null).getPattern());
     }
 
     @Test
-    void testGetPatternReturnsDefaultForSingleNullElementOptionsArray() {
+    public void testGetPatternReturnsDefaultForSingleNullElementOptionsArray() {
         assertEquals(
                 DEFAULT_PATTERN, DatePatternConverter.newInstance(new String[1]).getPattern());
     }
 
     @Test
-    void testGetPatternReturnsDefaultForTwoNullElementsOptionsArray() {
+    public void testGetPatternReturnsDefaultForTwoNullElementsOptionsArray() {
         assertEquals(
                 DEFAULT_PATTERN, DatePatternConverter.newInstance(new String[2]).getPattern());
     }
 
     @Test
-    void testGetPatternReturnsNullForUnix() {
+    public void testGetPatternReturnsNullForUnix() {
         final String[] options = {"UNIX"};
         assertNull(DatePatternConverter.newInstance(options).getPattern());
     }
 
     @Test
-    void testGetPatternReturnsNullForUnixMillis() {
+    public void testGetPatternReturnsNullForUnixMillis() {
         final String[] options = {"UNIX_MILLIS"};
         assertNull(DatePatternConverter.newInstance(options).getPattern());
     }
 
     @Test
-    void testInvalidLongPatternIgnoresExcessiveDigits() {
+    public void testInvalidLongPatternIgnoresExcessiveDigits() {
         final StringBuilder preciseBuilder = new StringBuilder();
         final StringBuilder milliBuilder = new StringBuilder();
         final LogEvent event = new MyLogEvent();
@@ -396,13 +396,13 @@ abstract class DatePatternConverterTestBase {
     }
 
     @Test
-    void testNewInstanceAllowsNullParameter() {
+    public void testNewInstanceAllowsNullParameter() {
         DatePatternConverter.newInstance(null); // no errors
     }
 
     // test with all formats from one 'n' (100s of millis) to 'nnnnnnnnn' (nanosecond precision)
     @Test
-    void testPredefinedFormatWithAnyValidNanoPrecision() {
+    public void testPredefinedFormatWithAnyValidNanoPrecision() {
         final StringBuilder preciseBuilder = new StringBuilder();
         final StringBuilder milliBuilder = new StringBuilder();
         final LogEvent event = new MyLogEvent();
@@ -450,7 +450,7 @@ abstract class DatePatternConverterTestBase {
     }
 
     @Test
-    void testPredefinedFormatWithoutTimezone() {
+    public void testPredefinedFormatWithoutTimezone() {
         for (final FixedDateFormat.FixedFormat format : FixedDateFormat.FixedFormat.values()) {
             final String[] options = {format.name()};
             final DatePatternConverter converter = DatePatternConverter.newInstance(options);
@@ -459,7 +459,7 @@ abstract class DatePatternConverterTestBase {
     }
 
     @Test
-    void testPredefinedFormatWithTimezone() {
+    public void testPredefinedFormatWithTimezone() {
         for (final FixedDateFormat.FixedFormat format : FixedDateFormat.FixedFormat.values()) {
             final String[] options = {format.name(), "PST"}; // Pacific Standard Time=UTC-8:00
             final DatePatternConverter converter = DatePatternConverter.newInstance(options);


(logging-log4j2) 02/02: More Java 8 fixes

Posted by vy...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

vy pushed a commit to branch 2.x-java-17
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git

commit 190092d0e5b436cc779d0e97fe425cb4b88a7491
Author: Volkan Yazıcı <vo...@yazi.ci>
AuthorDate: Fri Dec 1 21:40:05 2023 +0100

    More Java 8 fixes
---
 log4j-1.2-api/pom.xml   | 12 +++++++-----
 log4j-core-test/pom.xml | 27 +++++++++++++++++----------
 log4j-jpa/pom.xml       | 12 +++++++-----
 log4j-osgi-test/pom.xml | 12 +++++++-----
 4 files changed, 38 insertions(+), 25 deletions(-)

diff --git a/log4j-1.2-api/pom.xml b/log4j-1.2-api/pom.xml
index 09ef006194..58c18dd5bc 100644
--- a/log4j-1.2-api/pom.xml
+++ b/log4j-1.2-api/pom.xml
@@ -161,17 +161,17 @@
 
   <profiles>
 
-    <!-- Relax reflective access constraints for tests -->
+    <!-- Fixes incompatible with Java 8 -->
     <profile>
 
-      <id>reflective-access-fixes</id>
+      <id>java8-incompat-fixes</id>
 
       <!-- CI uses Java 8 for running tests.
-           Though illegal access is disabled by default in Java 16 due to JEP-396.
-           Hence, we assume CI=Java8 and open modules only elsewhere.
+           Hence, we assume CI=Java8 and apply our changes elsewhere.
 
            One might think why not activate using `<jdk>[16,)` instead?
-           This doesn't work, since the match is not against "the JDK used by tests".
+           This doesn't work, since the match is not against "the JDK running tests", but "the JDK running Maven".
+           These two JDKs can differ due to Maven Toolchains.
            See `java8-tests` profile in `/pom.xml` for details. -->
       <activation>
         <property>
@@ -179,6 +179,8 @@
         </property>
       </activation>
 
+      <!-- Illegal access is disabled by default in Java 16 due to JEP-396.
+           We are relaxing it for tests. -->
       <build>
         <plugins>
           <plugin>
diff --git a/log4j-core-test/pom.xml b/log4j-core-test/pom.xml
index bc48791c98..fb79c45da2 100644
--- a/log4j-core-test/pom.xml
+++ b/log4j-core-test/pom.xml
@@ -297,11 +297,6 @@
       <artifactId>mockito-junit-jupiter</artifactId>
       <scope>test</scope>
     </dependency>
-    <dependency>
-      <groupId>org.openjdk.nashorn</groupId>
-      <artifactId>nashorn-core</artifactId>
-      <scope>test</scope>
-    </dependency>
     <dependency>
       <groupId>org.apache.felix</groupId>
       <artifactId>org.apache.felix.framework</artifactId>
@@ -381,17 +376,17 @@
 
   <profiles>
 
-    <!-- Relax reflective access constraints for tests -->
+    <!-- Fixes incompatible with Java 8 -->
     <profile>
 
-      <id>reflective-access-fixes</id>
+      <id>java8-incompat-fixes</id>
 
       <!-- CI uses Java 8 for running tests.
-           Though illegal access is disabled by default in Java 16 due to JEP-396.
-           Hence, we assume CI=Java8 and open modules only elsewhere.
+           Hence, we assume CI=Java8 and apply our changes elsewhere.
 
            One might think why not activate using `<jdk>[16,)` instead?
-           This doesn't work, since the match is not against "the JDK used by tests".
+           This doesn't work, since the match is not against "the JDK running tests", but "the JDK running Maven".
+           These two JDKs can differ due to Maven Toolchains.
            See `java8-tests` profile in `/pom.xml` for details. -->
       <activation>
         <property>
@@ -399,6 +394,18 @@
         </property>
       </activation>
 
+      <!-- JEP-335 has deprecated the built-in JavaScript engine (Nashorn) in Java 11, and JEP-372 removed it in Java 15.
+           We are adding it back for tests that use JavaScript. -->
+      <dependencies>
+        <dependency>
+          <groupId>org.openjdk.nashorn</groupId>
+          <artifactId>nashorn-core</artifactId>
+          <scope>test</scope>
+        </dependency>
+      </dependencies>
+
+      <!-- Illegal access is disabled by default in Java 16 due to JEP-396.
+           We are relaxing it for tests. -->
       <build>
         <plugins>
           <plugin>
diff --git a/log4j-jpa/pom.xml b/log4j-jpa/pom.xml
index df7a007434..54e535b2b6 100644
--- a/log4j-jpa/pom.xml
+++ b/log4j-jpa/pom.xml
@@ -121,17 +121,17 @@
 
   <profiles>
 
-    <!-- Relax reflective access constraints for tests -->
+    <!-- Fixes incompatible with Java 8 -->
     <profile>
 
-      <id>reflective-access-fixes</id>
+      <id>java8-incompat-fixes</id>
 
       <!-- CI uses Java 8 for running tests.
-           Though illegal access is disabled by default in Java 16 due to JEP-396.
-           Hence, we assume CI=Java8 and open modules only elsewhere.
+           Hence, we assume CI=Java8 and apply our changes elsewhere.
 
            One might think why not activate using `<jdk>[16,)` instead?
-           This doesn't work, since the match is not against "the JDK used by tests".
+           This doesn't work, since the match is not against "the JDK running tests", but "the JDK running Maven".
+           These two JDKs can differ due to Maven Toolchains.
            See `java8-tests` profile in `/pom.xml` for details. -->
       <activation>
         <property>
@@ -139,6 +139,8 @@
         </property>
       </activation>
 
+      <!-- Illegal access is disabled by default in Java 16 due to JEP-396.
+           We are relaxing it for tests. -->
       <build>
         <plugins>
           <plugin>
diff --git a/log4j-osgi-test/pom.xml b/log4j-osgi-test/pom.xml
index 885fd510b4..b181d642cd 100644
--- a/log4j-osgi-test/pom.xml
+++ b/log4j-osgi-test/pom.xml
@@ -209,17 +209,17 @@
 
   <profiles>
 
-    <!-- Relax reflective access constraints for tests -->
+    <!-- Fixes incompatible with Java 8 -->
     <profile>
 
-      <id>reflective-access-fixes</id>
+      <id>java8-incompat-fixes</id>
 
       <!-- CI uses Java 8 for running tests.
-           Though illegal access is disabled by default in Java 16 due to JEP-396.
-           Hence, we assume CI=Java8 and open modules only elsewhere.
+           Hence, we assume CI=Java8 and apply our changes elsewhere.
 
            One might think why not activate using `<jdk>[16,)` instead?
-           This doesn't work, since the match is not against "the JDK used by tests".
+           This doesn't work, since the match is not against "the JDK running tests", but "the JDK running Maven".
+           These two JDKs can differ due to Maven Toolchains.
            See `java8-tests` profile in `/pom.xml` for details. -->
       <activation>
         <property>
@@ -227,6 +227,8 @@
         </property>
       </activation>
 
+      <!-- Illegal access is disabled by default in Java 16 due to JEP-396.
+           We are relaxing it for tests. -->
       <build>
         <plugins>
           <plugin>