Skip to content

Commit 45a24b8

Browse files
committed
Upgrade to Log4j 2.9.1
This commit uppgrade our Log4j dependency to 2.9.1. It also modifies ModifiedClassPathRunner so that log4j-*.jar jars are always excluded from the class path when using the runner. This is necessary due to a change in Log4j [1] which makes assumptions about the class loader hierarchy that do not hold true when using the modified class path runner. Specifically, it assumes that the system class loader should always be used to load providers. This is exactly what we don't want to happen when using the modified class path runner as it breaks the filtering of the class path and leads to Log4j classes being loaded from both the system class loader and the filtering class loader. Closes gh-10407 [1] apache/logging-log4j2@9422ca7
1 parent 3bd5d90 commit 45a24b8

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

spring-boot-dependencies/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@
131131
<junit-platform.version>1.0.0</junit-platform.version>
132132
<lettuce.version>5.0.0.RC2</lettuce.version>
133133
<liquibase.version>3.5.3</liquibase.version>
134-
<log4j2.version>2.9.0</log4j2.version>
134+
<log4j2.version>2.9.1</log4j2.version>
135135
<logback.version>1.2.3</logback.version>
136136
<lombok.version>1.16.18</lombok.version>
137137
<mariadb.version>2.1.1</mariadb.version>

spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/runner/classpath/ModifiedClassPathRunner.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,10 +216,13 @@ private static final class ClassPathEntryFilter {
216216
private final AntPathMatcher matcher = new AntPathMatcher();
217217

218218
private ClassPathEntryFilter(Class<?> testClass) throws Exception {
219+
this.exclusions = new ArrayList<>();
220+
this.exclusions.add("log4j-*.jar");
219221
ClassPathExclusions exclusions = AnnotationUtils.findAnnotation(testClass,
220222
ClassPathExclusions.class);
221-
this.exclusions = exclusions == null ? Collections.<String>emptyList()
222-
: Arrays.asList(exclusions.value());
223+
if (exclusions != null) {
224+
this.exclusions.addAll(Arrays.asList(exclusions.value()));
225+
}
223226
}
224227

225228
private boolean isExcluded(URL url) throws Exception {

0 commit comments

Comments
 (0)