On Wed, 1 Apr 2026 10:05:29 GMT, Michael McMahon <[email protected]> wrote:
>> I had surprising results when running converted tests the first time around >> because of JUnit autoclosing arguments of type Closeable. So I want to make >> sure that whatever argument is passed here is not something that has already >> been closed or connected by another test. Let's call it sanity. It doesn't >> change what the test is testing, just makes sure that assumptions about >> invariants are accurate. > > I think there is a parameter to the ParameterizedTest annotation which > disables auto-close if you think that makes thinks simpler > (autoCloseArguments). Yes - I've used it one place but I don't want to make it the default. Better make sure each new test gets a new socket to work with and closes that socket with try-with-resources. If JUnit closes that socket again we don't care because the second close is a no-op. The alternative would be to rework all these tests to take a socket supplier instead of a socket. But then we would have to introduce a new interface for that because Supplier::get doesn't allow to throw IOException, and DatagramSocket::new does. Some of the tests already use that logic and define their own supplier interface but I didn't want to go through that much refactoring, when simply creating a new set of sockets for each method source invocation would work. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/30502#discussion_r3021608081
