From 8a454581d805a2860085fad3f1e3ef983e7056ae Mon Sep 17 00:00:00 2001 From: kanghailin <1227734668@qq.com> Date: Fri, 21 Apr 2023 17:23:34 +0800 Subject: [PATCH] optimize code in RouteTable --- .../src/main/java/com/alipay/sofa/jraft/RouteTable.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/jraft-core/src/main/java/com/alipay/sofa/jraft/RouteTable.java b/jraft-core/src/main/java/com/alipay/sofa/jraft/RouteTable.java index 1d37e6193..99a2e936b 100644 --- a/jraft-core/src/main/java/com/alipay/sofa/jraft/RouteTable.java +++ b/jraft-core/src/main/java/com/alipay/sofa/jraft/RouteTable.java @@ -86,11 +86,7 @@ public boolean updateConfiguration(final String groupId, final Configuration con private GroupConf getOrCreateGroupConf(final String groupId) { GroupConf gc = this.groupConfTable.get(groupId); if (gc == null) { - gc = new GroupConf(); - final GroupConf old = this.groupConfTable.putIfAbsent(groupId, gc); - if (old != null) { - gc = old; - } + return this.groupConfTable.computeIfAbsent(groupId, key -> new GroupConf()); } return gc; }