Skip to content

Commit 4a7c757

Browse files
committed
Merge branch '3.2.x' into 3.3.x
Closes gh-42989
2 parents bffde82 + 8f72f03 commit 4a7c757

File tree

5 files changed

+28
-12
lines changed

5 files changed

+28
-12
lines changed

spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/configuration/ResolvedDockerHost.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 the original author or authors.
2+
* Copyright 2012-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/docker/configuration/ResolvedDockerHostTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 the original author or authors.
2+
* Copyright 2012-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/logback/LogbackLoggingSystem.java

+3-8
Original file line numberDiff line numberDiff line change
@@ -291,14 +291,9 @@ private void reportConfigurationErrorsIfNecessary(LoggerContext loggerContext) {
291291

292292
private void configureByResourceUrl(LoggingInitializationContext initializationContext, LoggerContext loggerContext,
293293
URL url) throws JoranException {
294-
if (url.getPath().endsWith(".xml")) {
295-
JoranConfigurator configurator = new SpringBootJoranConfigurator(initializationContext);
296-
configurator.setContext(loggerContext);
297-
configurator.doConfigure(url);
298-
}
299-
else {
300-
throw new IllegalArgumentException("Unsupported file extension in '" + url + "'. Only .xml is supported");
301-
}
294+
JoranConfigurator configurator = new SpringBootJoranConfigurator(initializationContext);
295+
configurator.setContext(loggerContext);
296+
configurator.doConfigure(url);
302297
}
303298

304299
private void stopAndReset(LoggerContext loggerContext) {

spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/logback/LogbackLoggingSystemTests.java

+12-2
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import ch.qos.logback.classic.spi.LoggerContextListener;
3838
import ch.qos.logback.core.ConsoleAppender;
3939
import ch.qos.logback.core.encoder.LayoutWrappingEncoder;
40+
import ch.qos.logback.core.joran.spi.JoranException;
4041
import ch.qos.logback.core.rolling.RollingFileAppender;
4142
import ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy;
4243
import ch.qos.logback.core.util.DynamicClassLoadingException;
@@ -848,8 +849,17 @@ void whenConfigLocationIsNotXmlThenIllegalArgumentExceptionShouldBeThrown() {
848849
assertThatIllegalStateException()
849850
.isThrownBy(() -> initialize(this.initializationContext, "classpath:logback-invalid-format.txt",
850851
getLogFile(tmpDir() + "/tmp.log", null)))
851-
.satisfies((ex) -> assertThat(ex.getCause()).isInstanceOf(IllegalArgumentException.class)
852-
.hasMessageStartingWith("Unsupported file extension"));
852+
.satisfies((ex) -> assertThat(ex.getCause()).isInstanceOf(JoranException.class)
853+
.hasMessageStartingWith("Problem parsing XML document. See previously reported errors"));
854+
}
855+
856+
@Test
857+
void whenConfigLocationIsXmlFileWithoutExtensionShouldWork(CapturedOutput output) {
858+
this.loggingSystem.beforeInitialize();
859+
initialize(this.initializationContext, "classpath:logback-without-extension",
860+
getLogFile(tmpDir() + "/tmp.log", null));
861+
this.logger.info("No extension and works!");
862+
assertThat(output.toString()).contains("No extension and works!");
853863
}
854864

855865
@Test
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<configuration>
3+
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
4+
<encoder>
5+
<pattern>%msg</pattern>
6+
</encoder>
7+
</appender>
8+
<root level="INFO">
9+
<appender-ref ref="CONSOLE" />
10+
</root>
11+
</configuration>

0 commit comments

Comments
 (0)