diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/TomcatWebSocketTestServer.java b/spring-websocket/src/test/java/org/springframework/web/socket/TomcatWebSocketTestServer.java index 78ca7714ac..a27918cdd8 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/TomcatWebSocketTestServer.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/TomcatWebSocketTestServer.java @@ -18,6 +18,7 @@ import java.io.File; import java.io.IOException; +import java.nio.file.Files; import javax.servlet.Filter; import javax.servlet.ServletContext; @@ -70,9 +71,7 @@ public void setup() { private File createTempDir(String prefix) { try { - File tempFolder = File.createTempFile(prefix + ".", "." + getPort()); - tempFolder.delete(); - tempFolder.mkdir(); + File tempFolder = Files.createTempDirectory(prefix + "." + "." + getPort()).toFile(); tempFolder.deleteOnExit(); return tempFolder; }