Skip to content
Merged
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 gradle/libs.versions.toml
Original file line numberDiff line numberDiff line change
Expand Up@@ -144,9 +144,9 @@ junit-v4-13-1 = { module = "junit:junit", version = "4.13.1" }
kms = { module = "software.amazon.awssdk:kms", version = "2.15.28" }
libphonenumber = { module = "com.googlecode.libphonenumber:libphonenumber", version = "8.12.50" }
listenablefuture = { module = "com.google.guava:listenablefuture", version = "9999.0-empty-to-avoid-conflict-with-guava" }
log4j-1-2-api = { module = "org.apache.logging.log4j:log4j-1.2-api", version = "2.25.4" }
log4j-api = { module = "org.apache.logging.log4j:log4j-api", version = "2.25.3" }
log4j-core = { module = "org.apache.logging.log4j:log4j-core", version = "2.25.4" }
log4j-1-2-api = { module = "org.apache.logging.log4j:log4j-1.2-api", version = "2.26.1" }
log4j-api = { module = "org.apache.logging.log4j:log4j-api", version = "2.26.1" }
log4j-core = { module = "org.apache.logging.log4j:log4j-core", version = "2.26.1" }
management-api = { module = "org.glassfish.external:management-api", version = "3.2.1-b001" }
metrics-spi = { module = "software.amazon.awssdk:metrics-spi", version = "2.15.28" }
miglayout-core = { module = "com.miglayout:miglayout-core", version = "4.2" }
Expand Down
52 changes: 52 additions & 0 deletions gradle/verification-metadata.xml
Original file line numberDiff line numberDiff line change
Expand Up@@ -92,6 +92,11 @@
<sha256 value="ba6d68eeab3a1cc13a77a8ade2197ff9a32aa1cffeac72847d49badd82e1b9ce" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="com.fasterxml.jackson" name="jackson-bom" version="2.19.2">
Comment thread
mgaffigan marked this conversation as resolved.
<artifact name="jackson-bom-2.19.2.pom">
<sha256 value="22006be70fd018099e99c6c27ac0982320f3a0f3c2ce053c55703579a5eea303" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="com.fasterxml.jackson" name="jackson-bom" version="2.21.2">
<artifact name="jackson-bom-2.21.2.pom">
<sha256 value="bc6c549e632927bb9d8a0ada20c8467b5007d3b797c7f5db03a9b60d1de59be3" origin="Generated by Gradle"/>
Expand All@@ -117,6 +122,11 @@
<sha256 value="639a2b63dd05da4e381081303985caadfbb7ad9f85b1d2320638f6b11f208365" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="com.fasterxml.jackson" name="jackson-parent" version="2.19.3">
<artifact name="jackson-parent-2.19.3.pom">
<sha256 value="23d186c8d8cd06015d022c710c715423d660d49e2973b15870b029cc26018682" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="com.fasterxml.jackson" name="jackson-parent" version="2.21">
<artifact name="jackson-parent-2.21.pom">
<sha256 value="3851df627faeb46887b956104630b74a8bbb5f7de22e974cf15982e20e0373de" origin="Generated by Gradle"/>
Expand DownExpand Up@@ -1935,6 +1945,11 @@
<sha256 value="f8ae8904a28e34fa04c35d3740619dae83632401ba1e313bafd7ccf5a3000dec" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.apache.logging.log4j" name="log4j" version="2.26.1">
<artifact name="log4j-2.26.1.pom">
<sha256 value="ea4705725fd94bf5debe2911d4ea7af20898603f68354e64b2461a0f249e445d" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.apache.logging.log4j" name="log4j-1.2-api" version="2.25.3">
<artifact name="log4j-1.2-api-2.25.3.jar">
<sha256 value="72aab8a06335962bfd441605cb4da94777798f699414e02931d29e63fd12ace4" origin="Generated by Gradle"/>
Expand All@@ -1954,6 +1969,14 @@
<sha256 value="ac8e0f5dee9933a353ac2f0ea3451c1edd4dcd8cf5a7a82f34eea1c1a5dae77c" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.apache.logging.log4j" name="log4j-1.2-api" version="2.26.1">
<artifact name="log4j-1.2-api-2.26.1.jar">
<sha256 value="6f063c9c533788cb548d88ddb4bc7c59fbdb830182fc23d19e8d16ed0d8e2986" origin="Generated by Gradle"/>
</artifact>
<artifact name="log4j-1.2-api-2.26.1.module">
<sha256 value="44eb8df5d4e9feeaf714fa81f38776d68646b867c75e2cf4219a27ef0c0ec50c" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.apache.logging.log4j" name="log4j-api" version="2.25.3">
<artifact name="log4j-api-2.25.3.jar">
<sha256 value="e886682920fa0fb9d6eb6395dcb4de088443f8646c89c5e5846e168e327f406f" origin="Generated by Gradle"/>
Expand All@@ -1965,6 +1988,22 @@
<sha256 value="3284be6573aeb83346cff6b746fa325d23eadd9d09c8e286ed1d75904a12dd6e" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.apache.logging.log4j" name="log4j-api" version="2.25.4">
<artifact name="log4j-api-2.25.4.jar">
<sha256 value="c4b642a7f047275215de117e0e3847eb2c7711d84a0aa7433e7b3c096daf341d" origin="Generated by Gradle"/>
</artifact>
<artifact name="log4j-api-2.25.4.module">
<sha256 value="bed1b6791a314e24f97db063bf6bd05d3a7fd76c1450d6c7b45fdbbd7a4f58ff" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.apache.logging.log4j" name="log4j-api" version="2.26.1">
<artifact name="log4j-api-2.26.1.jar">
<sha256 value="f1810a4704ccce019d02bba029dc02a4f2ac0c997f647b465e7d409c1927f822" origin="Generated by Gradle"/>
</artifact>
<artifact name="log4j-api-2.26.1.module">
<sha256 value="5ed93f6fb5334bf7ee52943d1a654bc3a1f3f10765ae2fd4bbd387333be6678a" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.apache.logging.log4j" name="log4j-bom" version="2.24.3">
<artifact name="log4j-bom-2.24.3.pom">
<sha256 value="b17ab7f328f4586b7e71f8c94fc35a5da2bce80705a5d63004022c1928833558" origin="Generated by Gradle"/>
Expand All@@ -1980,6 +2019,11 @@
<sha256 value="7313d339fb632a8610e1140b3290fc24d63743b9aa625e2a0bd59ded40a3ae54" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.apache.logging.log4j" name="log4j-bom" version="2.26.1">
<artifact name="log4j-bom-2.26.1.pom">
<sha256 value="4415ad189dd04db54958a43e23b37cc397a1edee9e888214b8bd47fbe819072e" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.apache.logging.log4j" name="log4j-core" version="2.25.3">
<artifact name="log4j-core-2.25.3.jar">
<sha256 value="362b7fcb65b73aa46cc4bc53abf4eb216f444a83b5d1a037cb6fdfff0ae9f0f9" origin="Generated by Gradle"/>
Expand All@@ -1999,6 +2043,14 @@
<sha256 value="31c581b7390bd2f8481e877775c218924ea730f111c1d812d5b580d96f9c794f" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.apache.logging.log4j" name="log4j-core" version="2.26.1">
<artifact name="log4j-core-2.26.1.jar">
<sha256 value="2ec8c3bf5a6d7c89be8620116a2fc973f7dda1ad0261ad393c4d4726edfd3dcb" origin="Generated by Gradle"/>
</artifact>
<artifact name="log4j-core-2.26.1.module">
<sha256 value="03bfd8adbe306ac46001ec9de668f8e5d24f6659f212fc64e62a1b672a5a2f6a" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.apache.lucene" name="lucene-analysis-common" version="9.12.3">
<artifact name="lucene-analysis-common-9.12.3.jar">
<sha256 value="fa571bd7caf0f0b4faf46a72ca004a7836f348c31d92bd522dddcc3d128d287e" origin="Generated by Gradle"/>
Expand Down
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
// SPDX-License-Identifier: MPL-2.0
// SPDX-FileCopyrightText: 2026 Mitch Gaffigan <mitch@gaffigan.net>

package com.mirth.connect.server.launcher;

import java.io.File;
import java.io.FileFilter;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;

import org.apache.commons.io.filefilter.WildcardFileFilter;

/** Utility class for bootstrapping Log4j. */
final class Log4jBootstrap {
private static final File LOG4J_LIB_DIR = new File("./server-lib/log4j");
private static final String[] JAR_PATTERNS = { "log4j-core-*.jar", "log4j-api-*.jar", "log4j-1.2-api-*.jar" };

private Log4jBootstrap() {}

/** Returns the classpath URLs for the Log4j libraries. */
static List<URL> getClasspathUrls() throws IOException {
return getClasspathUrls(LOG4J_LIB_DIR);
}

/** Unit testable version of getClasspathUrls. */
static List<URL> getClasspathUrls(File log4jLibDir) throws IOException {
List<URL> log4jClasspathUrls = new ArrayList<>();

for (String jarPattern : JAR_PATTERNS) {
File[] matchingFiles = log4jLibDir.listFiles((FileFilter) new WildcardFileFilter(jarPattern));
if (matchingFiles == null || matchingFiles.length != 1) {
throw new IOException("Expected exactly one " + jarPattern + " in " + log4jLibDir.getAbsolutePath());
}
log4jClasspathUrls.add(matchingFiles[0].toURI().toURL());
}

return log4jClasspathUrls;
}
}
Original file line numberDiff line numberDiff line change
Expand Up@@ -43,9 +43,6 @@ public class MirthLauncher {
private static final String LOG4J_PROPERTIES_FILE = "./conf/log4j2.properties";
private static final String PROPERTY_APP_DATA_DIR = "dir.appdata";
private static final String PROPERTY_INCLUDE_CUSTOM_LIB = "server.includecustomlib";
private static final String[] LOG4J_JAR_FILES = { "./server-lib/log4j/log4j-core-2.25.3.jar",
"./server-lib/log4j/log4j-api-2.25.3.jar",
"./server-lib/log4j/log4j-1.2-api-2.25.3.jar" };

private static String appDataDir = null;

Expand All@@ -58,9 +55,7 @@ public static void main(String[] args) {

List<URL> classpathUrls = new ArrayList<>();
// Always add log4j
for (String log4jJar : LOG4J_JAR_FILES) {
classpathUrls.add(new File(log4jJar).toURI().toURL());
}
classpathUrls.addAll(Log4jBootstrap.getClasspathUrls());
classpathUrls.addAll(addServerLauncherLibJarsToClasspath());
URLClassLoader mirthLauncherClassLoader = new URLClassLoader(classpathUrls.toArray(new URL[classpathUrls.size()]), Thread.currentThread().getContextClassLoader());
Thread.currentThread().setContextClassLoader(mirthLauncherClassLoader);
Expand Down
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
// SPDX-License-Identifier: MPL-2.0
// SPDX-FileCopyrightText: 2026 Mitch Gaffigan <mitch@gaffigan.net>

package com.mirth.connect.server.launcher;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import java.io.File;
import java.net.URL;
import java.nio.file.Files;
import java.util.Arrays;
import java.util.List;

import org.junit.Test;

/** Unit tests for {@link Log4jBootstrap}. */
public class Log4jBootstrapTest {

/** Tests that {@link Log4jBootstrap#getClasspathUrls(File)} correctly resolves Log4j JARs regardless of version. */
@Test
public void testGetClasspathUrlsDoesNotDependOnVersions() throws Exception {
File log4jLibDir = Files.createTempDirectory("log4j").toFile();
log4jLibDir.deleteOnExit();

for (String name : Arrays.asList("log4j-core-99.0.0.jar", "log4j-api-99.0.0.jar", "log4j-1.2-api-99.0.0.jar")) {
File jarFile = new File(log4jLibDir, name);
assertTrue(jarFile.createNewFile());
jarFile.deleteOnExit();
}

List<URL> classpathUrls = Log4jBootstrap.getClasspathUrls(log4jLibDir);

assertEquals(Arrays.asList(
new File(log4jLibDir, "log4j-core-99.0.0.jar").toURI().toURL(),
new File(log4jLibDir, "log4j-api-99.0.0.jar").toURI().toURL(),
new File(log4jLibDir, "log4j-1.2-api-99.0.0.jar").toURI().toURL()), classpathUrls);
}
}
Loading