Skip to content

Commit 721597b

Browse files
authored
GEODE-10544: Upgrade Apache Log4j from version 2.17.2 to 2.25.3 to remediate security vulnerability CVE-2025-68161. (#7978)
* GEODE-10544: Upgrade Log4j from 2.17.2 to 2.25.3 - Updated Log4j version to 2.25.3 in dependency constraints - Added GraalVM annotation processor configuration for geode-log4j - Migrated test dependencies from log4j-core::tests to log4j-core-test artifact - Updated 20 integration test files to use new package structure: * org.apache.logging.log4j.junit -> org.apache.logging.log4j.core.test.junit * org.apache.logging.log4j.test.appender -> org.apache.logging.log4j.core.test.appender - Suppressed deprecation warning for Message.getFormat() method - Added exclusions for Maven transitive dependencies to resolve Guava conflicts - All quality checks pass: build, spotlessCheck, rat, checkPom, japicmp * Fix integration test failures for Log4j 2.25.3 - Exclude JUnit 5.13.2 from log4j-core-test (conflicts with project's 5.8.2) - Exclude assertj-core 3.27.3 from log4j-core-test (conflicts with Geode's 3.22.0) - Add detailed comments explaining the exclusions This fixes the 26 integration test failures that occurred after upgrading Log4j from 2.17.2 to 2.25.3. The failures were caused by version conflicts in transitive dependencies brought in by log4j-core-test. Tested: ./gradlew :geode-log4j:integrationTest passes successfully * Update build.gradle comments to explain all 5 dependency exclusions - Document maven-core exclusion (Guava conflict) - Document log4j-api-test exclusion (brings JUnit 5.13.2) - Document junit.jupiter/platform exclusions (version mismatch with 5.8.2) - Clarify all exclusions are required for support/1.15 branch
1 parent efd7796 commit 721597b

23 files changed

Lines changed: 54 additions & 29 deletions

build-tools/geode-dependency-management/src/main/groovy/org/apache/geode/gradle/plugins/DependencyConstraints.groovy

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class DependencyConstraints {
3939
deps.put("fastutil.version", "8.5.8")
4040
deps.put("javax.transaction-api.version", "1.3")
4141
deps.put("jgroups.version", "3.6.20.Final")
42-
deps.put("log4j.version", "2.17.2")
42+
deps.put("log4j.version", "2.25.3")
4343
deps.put("micrometer.version", "1.9.1")
4444
deps.put("shiro.version", "1.13.0")
4545
deps.put("slf4j-api.version", "1.7.32")
@@ -215,6 +215,7 @@ class DependencyConstraints {
215215
dependencySet(group: 'org.apache.logging.log4j', version: get('log4j.version')) {
216216
entry('log4j-api')
217217
entry('log4j-core')
218+
entry('log4j-core-test')
218219
entry('log4j-jcl')
219220
entry('log4j-jul')
220221
entry('log4j-slf4j-impl')

geode-log4j/build.gradle

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ plugins {
2121
id 'jmh'
2222
}
2323

24+
// Suppress Log4j 2.25.3 GraalVM annotation processor warning
25+
tasks.withType(JavaCompile) {
26+
options.compilerArgs.addAll([
27+
'-Alog4j.graalvm.groupId=org.apache.geode',
28+
'-Alog4j.graalvm.artifactId=geode-log4j'
29+
])
30+
}
31+
2432
dependencies {
2533
api(platform(project(':boms:geode-all-bom')))
2634

@@ -63,8 +71,23 @@ dependencies {
6371
exclude module: 'geode-core'
6472
}
6573
integrationTestImplementation('junit:junit')
66-
integrationTestImplementation('org.apache.logging.log4j:log4j-core::tests')
67-
integrationTestImplementation('org.apache.logging.log4j:log4j-core::test-sources')
74+
// Log4j 2.20.0+ moved test utilities to log4j-core-test with new package names:
75+
// org.apache.logging.log4j.junit → org.apache.logging.log4j.core.test.junit
76+
// org.apache.logging.log4j.test → org.apache.logging.log4j.core.test
77+
// log4j-core-test 2.25.3 requires the following exclusions:
78+
// - assertj-core 3.27.3: conflicts with Geode's 3.22.0 custom assertions
79+
// (NoSuchMethodError: CommonValidations.failIfEmptySinceActualIsNotEmpty)
80+
// - maven-core 3.9.10: causes Gradle dependency resolution conflict with Guava
81+
// - log4j-api-test: brings JUnit 5.13.2 transitively
82+
// - junit.jupiter/platform 5.13.2: conflicts with project's JUnit 5.8.2
83+
// (JUnitException: OutputDirectoryProvider not available due to version mismatch)
84+
integrationTestImplementation('org.apache.logging.log4j:log4j-core-test') {
85+
exclude group: 'org.apache.maven'
86+
exclude group: 'org.apache.logging.log4j', module: 'log4j-api-test'
87+
exclude group: 'org.assertj', module: 'assertj-core'
88+
exclude group: 'org.junit.jupiter'
89+
exclude group: 'org.junit.platform'
90+
}
6891
integrationTestImplementation('org.assertj:assertj-core')
6992

7093
distributedTestImplementation(project(':geode-junit')) {

geode-log4j/src/integrationTest/java/org/apache/geode/alerting/log4j/internal/impl/AlertAppenderIntegrationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
import org.apache.logging.log4j.Level;
3737
import org.apache.logging.log4j.Logger;
3838
import org.apache.logging.log4j.core.LogEvent;
39-
import org.apache.logging.log4j.junit.LoggerContextRule;
39+
import org.apache.logging.log4j.core.test.junit.LoggerContextRule;
4040
import org.junit.After;
4141
import org.junit.Before;
4242
import org.junit.BeforeClass;

geode-log4j/src/integrationTest/java/org/apache/geode/logging/log4j/internal/impl/BothLogWriterAppendersIntegrationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import java.net.URL;
2727

2828
import org.apache.logging.log4j.Logger;
29-
import org.apache.logging.log4j.junit.LoggerContextRule;
29+
import org.apache.logging.log4j.core.test.junit.LoggerContextRule;
3030
import org.junit.After;
3131
import org.junit.Before;
3232
import org.junit.BeforeClass;

geode-log4j/src/integrationTest/java/org/apache/geode/logging/log4j/internal/impl/CacheWithCustomLogConfigIntegrationTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
import org.apache.logging.log4j.Level;
3131
import org.apache.logging.log4j.Logger;
3232
import org.apache.logging.log4j.core.LogEvent;
33-
import org.apache.logging.log4j.junit.LoggerContextRule;
34-
import org.apache.logging.log4j.test.appender.ListAppender;
33+
import org.apache.logging.log4j.core.test.appender.ListAppender;
34+
import org.apache.logging.log4j.core.test.junit.LoggerContextRule;
3535
import org.junit.After;
3636
import org.junit.Before;
3737
import org.junit.BeforeClass;

geode-log4j/src/integrationTest/java/org/apache/geode/logging/log4j/internal/impl/ConfigurationWithLogLevelChangesIntegrationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
import org.apache.logging.log4j.Level;
3030
import org.apache.logging.log4j.Logger;
3131
import org.apache.logging.log4j.core.LogEvent;
32-
import org.apache.logging.log4j.junit.LoggerContextRule;
32+
import org.apache.logging.log4j.core.test.junit.LoggerContextRule;
3333
import org.junit.After;
3434
import org.junit.Before;
3535
import org.junit.BeforeClass;

geode-log4j/src/integrationTest/java/org/apache/geode/logging/log4j/internal/impl/ConsoleAppenderWithLoggerContextRuleIntegrationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import org.apache.logging.log4j.core.appender.ConsoleAppender;
2929
import org.apache.logging.log4j.core.appender.DefaultErrorHandler;
3030
import org.apache.logging.log4j.core.appender.OutputStreamManager;
31-
import org.apache.logging.log4j.junit.LoggerContextRule;
31+
import org.apache.logging.log4j.core.test.junit.LoggerContextRule;
3232
import org.junit.Before;
3333
import org.junit.BeforeClass;
3434
import org.junit.ClassRule;

geode-log4j/src/integrationTest/java/org/apache/geode/logging/log4j/internal/impl/DistributedSystemWithBothLogWriterAppendersIntegrationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import java.util.Properties;
2828

2929
import org.apache.logging.log4j.Logger;
30-
import org.apache.logging.log4j.junit.LoggerContextRule;
30+
import org.apache.logging.log4j.core.test.junit.LoggerContextRule;
3131
import org.junit.After;
3232
import org.junit.Before;
3333
import org.junit.BeforeClass;

geode-log4j/src/integrationTest/java/org/apache/geode/logging/log4j/internal/impl/DistributedSystemWithLogLevelChangesIntegrationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
import org.apache.logging.log4j.Level;
3232
import org.apache.logging.log4j.Logger;
3333
import org.apache.logging.log4j.core.LogEvent;
34-
import org.apache.logging.log4j.junit.LoggerContextRule;
34+
import org.apache.logging.log4j.core.test.junit.LoggerContextRule;
3535
import org.junit.After;
3636
import org.junit.Before;
3737
import org.junit.BeforeClass;

geode-log4j/src/integrationTest/java/org/apache/geode/logging/log4j/internal/impl/FastLoggerIntegrationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
import org.apache.logging.log4j.Logger;
3131
import org.apache.logging.log4j.Marker;
3232
import org.apache.logging.log4j.MarkerManager;
33-
import org.apache.logging.log4j.junit.LoggerContextRule;
33+
import org.apache.logging.log4j.core.test.junit.LoggerContextRule;
3434
import org.junit.After;
3535
import org.junit.Before;
3636
import org.junit.BeforeClass;

0 commit comments

Comments
 (0)