RFR: JDK-8265362 java/net/Socket/UdpSocket.java fails with "java.net.BindException: Address already in use" (macos-aarch64)

Alan Bateman alanb at openjdk.java.net
Sat May 22 06:49:00 UTC 2021


On Fri, 21 May 2021 17:00:11 GMT, Mark Sheppard <msheppar at openjdk.org> wrote:

>> test/jdk/java/net/Socket/UdpSocket.java line 151:
>> 
>>> 149:             }
>>> 150:         }
>>> 151:         return newUdpSocket;
>> 
>> I added this test in advance of JEP 353 as we didn't have much coverage for this deprecated constructor. No objection to the retry if it helps.  Is the catching of SocketException a left over from testing? I assume the patch can be simplified down to:
>> 
>> 
>> try {
>>    return new Socket(InetAddress.getLoopbackAddress(), 8000, false);
>> } catch (BindException e) {
>>     System.out.println(...);
>>    return new Socket(InetAddress.getLoopbackAddress(), 8000, false);
>> }
>
> yes, thanks for that  ... updated as requested

Thanks, and if you want to keep it consistent with the existing code then you could rename "Socket newUdpSocket" and "biEx", or just change it to "return new Socket(...)".

-------------

PR: https://git.openjdk.java.net/jdk/pull/4103


More information about the net-dev mailing list