diff --git a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/resolver/order/HashResolver.java b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/resolver/order/HashResolver.java index 4034a46a65..455a3edb87 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/resolver/order/HashResolver.java +++ b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/resolver/order/HashResolver.java @@ -98,13 +98,9 @@ public String getFirstNamespace(final String path, final PathLocation loc) { * namespaces using the provided set of namespace identifiers. */ private ConsistentHashRing getHashResolver(final Set namespaces) { - int hash = namespaces.hashCode(); - ConsistentHashRing resolver = this.hashResolverMap.get(hash); - if (resolver == null) { - resolver = new ConsistentHashRing(namespaces); - this.hashResolverMap.put(hash, resolver); - } - return resolver; + final int hash = namespaces.hashCode(); + return this.hashResolverMap.computeIfAbsent(hash, + k -> new ConsistentHashRing(namespaces)); } /**