Mercurial > hg > release > icedtea7-forest-2.3 > jdk
changeset 6113:8dbc6c8923e7
7032247: java/net/InetAddress/GetLocalHostWithSM.java fails if hostname resolves to loopback address
Summary: TESTBUG
Reviewed-by: chegar, alanb
Contributed-by: Eric Wang <yiming.wang@oracle.com>
author | chegar |
---|---|
date | Fri, 07 Sep 2012 14:00:31 +0100 |
parents | 51877c178a00 |
children | 666a4b5ed3b6 |
files | test/java/net/InetAddress/GetLocalHostWithSM.java |
diffstat | 1 files changed, 7 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/test/java/net/InetAddress/GetLocalHostWithSM.java Mon Feb 11 14:37:57 2013 +0000 +++ b/test/java/net/InetAddress/GetLocalHostWithSM.java Fri Sep 07 14:00:31 2012 +0100 @@ -41,14 +41,13 @@ public static void main(String[] args) throws Exception { // try setting the local hostname - try { - System.setProperty("host.name", InetAddress. - getLocalHost(). - getHostName()); - } catch (UnknownHostException e) { - System.out.println("Cannot find the local hostname, " + - "no nameserver entry found"); + InetAddress localHost = InetAddress.getLocalHost(); + if (localHost.isLoopbackAddress()) { + System.err.println("Local host name is resolved into a loopback address. Quit now!"); + return; } + System.setProperty("host.name", localHost. + getHostName()); String policyFileName = System.getProperty("test.src", ".") + "/" + "policy.file"; System.setProperty("java.security.policy", policyFileName); @@ -66,6 +65,7 @@ new MyAction(), null); if (localHost1.equals(localHost2)) { + System.out.println("localHost1 = " + localHost1); throw new RuntimeException("InetAddress.getLocalHost() test " + " fails. localHost2 should be " + " the real address instead of " +