harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Regis <xu.re...@gmail.com>
Subject Re: [classlib][luni] ServerSocketTest.test_setReuseAddressZ() faild on Linux
Date Thu, 12 Feb 2009 08:05:48 GMT
Jim Yu wrote:
> Hi Regis,
> I reproduced this failure on my Linux platform. Since the specs
> says SO_REUSEADDR  "is used only
> for MulticastSockets in java, and it is set by default for
> MulticastSockets." So as you said, the default value
I can't find this statement in specs. And at:
http://java.sun.com/j2se/1.5.0/docs/api/java/net/ServerSocket.html#setReuseAddress(boolean)

it says "Enabling SO_REUSEADDR prior to binding the socket using 
bind(SocketAddress) allows the socket to be bound even though a previous 
connection is in a timeout state. " and it really affect behaviors of bind.

> for SO_REUSEADDR in ServerSocket which is not defined is reasonable. IMO, it
> is a non-bug difference between
> Harmony and RI.
I incline to follow RI. Because there are already lots of code depends 
on RI's behaviors: create a new ServerSocket which reuse address 
default, no need to set it explicit.

If Harmony set the default value to false, many applications may not be 
able to bind address correctly.
> 
> 2009/1/23 Regis <xu.regis@gmail.com>
> 
>> did anyone notice the failures on linux? or it just happen on my local env?
>> junit.framework.AssertionFailedError: Unexpected exception when
>> setReuseAddress is the default case and we
>> bind:Harmony-L3NEK37/127.0.0.1:55891:java.net.BindException: The address
>> is not available
>> at junit.framework.Assert.fail(Assert.java:47)
>> at
>> org.apache.harmony.luni.tests.java.net.ServerSocketTest.test_setReuseAddressZ(ServerSocketTest.java:760)
>> at java.lang.reflect.VMReflection.invokeMethod(VMReflection.java)
>> at java.lang.reflect.Method.invoke(Method.java:317)
>> at junit.framework.TestCase.runTest(TestCase.java:154)
>> at junit.framework.TestCase.runBare(TestCase.java:127)
>> at junit.framework.TestResult$1.protect(TestResult.java:106)
>> at junit.framework.TestResult.runProtected(TestResult.java:124)
>> at junit.framework.TestResult.run(TestResult.java:109)
>> at junit.framework.TestCase.run(TestCase.java:118)
>> at junit.framework.TestSuite.runTest(TestSuite.java:208)
>> at junit.framework.TestSuite.run(TestSuite.java:203)
>> at
>> org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128)
>> at
>> org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
>> at
>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
>> at
>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
>> at
>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
>> at
>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
>>
>> I found the default value of ServerSocket.getReuseAddress() on Linux should
>> be true, but on Harmony is false, following simple test show this:
>>
>> ServerSocket serverSocket = new ServerSocket();
>> System.out.println(serverSocket.getReuseAddress());
>>
>> and I found it's introduced by commit r723103, and the code set default
>> value is removed intended, so I think there must be a reason. From spec,
>> it's undefined:
>> When a ServerSocket is created the initial setting of SO_REUSEADDR is not
>> defined
>>
>> So both Harmony and RI are reasonable.
>>
>> Should we follow RI or mark it as non-bug difference and correct the test
>> case?
>>
>> --
>> Best Regards,
>> Regis.
>>
> 
> 
> 


-- 
Best Regards,
Regis.

Mime
View raw message