mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-08-29 03:06:45 +08:00
Merge branch '2.3.x'
Closes gh-23672
This commit is contained in:
commit
98914b65bc
@ -20,6 +20,7 @@ import java.io.File;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
|
||||||
import org.springframework.core.io.FileSystemResourceLoader;
|
import org.springframework.core.io.FileSystemResourceLoader;
|
||||||
import org.springframework.core.io.Resource;
|
import org.springframework.core.io.Resource;
|
||||||
@ -93,9 +94,7 @@ public class SpringBootMockServletContext extends MockServletContext {
|
|||||||
try {
|
try {
|
||||||
if (this.emptyRootDirectory == null) {
|
if (this.emptyRootDirectory == null) {
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
File tempDirectory = File.createTempFile("spr", "servlet");
|
File tempDirectory = Files.createTempDirectory("spr-servlet").toFile();
|
||||||
tempDirectory.delete();
|
|
||||||
tempDirectory.mkdirs();
|
|
||||||
tempDirectory.deleteOnExit();
|
tempDirectory.deleteOnExit();
|
||||||
this.emptyRootDirectory = tempDirectory;
|
this.emptyRootDirectory = tempDirectory;
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@ package org.springframework.boot.web.server;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
|
import java.nio.file.Files;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@ -185,9 +186,7 @@ public abstract class AbstractConfigurableWebServerFactory implements Configurab
|
|||||||
*/
|
*/
|
||||||
protected final File createTempDir(String prefix) {
|
protected final File createTempDir(String prefix) {
|
||||||
try {
|
try {
|
||||||
File tempDir = File.createTempFile(prefix + ".", "." + getPort());
|
File tempDir = Files.createTempDirectory(prefix + "." + getPort() + ".").toFile();
|
||||||
tempDir.delete();
|
|
||||||
tempDir.mkdir();
|
|
||||||
tempDir.deleteOnExit();
|
tempDir.deleteOnExit();
|
||||||
return tempDir;
|
return tempDir;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user