Skip to content

Commit 269f18c

Browse files
committed
Merge branch '3.3.x'
Closes gh-42990
2 parents ba56bbe + 4a7c757 commit 269f18c

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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -295,14 +295,9 @@ private void reportConfigurationErrorsIfNecessary(LoggerContext loggerContext) {
295295

296296
private void configureByResourceUrl(LoggingInitializationContext initializationContext, LoggerContext loggerContext,
297297
URL url) throws JoranException {
298-
if (url.getPath().endsWith(".xml")) {
299-
JoranConfigurator configurator = new SpringBootJoranConfigurator(initializationContext);
300-
configurator.setContext(loggerContext);
301-
configurator.doConfigure(url);
302-
}
303-
else {
304-
throw new IllegalArgumentException("Unsupported file extension in '" + url + "'. Only .xml is supported");
305-
}
298+
JoranConfigurator configurator = new SpringBootJoranConfigurator(initializationContext);
299+
configurator.setContext(loggerContext);
300+
configurator.doConfigure(url);
306301
}
307302

308303
private void stopAndReset(LoggerContext loggerContext) {

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

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

854864
@Test
Lines changed: 11 additions & 0 deletions
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)