You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by st...@apache.org on 2019/03/07 11:09:12 UTC

[hadoop] branch branch-3.2 updated: HADOOP-16114. NetUtils#canonicalizeHost gives different value for same host.

This is an automated email from the ASF dual-hosted git repository.

stevel pushed a commit to branch branch-3.2
in repository https://gitbox.apache.org/repos/asf/hadoop.git


The following commit(s) were added to refs/heads/branch-3.2 by this push:
     new 451844f  HADOOP-16114. NetUtils#canonicalizeHost gives different value for same host.
451844f is described below

commit 451844fee55d20871ee66498d453ebb4945f48d5
Author: Praveen Krishna <pr...@tutanota.com>
AuthorDate: Thu Mar 7 11:07:55 2019 +0000

    HADOOP-16114. NetUtils#canonicalizeHost gives different value for same host.
    
    Author:    Praveen Krishna <pr...@tutanota.com>
    (cherry picked from commit 2b94e51a8f17548e5ef6af8e1e934a94031bb1dc)
---
 .../hadoop-common/src/main/java/org/apache/hadoop/net/NetUtils.java   | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NetUtils.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NetUtils.java
index 0f9cfc3..6fa0a38 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NetUtils.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NetUtils.java
@@ -288,8 +288,10 @@ public class NetUtils {
     if (fqHost == null) {
       try {
         fqHost = SecurityUtil.getByName(host).getHostName();
-        // slight race condition, but won't hurt
         canonicalizedHostCache.putIfAbsent(host, fqHost);
+        // ensures that we won't return a canonicalized stale (non-cached)
+        // host name for a given host
+        fqHost = canonicalizedHostCache.get(host);
       } catch (UnknownHostException e) {
         fqHost = host;
       }


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org