convert HTTPMemServer.getFreePort to use try-with-resources