Skip to content

Commit 74f3f81

Browse files
committed
Remove workaround for LOG4J2-3618
Closes gh-41906
1 parent 080e43e commit 74f3f81

File tree

1 file changed

+0
-14
lines changed

1 file changed

+0
-14
lines changed

spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/log4j2/Log4J2LoggingSystemTests.java

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import java.util.LinkedHashMap;
2525
import java.util.List;
2626
import java.util.Map;
27-
import java.util.Set;
2827
import java.util.logging.Handler;
2928
import java.util.logging.Level;
3029

@@ -43,7 +42,6 @@
4342
import org.apache.logging.log4j.core.util.ShutdownCallbackRegistry;
4443
import org.apache.logging.log4j.jul.Log4jBridgeHandler;
4544
import org.apache.logging.log4j.util.PropertiesUtil;
46-
import org.apache.logging.log4j.util.PropertySource;
4745
import org.junit.jupiter.api.AfterEach;
4846
import org.junit.jupiter.api.BeforeEach;
4947
import org.junit.jupiter.api.Test;
@@ -64,7 +62,6 @@
6462
import org.springframework.boot.testsupport.system.OutputCaptureExtension;
6563
import org.springframework.core.env.Environment;
6664
import org.springframework.mock.env.MockEnvironment;
67-
import org.springframework.test.util.ReflectionTestUtils;
6865
import org.springframework.util.ClassUtils;
6966
import org.springframework.util.StringUtils;
7067

@@ -110,7 +107,6 @@ void setup() {
110107
this.configuration = loggerContext.getConfiguration();
111108
this.loggingSystem.cleanUp();
112109
this.logger = LogManager.getLogger(getClass());
113-
cleanUpPropertySources();
114110
}
115111

116112
@AfterEach
@@ -119,19 +115,9 @@ void cleanUp() {
119115
LoggerContext loggerContext = (LoggerContext) LogManager.getContext(false);
120116
loggerContext.stop();
121117
loggerContext.start(((Reconfigurable) this.configuration).reconfigure());
122-
cleanUpPropertySources();
123118
PluginRegistry.getInstance().clear();
124119
}
125120

126-
@SuppressWarnings("unchecked")
127-
private void cleanUpPropertySources() { // https://issues.apache.org/jira/browse/LOG4J2-3618
128-
PropertiesUtil properties = PropertiesUtil.getProperties();
129-
Object environment = ReflectionTestUtils.getField(properties, "environment");
130-
Set<PropertySource> sources = (Set<PropertySource>) ReflectionTestUtils.getField(environment, "sources");
131-
sources.removeIf((candidate) -> candidate instanceof SpringEnvironmentPropertySource
132-
|| candidate instanceof SpringBootPropertySource);
133-
}
134-
135121
@Test
136122
void noFile(CapturedOutput output) {
137123
this.loggingSystem.beforeInitialize();

0 commit comments

Comments
 (0)