Skip to content

Commit 68d600e

Browse files
committed
Merge pull request #41885 from mches
* pr/41885: Polish "Upgrade to Logback 1.5.7" Upgrade to Logback 1.5.7 Closes gh-41885
2 parents d4762ec + f9d5634 commit 68d600e

File tree

6 files changed

+15
-4
lines changed

6 files changed

+15
-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 & 2 deletions
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.
@@ -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;
@@ -49,7 +50,7 @@ LoggerContext getContext() {
4950
return this.context;
5051
}
5152

52-
Object getConfigurationLock() {
53+
ReentrantLock getConfigurationLock() {
5354
return this.context.getConfigurationLock();
5455
}
5556

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class LogbackLoggingSystemParallelInitializationTests {
4545
void cleanUp() {
4646
this.loggingSystem.cleanUp();
4747
((LoggerContext) LoggerFactory.getILoggerFactory()).stop();
48+
((LoggerContext) LoggerFactory.getILoggerFactory()).reset();
4849
}
4950

5051
@Test

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ void cleanUp() {
128128
System.getProperties().keySet().retainAll(this.systemPropertyNames);
129129
this.loggingSystem.cleanUp();
130130
((LoggerContext) LoggerFactory.getILoggerFactory()).stop();
131+
((LoggerContext) LoggerFactory.getILoggerFactory()).reset();
131132
}
132133

133134
@Test

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ void setup(CapturedOutput output) {
7272
@AfterEach
7373
void reset() {
7474
this.context.stop();
75+
this.context.reset();
7576
new BasicConfigurator().configure((LoggerContext) LoggerFactory.getILoggerFactory());
7677
}
7778

0 commit comments

Comments
 (0)