Skip to content

Commit

Permalink
Upgrade compiler baseline to Java 17 (apache#2021)
Browse files Browse the repository at this point in the history
  • Loading branch information
vy authored Dec 1, 2023
1 parent 8c09c3f commit 6b9d122
Show file tree
Hide file tree
Showing 24 changed files with 320 additions and 80 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
with:
java-version: |
8
11
17
site-enabled: true

deploy-snapshot:
Expand All @@ -56,7 +56,7 @@ jobs:
with:
java-version: |
8
11
17
deploy-release:
needs: build
Expand All @@ -75,6 +75,6 @@ jobs:
with:
java-version: |
8
11
17
project-id: log4j
site-enabled: true
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
with:
java-version: |
8
11
17
# Permissions required to publish Security Alerts
permissions:
actions: read
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/merge-dependabot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ jobs:
with:
java-version: |
8
11
17
merge-dependabot:
needs: build
uses: apache/logging-parent/.github/workflows/merge-dependabot-reusable.yaml@main
with:
java-version: 11
java-version: 17
permissions:
contents: write # to push changelog commits
pull-requests: write # to close the PR
Expand Down
2 changes: 1 addition & 1 deletion .java-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
11
17
2 changes: 1 addition & 1 deletion BUILDING.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
[#requirements]
== Requirements
* JDK 11+
* JDK 17+
* A modern Linux, OSX, or Windows host
[#building]
Expand Down
47 changes: 42 additions & 5 deletions log4j-1.2-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -140,15 +140,12 @@

<build>
<plugins>

<!-- Enable Log4j plugin processing -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<!--
~ Modules that contain `log4j-core` plugins, must be compiled with:
~
~ org.apache.logging.log4j.core.config.plugins.processor.PluginProcessor
-->
<annotationProcessorPaths combine.children="append">
<path>
<groupId>org.apache.logging.log4j</groupId>
Expand All @@ -158,6 +155,46 @@
</annotationProcessorPaths>
</configuration>
</plugin>

</plugins>
</build>

<profiles>

<!-- Fixes incompatible with Java 8 -->
<profile>

<id>java8-incompat-fixes</id>

<!-- CI uses Java 8 for running tests.
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 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>
<name>!env.CI</name>
</property>
</activation>

<!-- Illegal access is disabled by default in Java 16 due to JEP-396.
We are relaxing it for tests. -->
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>--add-opens java.base/java.io=ALL-UNNAMED</argLine>
</configuration>
</plugin>
</plugins>
</build>

</profile>

</profiles>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,15 @@

import static org.junit.jupiter.api.Assertions.assertNull;

import org.apache.logging.log4j.test.junit.InitializesThreadContext;
import org.apache.logging.log4j.test.junit.SetTestProperty;
import org.apache.logging.log4j.test.junit.UsingThreadContextMap;
import org.junit.jupiter.api.Test;
import org.junitpioneer.jupiter.SetSystemProperty;

/**
* Tests {@link ThreadContext}.
*/
@SetSystemProperty(key = "log4j2.disableThreadContext", value = "true")
@SetSystemProperty(key = "log4j2.disableThreadContextMap", value = "true")
@InitializesThreadContext
@SetTestProperty(key = "log4j2.disableThreadContext", value = "true")
@SetTestProperty(key = "log4j2.disableThreadContextMap", value = "true")
@UsingThreadContextMap
public class NoopThreadContextTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
import org.apache.logging.log4j.spi.DefaultThreadContextMap;
import org.apache.logging.log4j.test.ThreadContextUtilityClass;
import org.apache.logging.log4j.test.junit.InitializesThreadContext;
import org.apache.logging.log4j.test.junit.SetTestProperty;
import org.apache.logging.log4j.test.junit.UsingThreadContextMap;
import org.apache.logging.log4j.test.junit.UsingThreadContextStack;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Tag;
Expand All @@ -33,8 +36,10 @@
/**
* Tests {@link ThreadContext}.
*/
@SetSystemProperty(key = DefaultThreadContextMap.INHERITABLE_MAP, value = "true")
@SetTestProperty(key = DefaultThreadContextMap.INHERITABLE_MAP, value = "true")
@InitializesThreadContext
@UsingThreadContextMap
@UsingThreadContextStack
public class ThreadContextInheritanceTest {

@BeforeAll
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
import java.util.HashMap;
import java.util.Map;
import org.apache.logging.log4j.test.junit.InitializesThreadContext;
import org.apache.logging.log4j.test.junit.SetTestProperty;
import org.apache.logging.log4j.test.junit.UsingThreadContextMap;
import org.junit.jupiter.api.Test;
import org.junitpioneer.jupiter.ClearSystemProperty;
import org.junitpioneer.jupiter.SetSystemProperty;

/**
* Tests the {@code DefaultThreadContextMap} class.
Expand Down Expand Up @@ -228,7 +228,7 @@ public void testThreadLocalNotInheritableByDefault() {
}

@Test
@SetSystemProperty(key = DefaultThreadContextMap.INHERITABLE_MAP, value = "true")
@SetTestProperty(key = DefaultThreadContextMap.INHERITABLE_MAP, value = "true")
@InitializesThreadContext
public void testThreadLocalInheritableIfConfigured() {
ThreadContextMapFactory.init();
Expand Down
59 changes: 54 additions & 5 deletions log4j-core-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -355,15 +355,12 @@

<build>
<plugins>

<!-- Enable Log4j plugin processing -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<!--
~ Modules that contain `log4j-core` plugins, must be compiled with:
~
~ org.apache.logging.log4j.core.config.plugins.processor.PluginProcessor
-->
<annotationProcessorPaths combine.children="append">
<path>
<groupId>org.apache.logging.log4j</groupId>
Expand All @@ -373,6 +370,58 @@
</annotationProcessorPaths>
</configuration>
</plugin>

</plugins>
</build>

<profiles>

<!-- Fixes incompatible with Java 8 -->
<profile>

<id>java8-incompat-fixes</id>

<!-- CI uses Java 8 for running tests.
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 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>
<name>!env.CI</name>
</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>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>--add-opens java.base/java.lang=ALL-UNNAMED
--add-opens java.base/java.net=ALL-UNNAMED
--add-opens java.base/java.util=ALL-UNNAMED</argLine>
</configuration>
</plugin>
</plugins>
</build>

</profile>

</profiles>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledOnOs;
import org.junit.jupiter.api.condition.OS;
import org.junitpioneer.jupiter.RetryingTest;

/**
* Tests the UrlConnectionFactory
Expand Down Expand Up @@ -142,7 +143,7 @@ private int verifyNotModified(final URI uri, final long lastModifiedMillis) thro
}
}

@Test
@RetryingTest(maxAttempts = 5, suspendForMs = 1000)
@DisabledOnOs(value = OS.WINDOWS, disabledReason = "Fails frequently on Windows (#2011)")
public void testNoJarFileLeak() throws Exception {
ConfigurationSourceTest.prepareJarConfigURL();
Expand Down
Loading

0 comments on commit 6b9d122

Please sign in to comment.