Skip to content

Commit 4d009c2

Browse files
committed
[KYUUBI #3353] Backport HIVE-21899 - Utils.getCanonicalHostName() may return IP address depending on DNS infra
### _Why are the changes needed?_ Fix #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 85a25c8 [Cheng Pan] Backport HIVE-21899 - Utils.getCanonicalHostName() may return IP address depending on DNS infra Authored-by: Cheng Pan <chengpan@apache.org> Signed-off-by: Cheng Pan <chengpan@apache.org> (cherry picked from commit 5a32fcb) Signed-off-by: Cheng Pan <chengpan@apache.org>
1 parent 340893f commit 4d009c2

File tree

1 file changed

+7
-1
lines changed
  • kyuubi-hive-jdbc/src/main/java/org/apache/kyuubi/jdbc/hive

1 file changed

+7
-1
lines changed

kyuubi-hive-jdbc/src/main/java/org/apache/kyuubi/jdbc/hive/Utils.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,13 @@ public static String parsePropertyFromUrl(final String url, final String key) {
442442
*/
443443
public static String getCanonicalHostName(String hostName) {
444444
try {
445-
return InetAddress.getByName(hostName).getCanonicalHostName();
445+
InetAddress addr = InetAddress.getByName(hostName);
446+
String canonicalHostname = addr.getCanonicalHostName();
447+
if (canonicalHostname.equals(addr.getHostAddress())) {
448+
return hostName;
449+
} else {
450+
return canonicalHostname;
451+
}
446452
} catch (UnknownHostException exception) {
447453
LOG.warn("Could not retrieve canonical hostname for " + hostName, exception);
448454
return hostName;

0 commit comments

Comments
 (0)