From 2b29bea55c25dcdd31783f96ed2410189df87e2b Mon Sep 17 00:00:00 2001 From: Gang Zhang Date: Mon, 19 Aug 2019 23:01:37 +0800 Subject: [PATCH] Use putIfAbsent() instead of containsKey See gh-17913 --- .../boot/logging/AbstractLoggingSystem.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/AbstractLoggingSystem.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/AbstractLoggingSystem.java index 52a237c9b69..48be4c91f46 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/AbstractLoggingSystem.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/AbstractLoggingSystem.java @@ -194,12 +194,8 @@ public abstract class AbstractLoggingSystem extends LoggingSystem { } public void map(LogLevel system, T nativeLevel) { - if (!this.systemToNative.containsKey(system)) { - this.systemToNative.put(system, nativeLevel); - } - if (!this.nativeToSystem.containsKey(nativeLevel)) { - this.nativeToSystem.put(nativeLevel, system); - } + this.systemToNative.putIfAbsent(system, nativeLevel); + this.nativeToSystem.putIfAbsent(nativeLevel, system); } public LogLevel convertNativeToSystem(T level) {