Skip to content

Commit b2a271c

Browse files
committed
Merge branch '3.3.x' into 3.4.x
Closes gh-43713
2 parents 8502c80 + c7ef3e3 commit b2a271c

File tree

2 files changed

+37
-23
lines changed

2 files changed

+37
-23
lines changed

spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/logging/LoggingApplicationListenerTests.java

+37-5
Original file line numberDiff line numberDiff line change
@@ -168,13 +168,13 @@ void overrideConfigLocation() {
168168
}
169169

170170
@Test
171-
@ClassPathExclusions("janino-*.jar")
172-
void tryingToUseJaninoWhenItIsNotOnTheClasspathFailsGracefully(CapturedOutput output) {
173-
addPropertiesToEnvironment(this.context, "logging.config=classpath:logback-janino.xml");
171+
void throwableFromInitializeResultsInGracefulFailure(CapturedOutput output) {
172+
System.setProperty(LoggingSystem.SYSTEM_PROPERTY, BrokenInitializationLoggingSystem.class.getName());
173+
multicastEvent(this.listener,
174+
new ApplicationStartingEvent(this.bootstrapContext, new SpringApplication(), NO_ARGS));
174175
assertThatIllegalStateException()
175176
.isThrownBy(() -> this.listener.initialize(this.context.getEnvironment(), this.context.getClassLoader()));
176-
assertThat(output)
177-
.contains("Logging system failed to initialize using configuration from 'classpath:logback-janino.xml'");
177+
assertThat(output).contains("Deliberately broken");
178178
}
179179

180180
@Test
@@ -712,6 +712,38 @@ public void cleanUp() {
712712

713713
}
714714

715+
static final class BrokenInitializationLoggingSystem extends LoggingSystem {
716+
717+
BrokenInitializationLoggingSystem(ClassLoader classLoader) {
718+
719+
}
720+
721+
@Override
722+
public void beforeInitialize() {
723+
}
724+
725+
@Override
726+
public void initialize(LoggingInitializationContext initializationContext, String configLocation,
727+
LogFile logFile) {
728+
throw new Error("Deliberately broken");
729+
}
730+
731+
@Override
732+
public void setLogLevel(String loggerName, LogLevel level) {
733+
}
734+
735+
@Override
736+
public List<LoggerConfiguration> getLoggerConfigurations() {
737+
return null;
738+
}
739+
740+
@Override
741+
public LoggerConfiguration getLoggerConfiguration(String loggerName) {
742+
return null;
743+
}
744+
745+
}
746+
715747
@Configuration
716748
@Import(WebServerStyleLifecycle.class)
717749
static class TestConfiguration {

spring-boot-project/spring-boot/src/test/resources/logback-janino.xml

-18
This file was deleted.

0 commit comments

Comments
 (0)