diff --git a/buildSrc/src/main/groovy/io/spring/gradle/convention/SpringSampleWarPlugin.groovy b/buildSrc/src/main/groovy/io/spring/gradle/convention/SpringSampleWarPlugin.groovy index eea9483..829f4b4 100644 --- a/buildSrc/src/main/groovy/io/spring/gradle/convention/SpringSampleWarPlugin.groovy +++ b/buildSrc/src/main/groovy/io/spring/gradle/convention/SpringSampleWarPlugin.groovy @@ -116,9 +116,6 @@ class SpringSampleWarPlugin extends SpringSamplePlugin { } def static getRandomPort() { - ServerSocket serverSocket = new ServerSocket(0) - int port = serverSocket.localPort - serverSocket.close() - return port + new ServerSocket(0).withCloseable { it.localPort } } }