You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@harmony.apache.org by Denis Kishenko <dk...@gmail.com> on 2006/10/19 13:44:21 UTC

[classlib][test] Configuration dependent test of InetAddress.getHostName

I have researched issue H-1664 and found one more difference with RI.
I run simple test on Windows Server 2003 SP1

=================== Test =============
import java.net.InetAddress;
import java.net.UnknownHostException;

public class Test {
    public static void main(String[] args) throws UnknownHostException {
        System.out.println("by name (127.0.0.1) -> " +
InetAddress.getByName("127.0.0.1").getHostName());
        System.out.println("by name (localhost) -> " +
InetAddress.getByName("localhost").getHostName());
        System.out.println("by address -> " +
InetAddress.getByAddress(new byte[]{127, 0, 0, 1}).getHostName());
        System.out.println("localhost -> " + InetAddress.getLocalHost());
    }

}

Windows Server 2003 SP1
=========== RI ==============
    by name (127.0.0.1) -> 127.0.0.1
    by name (localhost) -> localhost
    by address -> 127.0.0.1
    localhost -> nstdrlew21/10.125.122.60

========= Harmony ==========
    by name (127.0.0.1) -> nstdrlew21.ins.intel.com
    by name (localhost) -> localhost
    by address -> nstdrlew21.ins.intel.com
    localhost -> nstdrlew21/10.125.122.60

WinXP
========= Both ===========
by name (127.0.0.1) -> localhost
by name (localhost) -> localhost
by address -> localhost
localhost -> pbwdmkishen/10.125.132.226


Actually Harmony use native call of getnameinfo() to get host name
(which is reasonable IMHO). MSDN says "The getnameinfo function
provides name resolution from an address to the host name".

InetAddressTest.test_getHostName (see H-1664) failed on WinServer
because InetAddress.getByName("127.0.0.1").getHostName() returned
"nstdrlew21.ins.intel.com" while "localhost" expected. So this test
looks like configuration dependent.

I see three possible options
1. Stay test as is. Just keep in mind that on specific configurations
this one fails.
2. Rewrite test to be configuration dependent. Test has to do the same
native call.
3. Exclude localhost checking from test_getHostName.

What do you think about this situation?

-- 
Denis M. Kishenko
Enterprise Solutions Software Division

---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


Re: [classlib][test] Configuration dependent test of InetAddress.getHostName

Posted by Paulex Yang <pa...@gmail.com>.
Denis Kishenko wrote:
> I have researched issue H-1664 and found one more difference with RI.
> I run simple test on Windows Server 2003 SP1
>
> =================== Test =============
> import java.net.InetAddress;
> import java.net.UnknownHostException;
>
> public class Test {
>    public static void main(String[] args) throws UnknownHostException {
>        System.out.println("by name (127.0.0.1) -> " +
> InetAddress.getByName("127.0.0.1").getHostName());
>        System.out.println("by name (localhost) -> " +
> InetAddress.getByName("localhost").getHostName());
>        System.out.println("by address -> " +
> InetAddress.getByAddress(new byte[]{127, 0, 0, 1}).getHostName());
>        System.out.println("localhost -> " + InetAddress.getLocalHost());
>    }
>
> }
>
> Windows Server 2003 SP1
> =========== RI ==============
>    by name (127.0.0.1) -> 127.0.0.1
>    by name (localhost) -> localhost
>    by address -> 127.0.0.1
>    localhost -> nstdrlew21/10.125.122.60
>
> ========= Harmony ==========
>    by name (127.0.0.1) -> nstdrlew21.ins.intel.com
>    by name (localhost) -> localhost
>    by address -> nstdrlew21.ins.intel.com
>    localhost -> nstdrlew21/10.125.122.60
>
> WinXP
> ========= Both ===========
> by name (127.0.0.1) -> localhost
> by name (localhost) -> localhost
> by address -> localhost
> localhost -> pbwdmkishen/10.125.132.226
>
>
> Actually Harmony use native call of getnameinfo() to get host name
> (which is reasonable IMHO). MSDN says "The getnameinfo function
> provides name resolution from an address to the host name".
>
> InetAddressTest.test_getHostName (see H-1664) failed on WinServer
> because InetAddress.getByName("127.0.0.1").getHostName() returned
> "nstdrlew21.ins.intel.com" while "localhost" expected. So this test
> looks like configuration dependent.
>
> I see three possible options
> 1. Stay test as is. Just keep in mind that on specific configurations
> this one fails.
> 2. Rewrite test to be configuration dependent. Test has to do the same
> native call.
> 3. Exclude localhost checking from test_getHostName.
I think Harmony does the right thing as spec requires, the difference is 
caused by underlying system call, so it should be acceptable, i.e., the 
test needs to be rewritten or excluded.  But this issue worth a non-bug 
difference together with getHostName()'s different behavior when 
SecurityManager presents[1](thanks Alexei Fedotov helped to find this 
link and commented to HARMONY-1664:))

Harmony-73 is another issue, which is actually caused by HARMONY-84 and 
irrelevant with getHostName() method.

[1] 
http://mail-archives.apache.org/mod_mbox/incubator-harmony-dev/200602.mbox/%3C43EC2AA4.7040801@gmail.com%3E
>
> What do you think about this situation?
>


-- 
Paulex Yang
China Software Development Lab
IBM



---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


Re: [classlib][test] Configuration dependent test of InetAddress.getHostName

Posted by Denis Kishenko <dk...@gmail.com>.
2006/10/20, Alexei Zakharov <al...@gmail.com>:
> Hi Denis,
>
> > InetAddressTest.test_getHostName (see H-1664) failed on WinServer
> > because InetAddress.getByName("127.0.0.1").getHostName() returned
> > "nstdrlew21.ins.intel.com" while "localhost" expected. So this test
>
> According to the test's output you've provided:
>
> > =========== RI ==============
> >    by name (127.0.0.1) -> 127.0.0.1
Yep

> RI returns "127.0.0.1" rather than "localhost". Is it written
> somewhere in the spec that
> InetAddress.getByName("127.0.0.1").getHostName() should return
> "localhost"?
Doesn't. But we aren't discussing this difference.

We discuss that Harmony uses system call which returns
"nstdrlew21.ins.intel.com" on WinServer2003. So should we hardcode
"127.0.0.1" as "localhost"?

---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


Re: [classlib][test] Configuration dependent test of InetAddress.getHostName

Posted by Alexei Zakharov <al...@gmail.com>.
Hi Denis,

> InetAddressTest.test_getHostName (see H-1664) failed on WinServer
> because InetAddress.getByName("127.0.0.1").getHostName() returned
> "nstdrlew21.ins.intel.com" while "localhost" expected. So this test

According to the test's output you've provided:

> =========== RI ==============
>    by name (127.0.0.1) -> 127.0.0.1

RI returns "127.0.0.1" rather than "localhost". Is it written
somewhere in the spec that
InetAddress.getByName("127.0.0.1").getHostName() should return
"localhost"?

Thanks,

2006/10/19, Denis Kishenko <dk...@gmail.com>:
> I have researched issue H-1664 and found one more difference with RI.
> I run simple test on Windows Server 2003 SP1
>
> =================== Test =============
> import java.net.InetAddress;
> import java.net.UnknownHostException;
>
> public class Test {
>    public static void main(String[] args) throws UnknownHostException {
>        System.out.println("by name (127.0.0.1) -> " +
> InetAddress.getByName("127.0.0.1").getHostName());
>        System.out.println("by name (localhost) -> " +
> InetAddress.getByName("localhost").getHostName());
>        System.out.println("by address -> " +
> InetAddress.getByAddress(new byte[]{127, 0, 0, 1}).getHostName());
>        System.out.println("localhost -> " + InetAddress.getLocalHost());
>    }
>
> }
>
> Windows Server 2003 SP1
> =========== RI ==============
>    by name (127.0.0.1) -> 127.0.0.1
>    by name (localhost) -> localhost
>    by address -> 127.0.0.1
>    localhost -> nstdrlew21/10.125.122.60
>
> ========= Harmony ==========
>    by name (127.0.0.1) -> nstdrlew21.ins.intel.com
>    by name (localhost) -> localhost
>    by address -> nstdrlew21.ins.intel.com
>    localhost -> nstdrlew21/10.125.122.60
>
> WinXP
> ========= Both ===========
> by name (127.0.0.1) -> localhost
> by name (localhost) -> localhost
> by address -> localhost
> localhost -> pbwdmkishen/10.125.132.226
>
>
> Actually Harmony use native call of getnameinfo() to get host name
> (which is reasonable IMHO). MSDN says "The getnameinfo function
> provides name resolution from an address to the host name".
>
> InetAddressTest.test_getHostName (see H-1664) failed on WinServer
> because InetAddress.getByName("127.0.0.1").getHostName() returned
> "nstdrlew21.ins.intel.com" while "localhost" expected. So this test
> looks like configuration dependent.
>
> I see three possible options
> 1. Stay test as is. Just keep in mind that on specific configurations
> this one fails.
> 2. Rewrite test to be configuration dependent. Test has to do the same
> native call.
> 3. Exclude localhost checking from test_getHostName.
>
> What do you think about this situation?


-- 
Alexei Zakharov,
Intel Enterprise Solutions Software Division

---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org