You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kyuubi.apache.org by ch...@apache.org on 2022/08/26 07:33:04 UTC

[incubator-kyuubi] branch master updated: [KYUUBI #3353] Backport HIVE-21899 - Utils.getCanonicalHostName() may return IP address depending on DNS infra

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

chengpan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-kyuubi.git


The following commit(s) were added to refs/heads/master by this push:
     new 5a32fcb70 [KYUUBI #3353] Backport HIVE-21899 - Utils.getCanonicalHostName() may return IP address depending on DNS infra
5a32fcb70 is described below

commit 5a32fcb70da36f119add8baabdd62f39618dc472
Author: Cheng Pan <ch...@apache.org>
AuthorDate: Fri Aug 26 15:32:53 2022 +0800

    [KYUUBI #3353] Backport HIVE-21899 - Utils.getCanonicalHostName() may return IP address depending on DNS infra
    
    ### _Why are the changes needed?_
    
    Fix https://github.com/apache/incubator-kyuubi/issues/3352
    
    It's a regression issue, that came from upgrading from Hive 2.3 to Hive 3.1.
    
    ### _How was this patch tested?_
    - [ ] Add some test cases that check the changes thoroughly including negative and positive cases if possible
    
    - [ ] Add screenshots for manual tests if appropriate
    
    - [x] [Run test](https://kyuubi.apache.org/docs/latest/develop_tools/testing.html#running-tests) locally before make a pull request
    
    Closes #3353 from pan3793/HIVE-21899.
    
    Closes #3353
    
    85a25c8e [Cheng Pan] Backport HIVE-21899 - Utils.getCanonicalHostName() may return IP address depending on DNS infra
    
    Authored-by: Cheng Pan <ch...@apache.org>
    Signed-off-by: Cheng Pan <ch...@apache.org>
---
 .../src/main/java/org/apache/kyuubi/jdbc/hive/Utils.java          | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/kyuubi-hive-jdbc/src/main/java/org/apache/kyuubi/jdbc/hive/Utils.java b/kyuubi-hive-jdbc/src/main/java/org/apache/kyuubi/jdbc/hive/Utils.java
index 307c7c53d..5309cdfc6 100644
--- a/kyuubi-hive-jdbc/src/main/java/org/apache/kyuubi/jdbc/hive/Utils.java
+++ b/kyuubi-hive-jdbc/src/main/java/org/apache/kyuubi/jdbc/hive/Utils.java
@@ -442,7 +442,13 @@ public class Utils {
    */
   public static String getCanonicalHostName(String hostName) {
     try {
-      return InetAddress.getByName(hostName).getCanonicalHostName();
+      InetAddress addr = InetAddress.getByName(hostName);
+      String canonicalHostname = addr.getCanonicalHostName();
+      if (canonicalHostname.equals(addr.getHostAddress())) {
+        return hostName;
+      } else {
+        return canonicalHostname;
+      }
     } catch (UnknownHostException exception) {
       LOG.warn("Could not retrieve canonical hostname for " + hostName, exception);
       return hostName;