[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 <chengpan@apache.org> Signed-off-by: Cheng Pan <chengpan@apache.org>
This commit is contained in:
parent
1163a76eb3
commit
5a32fcb70d
@ -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;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user