On 30/04/2020 11:40, Patrick Concannon wrote:
Hi,
After some discussion offline, it was decided that a
try-with-resources was preferred to a @BeforeTest @AfterTest for
creating and closing sockets. I’ve updated the webrev to reflect this,
and the new patch can be found below.
http://cr.openjdk.java.net/~pconcannon/8243488/webrevs/webrev.02/
Another approach would be replace DSF with a simple supplier like this:
@FunctionalInterface
interface DatagramSocketSupplier {
DatagramSocket get() throws IOException;
}
so that each test is invoked with a newly created DatagramSocket. It
means the tests don't need to invoke the factory open and change to try
(socket) { ...} instead.
Both approaches are fine of course and I agree is better than
@BeforeTest/@AfterTest so that the resource clean is more obvious.
-Alan