From cfa3a0fd5940188dea2fa080d0ea9d63ee399968 Mon Sep 17 00:00:00 2001 From: Karson Date: Mon, 23 May 2022 15:19:22 +0800 Subject: [PATCH] Unfiy Map's get and put methods by computeIfAbsent In AuthConfig (#8390) * Unfiy Map's get and put methods by computeIfAbsent In AuthConfig reformat code style reformat code style * reformat code style * reformat issue --- .../java/com/alibaba/nacos/auth/config/AuthConfigs.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/auth/src/main/java/com/alibaba/nacos/auth/config/AuthConfigs.java b/auth/src/main/java/com/alibaba/nacos/auth/config/AuthConfigs.java index 5611a0caa..00ee7ba97 100644 --- a/auth/src/main/java/com/alibaba/nacos/auth/config/AuthConfigs.java +++ b/auth/src/main/java/com/alibaba/nacos/auth/config/AuthConfigs.java @@ -87,11 +87,9 @@ public class AuthConfigs extends Subscriber { for (String each : properties.stringPropertyNames()) { int typeIndex = each.indexOf('.'); String type = each.substring(0, typeIndex); - if (!newProperties.containsKey(type)) { - newProperties.put(type, new Properties()); - } String subKey = each.substring(typeIndex + 1); - newProperties.get(type).setProperty(subKey, properties.getProperty(each)); + newProperties.computeIfAbsent(type, key -> new Properties()) + .setProperty(subKey, properties.getProperty(each)); } authPluginProperties = newProperties; } catch (Exception e) {