harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ruth Cao <ruoshe...@gmail.com>
Subject Re: [classlib][luni] new test in tests.api.java.net.SocketTest failed on my Windows XP sp2
Date Fri, 20 Apr 2007 03:06:41 GMT
Andrew Zhang wrote:
> On 4/19/07, Ruth Cao <ruoshen.c@gmail.com> wrote:
>>
>> 2007/4/19, Andrew Zhang <zhanghuangzhu@gmail.com>:
>> >
>> > On 4/19/07, LvJimmy,Jing <firepure@gmail.com> wrote:
>> > >
>> > > 2007/4/19, Andrew Zhang <zhanghuangzhu@gmail.com>:
>> > > > On 4/19/07, Ruth Cao <ruoshen.c@gmail.com> wrote:
>> > > > >
>> > > > > Tim Ellison wrote:
>> > > > > > Ruth Cao wrote:
>> > > > > >
>> > > > > >> You are right, Vladimir.
>> > > > > >>
>> > > > > >> It is just because the 'port' variable is set to 8080
and on
>> some
>> > > > > >> machines this port has already been occupied.  The test
case
>> will
>> > > pass
>> > > > > >> if we use Support_PortManager.getNextPort() on my side.
>> > > > > >>
>> > > > > >
>> > > > > > Please don't use the PortManager, just open port 0 and let
the
>> OS
>> > > > > > allocate a free port.  There are examples in the existing

>> tests.
>> > > > > >
>> > > > > > Regards,
>> > > > > > Tim
>> > > > > >
>> > > > > >
>> > > > > Yes, I agree that we should use port 0 in almost all the test
>> cases.
>> > > > > However, it seems that this test case is a little bit 
>> special. It
>> > > > > requires to initialize a ServerSocket to connect 0.0.0.0 after
>> > > > > connecting localhost successfully.  If we use port 0 and 
>> 0.0.0.0at
>> > > the
>> > > > > same time, the ServerSocket constructed will be invalid.
>> > > >
>> > > >
>> > > > Sorry Ruth, what did you mean here? A server socket  will 
>> connect to
>> > > > somewhere?
>> > > >
>> > > > Could you please explain the scenario a bit more clearly?
>> > > >
>> > >
>> > > I may explain you the interesting scenario :)
>> > > If we create a ServerSocket with localhost, port X (X is not zero),
>> > > close it,  and create another ServerSocket with 0.0.0.0,port X, this
>> > > process in RI is fine, but Harmony fails.
>> > > If we create a ServerSocket with localhost, port 0, close it,  and
>> > > create another ServerSocket with 0.0.0.0,port 0, this process both
>> > > fails on RI and Harmony when create the second ServerSocket.
>> >
>> >
>> > Thanks Jimmy, interesting. But  I wrote following test case which  
>> runs
>> > well
>> > against RI:
>> > public void test() throws Exception {
>> >         byte[] localAddress = {127,0,0,1};
>> >         byte[] anyAddress = {0,0,0,0};
>> >         InetAddress address = InetAddress.getByAddress(localAddress);
>> > // create a server socket with localhost, port 0
>> >         ServerSocket server = new ServerSocket(0, 5, address);
>> > // close it
>> >         server.close();
>> >         address = InetAddress.getByAddress(anyAddress);
>> > // create another server socket with 0.0.0.0, 0
>> >         server = new ServerSocket(0, 5, address);
>> > // close it
>> >         server.close();
>> >     }
>> > Did I misuderstand the scenario?
>>
>>
>> It is just the scenario on the ServerSocket side. Another part of the
>> story
>> is that the test case creates a Socket as a client to connect the above
>> two
>> ServerSockets. RI connects both successfully while Harmony fails to
>> connect
>> the second one.
>
>
> Hi Ruth,
>
> but I still don't understand why port 0 doesn't work?
> server1 = new ServerSocket(0,....);
> server2 = new ServerSocket(0,....);
> port1 = server1.getLocalPort();
> port2 = server2.getLocalPort();
> connect to port1
> connect to port2
> Where's the problem?  Can't create server2? The code above runs well 
> against
> RI.
>
I modified the test case a little and now it works by using port 0:

server1 = new ServerSocket(0,..., localhost);
port = server1.getLocalPort();
connect to server1
server2 = new ServerSocket(port,....);
connect to server2

If we skip step 'port = server1.getLocalPort();', both Harmony and RI 
fail. If no one objects, I'll create a new patch like this. It can 
reproduce the bug reported by Harmony-2503 and also avoid using 
Support_PortManager.

> You see these two process are not the same and so that we can not use
>> > > port 0 in the test.
>> > >
>> > >
>> > > > Thus, shall we assign a rarely-used port (e.g. 50000), or continue
>> > using
>> > > > > Support_PortManager? Any ideas? Suggestions?
>> > > > >
>> > > > > --
>> > > > > Regards,
>> > > > >
>> > > > > Ruth Cao
>> > > > > China Software Development Lab, IBM
>> > > > >
>> > > > >
>> > > > >
>> > > >
>> > > >
>> > > > --
>> > > > Best regards,
>> > > > Andrew Zhang
>> > > >
>> > >
>> > >
>> > > --
>> > >
>> > > Best Regards!
>> > >
>> > > Jimmy, Jing Lv
>> > > China Software Development Lab, IBM
>> > >
>> >
>> >
>> >
>> > --
>> > Best regards,
>> > Andrew Zhang
>> >
>>
>>
>>
>> -- 
>> Best regards,
>>
>> Ruth Cao
>> China Software Development Lab, IBM
>>
>
>
>


-- 
Regards,

Ruth Cao
China Software Development Lab, IBM



Mime
View raw message