mirror of
https://github.com/alibaba/DataX.git
synced 2025-05-02 17:40:28 +08:00
经测试还有查阅资料 getHostName() 有时候会有获取hostname错误的情况,
用getCanonicalHostName() 可以避免这种情况
This commit is contained in:
parent
643b6e9c64
commit
a571e1c2a7
@ -22,7 +22,8 @@ public class HostUtils {
|
|||||||
try {
|
try {
|
||||||
InetAddress addr = InetAddress.getLocalHost();
|
InetAddress addr = InetAddress.getLocalHost();
|
||||||
ip = addr.getHostAddress();
|
ip = addr.getHostAddress();
|
||||||
hostname = addr.getHostName();
|
// hostname = addr.getHostName();
|
||||||
|
hostname = addr.getCanonicalHostName();
|
||||||
} catch (UnknownHostException e) {
|
} catch (UnknownHostException e) {
|
||||||
log.error("Can't find out address: " + e.getMessage());
|
log.error("Can't find out address: " + e.getMessage());
|
||||||
ip = "UNKNOWN";
|
ip = "UNKNOWN";
|
||||||
|
Loading…
Reference in New Issue
Block a user