InetAddress.getByName间歇性地因系统错误而失败

时间:2014-06-08 20:43:20

标签: java nslookup

我有一些使用InetAddress.getByName的代码。我不断地得到UnknownHostException

java.net.UnknownHostException: google.com: System error
    at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
    at java.net.InetAddress$1.lookupAllHostAddr(InetAddress.java:901)
    at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1293)
    at java.net.InetAddress.getAllByName0(InetAddress.java:1246)
    at java.net.InetAddress.getAllByName(InetAddress.java:1162)
    at java.net.InetAddress.getAllByName(InetAddress.java:1098)
    at java.net.InetAddress.getByName(InetAddress.java:1048)

执行nslookup google.com工作,故障本身偶尔也会发生。可能导致这种情况的原因是什么?

1 个答案:

答案 0 :(得分:0)

尝试查看official java documentation

  

抛出:       UnknownHostException - 如果找不到主机的IP地址,或者为全局IPv6地址指定了scope_id。