diff --git a/spring-boot/src/main/java/org/springframework/boot/ApplicationTemp.java b/spring-boot/src/main/java/org/springframework/boot/ApplicationTemp.java index d804b80d9e..b96fa0e0b1 100644 --- a/spring-boot/src/main/java/org/springframework/boot/ApplicationTemp.java +++ b/spring-boot/src/main/java/org/springframework/boot/ApplicationTemp.java @@ -23,7 +23,7 @@ import org.springframework.util.Assert; import org.springframework.util.StringUtils; /** - * Provides access to an application specific temporary folder. Generally speaking + * Provides access to an application specific temporary directory. Generally speaking * different Spring Boot applications will get different locations, however, simply * restarting an application will give the same location. * @@ -36,7 +36,7 @@ public class ApplicationTemp { private final Class sourceClass; - private volatile File folder; + private volatile File dir; /** * Create a new {@link ApplicationTemp} instance. @@ -55,43 +55,43 @@ public class ApplicationTemp { @Override public String toString() { - return getFolder().getAbsolutePath(); + return getDir().getAbsolutePath(); } /** - * Return a subfolder of the application temp. - * @param subFolder the subfolder name - * @return a subfolder + * Return a sub-directory of the application temp. + * @param subDir the sub-directory name + * @return a sub-directory */ - public File getFolder(String subFolder) { - File folder = new File(getFolder(), subFolder); - folder.mkdirs(); - return folder; + public File getDir(String subDir) { + File dir = new File(getDir(), subDir); + dir.mkdirs(); + return dir; } /** - * Return the folder to be used for application specific temp files. - * @return the application temp folder + * Return the directory to be used for application specific temp files. + * @return the application temp directory */ - public File getFolder() { - if (this.folder == null) { + public File getDir() { + if (this.dir == null) { synchronized (this) { byte[] hash = generateHash(this.sourceClass); - this.folder = new File(getTempDirectory(), toHexString(hash)); - this.folder.mkdirs(); - Assert.state(this.folder.exists(), - "Unable to create temp folder " + this.folder); + this.dir = new File(getTempDirectory(), toHexString(hash)); + this.dir.mkdirs(); + Assert.state(this.dir.exists(), + "Unable to create temp directory " + this.dir); } } - return this.folder; + return this.dir; } private File getTempDirectory() { String property = System.getProperty("java.io.tmpdir"); Assert.state(StringUtils.hasLength(property), "No 'java.io.tmpdir' property set"); File file = new File(property); - Assert.state(file.exists(), "Temp folder " + file + " does not exist"); - Assert.state(file.isDirectory(), "Temp location " + file + " is not a folder"); + Assert.state(file.exists(), "Temp directory" + file + " does not exist"); + Assert.state(file.isDirectory(), "Temp location " + file + " is not a directory"); return file; } diff --git a/spring-boot/src/main/java/org/springframework/boot/context/embedded/AbstractEmbeddedServletContainerFactory.java b/spring-boot/src/main/java/org/springframework/boot/context/embedded/AbstractEmbeddedServletContainerFactory.java index 690cc3b695..67c9be044b 100644 --- a/spring-boot/src/main/java/org/springframework/boot/context/embedded/AbstractEmbeddedServletContainerFactory.java +++ b/spring-boot/src/main/java/org/springframework/boot/context/embedded/AbstractEmbeddedServletContainerFactory.java @@ -150,7 +150,7 @@ public abstract class AbstractEmbeddedServletContainerFactory protected final File getValidSessionStoreDir(boolean mkdirs) { File dir = getSessionStoreDir(); if (dir == null) { - return new ApplicationTemp().getFolder("servlet-sessions"); + return new ApplicationTemp().getDir("servlet-sessions"); } if (!dir.isAbsolute()) { dir = new File(new ApplicationHome().getDir(), dir.getPath()); diff --git a/spring-boot/src/test/java/org/springframework/boot/ApplicationTempTests.java b/spring-boot/src/test/java/org/springframework/boot/ApplicationTempTests.java index c8aff474dc..1ec4dab2c0 100644 --- a/spring-boot/src/test/java/org/springframework/boot/ApplicationTempTests.java +++ b/spring-boot/src/test/java/org/springframework/boot/ApplicationTempTests.java @@ -36,17 +36,17 @@ public class ApplicationTempTests { public void generatesConsistentTemp() throws Exception { ApplicationTemp t1 = new ApplicationTemp(); ApplicationTemp t2 = new ApplicationTemp(); - assertThat(t1.getFolder(), notNullValue()); - assertThat(t1.getFolder(), equalTo(t2.getFolder())); + assertThat(t1.getDir(), notNullValue()); + assertThat(t1.getDir(), equalTo(t2.getDir())); } @Test public void differentBasedOnUserDir() throws Exception { String userDir = System.getProperty("user.dir"); try { - File t1 = new ApplicationTemp().getFolder(); + File t1 = new ApplicationTemp().getDir(); System.setProperty("user.dir", "abc"); - File t2 = new ApplicationTemp().getFolder(); + File t2 = new ApplicationTemp().getDir(); assertThat(t1, not(equalTo(t2))); } finally { @@ -57,7 +57,7 @@ public class ApplicationTempTests { @Test public void getSubFolder() throws Exception { ApplicationTemp temp = new ApplicationTemp(); - assertThat(temp.getFolder("abc"), equalTo(new File(temp.getFolder(), "abc"))); + assertThat(temp.getDir("abc"), equalTo(new File(temp.getDir(), "abc"))); } } diff --git a/spring-boot/src/test/java/org/springframework/boot/context/embedded/AbstractEmbeddedServletContainerFactoryTests.java b/spring-boot/src/test/java/org/springframework/boot/context/embedded/AbstractEmbeddedServletContainerFactoryTests.java index 44e16adedf..f6b2934cf7 100644 --- a/spring-boot/src/test/java/org/springframework/boot/context/embedded/AbstractEmbeddedServletContainerFactoryTests.java +++ b/spring-boot/src/test/java/org/springframework/boot/context/embedded/AbstractEmbeddedServletContainerFactoryTests.java @@ -595,7 +595,7 @@ public abstract class AbstractEmbeddedServletContainerFactoryTests { AbstractEmbeddedServletContainerFactory factory = getFactory(); File dir = factory.getValidSessionStoreDir(false); assertThat(dir.getName(), equalTo("servlet-sessions")); - assertThat(dir.getParentFile(), equalTo(new ApplicationTemp().getFolder())); + assertThat(dir.getParentFile(), equalTo(new ApplicationTemp().getDir())); } @Test