RFR: 8264824: java/net/Inet6Address/B6206527.java doesn't close ServerSocket properly

Daniel Fuchs dfuchs at openjdk.java.net
Tue Apr 13 09:18:01 UTC 2021


On Tue, 13 Apr 2021 09:03:01 GMT, Michael McMahon <michaelm at openjdk.org> wrote:

>> ### Description
>> `Inet6Address/B6206527.java` test creates two instances of ServerSocket, both of which are explicity bound to a Link-Local address. Neither of the ServerSocket instances are explicitly closed meaning there is no guarantee that their associated resources are freed. 
>> 
>> ### Fix
>> Each ServerSocket is instantiated in a try-with-resources block. This ensures that in both cases of success or failure within the try-with-resources block, the sockets are always closed thanks to ServerSocket implementing Closeable. The test is also now started in othervm mode as an added assurance of the test's isolation in the event that resources are not freed.
>
> test/jdk/java/net/Inet6Address/B6206527.java line 31:
> 
>> 29:  * @build jdk.test.lib.NetworkConfiguration
>> 30:  *        jdk.test.lib.Platform
>> 31:  * @run main/othervm B6206527
> 
> Does it need othervm mode? Best to not use it if it can be avoided.

I agree with Michael that the test doesn't need the `/othervm` mode.

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

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


More information about the net-dev mailing list