Skip to content

Commit f09d645

Browse files
mchessnicoll
authored andcommitted
Upgrade to Logback 1.5.7
See gh-41885
1 parent d4762ec commit f09d645

File tree

6 files changed

+20
-4
lines changed

6 files changed

+20
-4
lines changed

spring-boot-project/spring-boot-dependencies/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1121,7 +1121,7 @@ bom {
11211121
releaseNotes("https://github.com/apache/logging-log4j2/releases/tag/rel%2F{version}")
11221122
}
11231123
}
1124-
library("Logback", "1.5.6") {
1124+
library("Logback", "1.5.7") {
11251125
group("ch.qos.logback") {
11261126
modules = [
11271127
"logback-classic",

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package org.springframework.boot.logging.logback;
1818

1919
import java.nio.charset.Charset;
20+
import java.util.concurrent.locks.ReentrantLock;
2021

2122
import ch.qos.logback.classic.Level;
2223
import ch.qos.logback.classic.encoder.PatternLayoutEncoder;
@@ -44,6 +45,7 @@
4445
* @author Robert Thornton
4546
* @author Scott Frederick
4647
* @author Jonatan Ivanov
48+
* @author Mark Chesney
4749
*/
4850
class DefaultLogbackConfiguration {
4951

@@ -54,7 +56,9 @@ class DefaultLogbackConfiguration {
5456
}
5557

5658
void apply(LogbackConfigurator config) {
57-
synchronized (config.getConfigurationLock()) {
59+
ReentrantLock lock = config.getConfigurationLock();
60+
lock.lock();
61+
try {
5862
defaults(config);
5963
Appender<ILoggingEvent> consoleAppender = consoleAppender(config);
6064
if (this.logFile != null) {
@@ -65,6 +69,9 @@ void apply(LogbackConfigurator config) {
6569
config.root(Level.INFO, consoleAppender);
6670
}
6771
}
72+
finally {
73+
lock.unlock();
74+
}
6875
}
6976

7077
private void defaults(LogbackConfigurator config) {

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import java.util.HashMap;
2020
import java.util.Map;
21+
import java.util.concurrent.locks.ReentrantLock;
2122

2223
import ch.qos.logback.classic.Level;
2324
import ch.qos.logback.classic.Logger;
@@ -35,6 +36,7 @@
3536
* Allows programmatic configuration of logback which is usually faster than parsing XML.
3637
*
3738
* @author Phillip Webb
39+
* @author Mark Chesney
3840
*/
3941
class LogbackConfigurator {
4042

@@ -49,7 +51,7 @@ LoggerContext getContext() {
4951
return this.context;
5052
}
5153

52-
Object getConfigurationLock() {
54+
ReentrantLock getConfigurationLock() {
5355
return this.context.getConfigurationLock();
5456
}
5557

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
* control over how and when the logging system is initialized.
3737
*
3838
* @author Andy Wilkinson
39+
* @author Mark Chesney
3940
*/
4041
class LogbackLoggingSystemParallelInitializationTests {
4142

@@ -45,6 +46,7 @@ class LogbackLoggingSystemParallelInitializationTests {
4546
void cleanUp() {
4647
this.loggingSystem.cleanUp();
4748
((LoggerContext) LoggerFactory.getILoggerFactory()).stop();
49+
((LoggerContext) LoggerFactory.getILoggerFactory()).reset();
4850
}
4951

5052
@Test

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
import org.junit.jupiter.api.BeforeEach;
4545
import org.junit.jupiter.api.Test;
4646
import org.junit.jupiter.api.extension.ExtendWith;
47+
import org.mockito.junit.jupiter.MockitoExtension;
4748
import org.slf4j.ILoggerFactory;
4849
import org.slf4j.LoggerFactory;
4950
import org.slf4j.MDC;
@@ -93,8 +94,9 @@
9394
* @author Scott Frederick
9495
* @author Jonatan Ivanov
9596
* @author Moritz Halbritter
97+
* @author Mark Chesney
9698
*/
97-
@ExtendWith(OutputCaptureExtension.class)
99+
@ExtendWith({ MockitoExtension.class, OutputCaptureExtension.class })
98100
@ClassPathExclusions({ "log4j-core-*.jar", "log4j-api-*.jar" })
99101
class LogbackLoggingSystemTests extends AbstractLoggingSystemTests {
100102

@@ -128,6 +130,7 @@ void cleanUp() {
128130
System.getProperties().keySet().retainAll(this.systemPropertyNames);
129131
this.loggingSystem.cleanUp();
130132
((LoggerContext) LoggerFactory.getILoggerFactory()).stop();
133+
((LoggerContext) LoggerFactory.getILoggerFactory()).reset();
131134
}
132135

133136
@Test

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
* @author Phillip Webb
4444
* @author Eddú Meléndez
4545
* @author Stephane Nicoll
46+
* @author Mark Chesney
4647
*/
4748
@ExtendWith(OutputCaptureExtension.class)
4849
class SpringBootJoranConfiguratorTests {
@@ -72,6 +73,7 @@ void setup(CapturedOutput output) {
7273
@AfterEach
7374
void reset() {
7475
this.context.stop();
76+
this.context.reset();
7577
new BasicConfigurator().configure((LoggerContext) LoggerFactory.getILoggerFactory());
7678
}
7779

0 commit comments

Comments
 (0)