Skip to content

Commit a9a32f3

Browse files
committed
Merge branch '2.2.x' into 2.3.x
Closes gh-23671
2 parents de685bd + 667ccda commit a9a32f3

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/mock/web/SpringBootMockServletContext.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import java.io.IOException;
2121
import java.net.MalformedURLException;
2222
import java.net.URL;
23+
import java.nio.file.Files;
2324

2425
import org.springframework.core.io.FileSystemResourceLoader;
2526
import org.springframework.core.io.Resource;
@@ -93,9 +94,7 @@ public URL getResource(String path) throws MalformedURLException {
9394
try {
9495
if (this.emptyRootDirectory == null) {
9596
synchronized (this) {
96-
File tempDirectory = File.createTempFile("spr", "servlet");
97-
tempDirectory.delete();
98-
tempDirectory.mkdirs();
97+
File tempDirectory = Files.createTempDirectory("spr-servlet").toFile();
9998
tempDirectory.deleteOnExit();
10099
this.emptyRootDirectory = tempDirectory;
101100
}

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/server/AbstractConfigurableWebServerFactory.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import java.io.File;
2020
import java.io.IOException;
2121
import java.net.InetAddress;
22+
import java.nio.file.Files;
2223
import java.util.Arrays;
2324
import java.util.LinkedHashSet;
2425
import java.util.Set;
@@ -185,9 +186,7 @@ public Shutdown getShutdown() {
185186
*/
186187
protected final File createTempDir(String prefix) {
187188
try {
188-
File tempDir = File.createTempFile(prefix + ".", "." + getPort());
189-
tempDir.delete();
190-
tempDir.mkdir();
189+
File tempDir = Files.createTempDirectory(prefix + "." + getPort() + ".").toFile();
191190
tempDir.deleteOnExit();
192191
return tempDir;
193192
}

0 commit comments

Comments
 (0)