Skip to content

Commit 552c145

Browse files
committed
Improve null-safety of core/spring-boot
See gh-46926
1 parent e70edce commit 552c145

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

core/spring-boot/src/main/java/org/springframework/boot/context/logging/LoggingApplicationListener.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ private void bindLoggerGroups(ConfigurableEnvironment environment) {
381381
* @since 2.2.0
382382
*/
383383
protected void initializeSpringBootLogging(LoggingSystem system, LogLevel springBootLogging) {
384-
BiConsumer<String, LogLevel> configurer = getLogLevelConfigurer(system);
384+
BiConsumer<String, @Nullable LogLevel> configurer = getLogLevelConfigurer(system);
385385
SPRING_BOOT_LOGGING_LOGGERS.getOrDefault(springBootLogging, Collections.emptyList())
386386
.forEach((name) -> configureLogLevel(name, springBootLogging, configurer));
387387
}
@@ -393,13 +393,13 @@ protected void initializeSpringBootLogging(LoggingSystem system, LogLevel spring
393393
* @since 2.2.0
394394
*/
395395
protected void setLogLevels(LoggingSystem system, ConfigurableEnvironment environment) {
396-
BiConsumer<String, LogLevel> customizer = getLogLevelConfigurer(system);
396+
BiConsumer<String, @Nullable LogLevel> customizer = getLogLevelConfigurer(system);
397397
Binder binder = Binder.get(environment);
398398
Map<String, LogLevel> levels = binder.bind(LOGGING_LEVEL, STRING_LOGLEVEL_MAP).orElseGet(Collections::emptyMap);
399399
levels.forEach((name, level) -> configureLogLevel(name, level, customizer));
400400
}
401401

402-
private void configureLogLevel(String name, LogLevel level, BiConsumer<String, LogLevel> configurer) {
402+
private void configureLogLevel(String name, LogLevel level, BiConsumer<String, @Nullable LogLevel> configurer) {
403403
if (this.loggerGroups != null) {
404404
LoggerGroup group = this.loggerGroups.get(name);
405405
if (group != null && group.hasMembers()) {
@@ -410,7 +410,7 @@ private void configureLogLevel(String name, LogLevel level, BiConsumer<String, L
410410
configurer.accept(name, level);
411411
}
412412

413-
private BiConsumer<String, LogLevel> getLogLevelConfigurer(LoggingSystem system) {
413+
private BiConsumer<String, @Nullable LogLevel> getLogLevelConfigurer(LoggingSystem system) {
414414
return (name, level) -> {
415415
try {
416416
name = name.equalsIgnoreCase(LoggingSystem.ROOT_LOGGER_NAME) ? null : name;

core/spring-boot/src/main/java/org/springframework/boot/logging/LoggerGroup.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public boolean hasMembers() {
5959
return this.configuredLevel;
6060
}
6161

62-
public void configureLogLevel(LogLevel level, BiConsumer<String, LogLevel> configurer) {
62+
public void configureLogLevel(@Nullable LogLevel level, BiConsumer<String, @Nullable LogLevel> configurer) {
6363
this.configuredLevel = level;
6464
this.members.forEach((name) -> configurer.accept(name, level));
6565
}

0 commit comments

Comments
 (0)