Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:

build:
if: github.actor != 'dependabot[bot]'
uses: apache/logging-parent/.github/workflows/build-reusable.yaml@rel/11.2.0
uses: apache/logging-parent/.github/workflows/build-reusable.yaml@rel/11.3.0
secrets:
DV_ACCESS_TOKEN: ${{ startsWith(github.ref_name, 'release/') && '' || secrets.GE_ACCESS_TOKEN }}
with:
Expand All @@ -44,7 +44,7 @@ jobs:
deploy-snapshot:
needs: build
if: github.repository == 'apache/logging-log4j2' && github.ref_name == '2.24.x'
uses: apache/logging-parent/.github/workflows/deploy-snapshot-reusable.yaml@rel/11.2.0
uses: apache/logging-parent/.github/workflows/deploy-snapshot-reusable.yaml@rel/11.3.0
# Secrets for deployments
secrets:
NEXUS_USERNAME: ${{ secrets.NEXUS_USER }}
Expand All @@ -57,7 +57,7 @@ jobs:
deploy-release:
needs: build
if: github.repository == 'apache/logging-log4j2' && startsWith(github.ref_name, 'release/')
uses: apache/logging-parent/.github/workflows/deploy-release-reusable.yaml@rel/11.2.0
uses: apache/logging-parent/.github/workflows/deploy-release-reusable.yaml@rel/11.3.0
# Secrets for deployments
secrets:
GPG_SECRET_KEY: ${{ secrets.LOGGING_GPG_SECRET_KEY }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ permissions: read-all
jobs:

analyze:
uses: apache/logging-parent/.github/workflows/codeql-analysis-reusable.yaml@rel/11.2.0
uses: apache/logging-parent/.github/workflows/codeql-analysis-reusable.yaml@rel/11.3.0
with:
java-version: |
8
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/deploy-site.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:

deploy-site-stg:
if: github.repository == 'apache/logging-log4j2' && github.ref_name == '2.x'
uses: apache/logging-parent/.github/workflows/deploy-site-reusable.yaml@rel/11.2.0
uses: apache/logging-parent/.github/workflows/deploy-site-reusable.yaml@rel/11.3.0
# Secrets for committing the generated site
secrets:
GPG_SECRET_KEY: ${{ secrets.LOGGING_GPG_SECRET_KEY }}
Expand All @@ -53,7 +53,7 @@ jobs:

deploy-site-pro:
if: github.repository == 'apache/logging-log4j2' && github.ref_name == '2.x-site-pro'
uses: apache/logging-parent/.github/workflows/deploy-site-reusable.yaml@rel/11.2.0
uses: apache/logging-parent/.github/workflows/deploy-site-reusable.yaml@rel/11.3.0
# Secrets for committing the generated site
secrets:
GPG_SECRET_KEY: ${{ secrets.LOGGING_GPG_SECRET_KEY }}
Expand Down Expand Up @@ -83,7 +83,7 @@ jobs:

deploy-site-rel:
needs: export-version
uses: apache/logging-parent/.github/workflows/deploy-site-reusable.yaml@rel/11.2.0
uses: apache/logging-parent/.github/workflows/deploy-site-reusable.yaml@rel/11.3.0
# Secrets for committing the generated site
secrets:
GPG_SECRET_KEY: ${{ secrets.LOGGING_GPG_SECRET_KEY }}
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/develocity-publish-build-scans.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@ jobs:
actions: write
pull-requests: write
steps:

- name: Setup Build Scan link capture
uses: gradle/develocity-actions/maven-setup@v1
uses: gradle/develocity-actions/maven-setup@9f1bf05334de7eb619731d5466c35a153742311d # 1.2

- name: Publish Build Scans
uses: gradle/develocity-actions/maven-publish-build-scan@v1
uses: gradle/develocity-actions/maven-publish-build-scan@9f1bf05334de7eb619731d5466c35a153742311d # 1.2
with:
develocity-url: 'https://ge.apache.org'
develocity-access-key: ${{ secrets.GE_ACCESS_TOKEN }}
4 changes: 2 additions & 2 deletions .github/workflows/merge-dependabot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
build:
if: github.repository == 'apache/logging-log4j2' && github.event_name == 'pull_request_target' && github.actor == 'dependabot[bot]'
# Temporary use `develocity` branch
uses: apache/logging-parent/.github/workflows/build-reusable.yaml@rel/11.2.0
uses: apache/logging-parent/.github/workflows/build-reusable.yaml@rel/11.3.0
secrets:
DV_ACCESS_TOKEN: ${{ secrets.GE_ACCESS_TOKEN }}
with:
Expand All @@ -43,7 +43,7 @@ jobs:

merge-dependabot:
needs: build
uses: apache/logging-parent/.github/workflows/merge-dependabot-reusable.yaml@rel/11.2.0
uses: apache/logging-parent/.github/workflows/merge-dependabot-reusable.yaml@rel/11.3.0
with:
java-version: 17
permissions:
Expand Down
7 changes: 7 additions & 0 deletions BUILDING.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,13 @@ You either need to have a user-level configuration in `~/.m2/toolchains.xml` or
./mvnw verify -Pjava8-tests,!java8-incompat-fixes
----

[#docker]
=== Docker tests

Certain tests use Docker to spawn necessary external services.
Docker tests are configured using the `docker` Maven profile, which is activated by default for the CI environment.
You can locally enable this profile by passing a `-P docker` argument to your `./mvnw` commands.

[#website]
== Building the website

Expand Down
10 changes: 10 additions & 0 deletions log4j-appserver/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,22 +52,32 @@
org.apache.tomcat.juli;transitive=false,
org.eclipse.jetty.util;transitive=false
</bnd-extra-module-options>

<!-- Dependencies unique for this module -->
<jetty.version>9.4.56.v20240826</jetty.version>
<tomcat-juli.version>10.0.27</tomcat-juli.version>
</properties>

<dependencies>

<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-util</artifactId>
<version>${jetty.version}</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-juli</artifactId>
<version>${tomcat-juli.version}</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
</dependency>

</dependencies>
</project>
4 changes: 2 additions & 2 deletions log4j-core-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,12 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<groupId>org.apache.groovy</groupId>
<artifactId>groovy-dateutil</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<groupId>org.apache.groovy</groupId>
<artifactId>groovy-jsr223</artifactId>
<scope>test</scope>
</dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
package org.apache.logging.log4j.core.config;

import static java.util.Objects.requireNonNull;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
Expand All @@ -32,50 +33,57 @@
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.jar.Attributes;
import java.util.jar.JarEntry;
import java.util.jar.JarOutputStream;
import java.util.jar.Manifest;
import org.apache.commons.io.IOUtils;
import org.apache.logging.log4j.core.net.UrlConnectionFactory;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;

public class ConfigurationSourceTest {
private static final Path JAR_FILE = Paths.get("target", "test-classes", "jarfile.jar");
private static final Path CONFIG_FILE = Paths.get("target", "test-classes", "log4j2-console.xml");
private static final byte[] buffer = new byte[1024];
/**
* The path inside the jar created by {@link #prepareJarConfigURL} containing the configuration.
*/
public static final String PATH_IN_JAR = "/config/console.xml";

private static final String CONFIG_FILE = "/config/ConfigurationSourceTest.xml";

@TempDir
private Path tempDir;

@Test
public void testJira_LOG4J2_2770_byteArray() throws Exception {
void testJira_LOG4J2_2770_byteArray() throws Exception {
final ConfigurationSource configurationSource =
new ConfigurationSource(new ByteArrayInputStream(new byte[] {'a', 'b'}));
assertNotNull(configurationSource.resetInputStream());
}

/**
* Checks if the usage of 'jar:' URLs does not increase the file descriptor
* count and the jar file can be deleted.
*
* @throws Exception
* count, and the jar file can be deleted.
*/
@Test
public void testNoJarFileLeak() throws Exception {
final URL jarConfigURL = prepareJarConfigURL();
void testNoJarFileLeak() throws Exception {
final Path jarFile = prepareJarConfigURL(tempDir);
final URL jarConfigURL = new URL("jar:" + jarFile.toUri().toURL() + "!" + PATH_IN_JAR);
final long expected = getOpenFileDescriptorCount();
UrlConnectionFactory.createConnection(jarConfigURL).getInputStream().close();
// This can only fail on UNIX
assertEquals(expected, getOpenFileDescriptorCount());
// This can only fail on Windows
try {
Files.delete(JAR_FILE);
Files.delete(jarFile);
} catch (IOException e) {
fail(e);
}
}

@Test
public void testLoadConfigurationSourceFromJarFile() throws Exception {
final URL jarConfigURL = prepareJarConfigURL();
final Path jarFile = prepareJarConfigURL(tempDir);
final URL jarConfigURL = new URL("jar:" + jarFile.toUri().toURL() + "!" + PATH_IN_JAR);
final long expectedFdCount = getOpenFileDescriptorCount();
ConfigurationSource configSource = ConfigurationSource.fromUri(jarConfigURL.toURI());
assertNotNull(configSource);
Expand All @@ -90,7 +98,7 @@ public void testLoadConfigurationSourceFromJarFile() throws Exception {
assertEquals(expectedFdCount, getOpenFileDescriptorCount());
// This can only fail on Windows
try {
Files.delete(JAR_FILE);
Files.delete(jarFile);
} catch (IOException e) {
fail(e);
}
Expand All @@ -104,22 +112,18 @@ private long getOpenFileDescriptorCount() {
return 0L;
}

public static URL prepareJarConfigURL() throws IOException {
if (!Files.exists(JAR_FILE)) {
final Manifest manifest = new Manifest();
manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0");
try (final OutputStream os = Files.newOutputStream(JAR_FILE);
final JarOutputStream jar = new JarOutputStream(os, manifest);
final InputStream config = Files.newInputStream(CONFIG_FILE)) {
final JarEntry jarEntry = new JarEntry("config/console.xml");
jar.putNextEntry(jarEntry);
int len;
while ((len = config.read(buffer)) != -1) {
jar.write(buffer, 0, len);
}
jar.closeEntry();
}
public static Path prepareJarConfigURL(Path dir) throws IOException {
Path jarFile = dir.resolve("jarFile.jar");
final Manifest manifest = new Manifest();
manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0");
try (final OutputStream os = Files.newOutputStream(jarFile);
final JarOutputStream jar = new JarOutputStream(os, manifest);
final InputStream config =
requireNonNull(ConfigurationSourceTest.class.getResourceAsStream(CONFIG_FILE))) {
final JarEntry jarEntry = new JarEntry("config/console.xml");
jar.putNextEntry(jarEntry);
IOUtils.copy(config, os);
}
return new URL("jar:" + JAR_FILE.toUri().toURL() + "!/config/console.xml");
return jarFile;
}
}
Loading