Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 72
Fix log4j bad versions#389
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
mgaffigan
merged 3 commits into
OpenIntegrationEngine:main
from
mgaffigan:fix/junit-bad-versionsJul 28, 2026
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41 server/src/main/java/com/mirth/connect/server/launcher/Log4jBootstrap.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff 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; | ||
| } | ||
| } |
7 changes: 1 addition & 6 deletions
7 server/src/main/java/com/mirth/connect/server/launcher/MirthLauncher.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39 server/src/test/java/com/mirth/connect/server/launcher/Log4jBootstrapTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff 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); | ||
| } | ||
| } |
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.