24
24
import java .util .LinkedHashMap ;
25
25
import java .util .List ;
26
26
import java .util .Map ;
27
- import java .util .Set ;
28
27
import java .util .logging .Handler ;
29
28
import java .util .logging .Level ;
30
29
43
42
import org .apache .logging .log4j .core .util .ShutdownCallbackRegistry ;
44
43
import org .apache .logging .log4j .jul .Log4jBridgeHandler ;
45
44
import org .apache .logging .log4j .util .PropertiesUtil ;
46
- import org .apache .logging .log4j .util .PropertySource ;
47
45
import org .junit .jupiter .api .AfterEach ;
48
46
import org .junit .jupiter .api .BeforeEach ;
49
47
import org .junit .jupiter .api .Test ;
64
62
import org .springframework .boot .testsupport .system .OutputCaptureExtension ;
65
63
import org .springframework .core .env .Environment ;
66
64
import org .springframework .mock .env .MockEnvironment ;
67
- import org .springframework .test .util .ReflectionTestUtils ;
68
65
import org .springframework .util .ClassUtils ;
69
66
import org .springframework .util .StringUtils ;
70
67
@@ -110,7 +107,6 @@ void setup() {
110
107
this .configuration = loggerContext .getConfiguration ();
111
108
this .loggingSystem .cleanUp ();
112
109
this .logger = LogManager .getLogger (getClass ());
113
- cleanUpPropertySources ();
114
110
}
115
111
116
112
@ AfterEach
@@ -119,19 +115,9 @@ void cleanUp() {
119
115
LoggerContext loggerContext = (LoggerContext ) LogManager .getContext (false );
120
116
loggerContext .stop ();
121
117
loggerContext .start (((Reconfigurable ) this .configuration ).reconfigure ());
122
- cleanUpPropertySources ();
123
118
PluginRegistry .getInstance ().clear ();
124
119
}
125
120
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
-
135
121
@ Test
136
122
void noFile (CapturedOutput output ) {
137
123
this .loggingSystem .beforeInitialize ();
0 commit comments