Replace "folder" with "directory"

Consistently use the term "directory" instead of "folder"

Closes gh-21218
This commit is contained in:
Phillip Webb
2020-04-28 18:27:41 -07:00
parent ec871d6752
commit ad1248e4ec
98 changed files with 853 additions and 835 deletions

View File

@@ -139,7 +139,7 @@ public abstract class ExecutableArchiveLauncher extends Launcher {
* Determine if the specified entry is a nested item that should be added to the
* classpath.
* @param entry the entry to check
* @return {@code true} if the entry is a nested item (jar or folder)
* @return {@code true} if the entry is a nested item (jar or directory)
*/
protected abstract boolean isNestedArchive(Archive.Entry entry);

View File

@@ -55,7 +55,7 @@ public class ExplodedArchive implements Archive {
/**
* Create a new {@link ExplodedArchive} instance.
* @param root the root folder
* @param root the root directory
*/
public ExplodedArchive(File root) {
this(root, true);
@@ -63,15 +63,14 @@ public class ExplodedArchive implements Archive {
/**
* Create a new {@link ExplodedArchive} instance.
* @param root the root folder
* @param root the root directory
* @param recursive if recursive searching should be used to locate the manifest.
* Defaults to {@code true}, folders with a large tree might want to set this to
* {@code
* false}.
* Defaults to {@code true}, directories with a large tree might want to set this to
* {@code false}.
*/
public ExplodedArchive(File root, boolean recursive) {
if (!root.exists() || !root.isDirectory()) {
throw new IllegalArgumentException("Invalid source folder " + root);
throw new IllegalArgumentException("Invalid source directory " + root);
}
this.root = root;
this.recursive = recursive;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -47,7 +47,7 @@ public class JarFileArchive implements Archive {
private URL url;
private File tempUnpackFolder;
private File tempUnpackDirectory;
public JarFileArchive(File file) throws IOException {
this(file, file.toURI().toURL());
@@ -109,31 +109,31 @@ public class JarFileArchive implements Archive {
if (name.lastIndexOf('/') != -1) {
name = name.substring(name.lastIndexOf('/') + 1);
}
File file = new File(getTempUnpackFolder(), name);
File file = new File(getTempUnpackDirectory(), name);
if (!file.exists() || file.length() != jarEntry.getSize()) {
unpack(jarEntry, file);
}
return new JarFileArchive(file, file.toURI().toURL());
}
private File getTempUnpackFolder() {
if (this.tempUnpackFolder == null) {
File tempFolder = new File(System.getProperty("java.io.tmpdir"));
this.tempUnpackFolder = createUnpackFolder(tempFolder);
private File getTempUnpackDirectory() {
if (this.tempUnpackDirectory == null) {
File tempDirectory = new File(System.getProperty("java.io.tmpdir"));
this.tempUnpackDirectory = createUnpackDirectory(tempDirectory);
}
return this.tempUnpackFolder;
return this.tempUnpackDirectory;
}
private File createUnpackFolder(File parent) {
private File createUnpackDirectory(File parent) {
int attempts = 0;
while (attempts++ < 1000) {
String fileName = new File(this.jarFile.getName()).getName();
File unpackFolder = new File(parent, fileName + "-spring-boot-libs-" + UUID.randomUUID());
if (unpackFolder.mkdirs()) {
return unpackFolder;
File unpackDirectory = new File(parent, fileName + "-spring-boot-libs-" + UUID.randomUUID());
if (unpackDirectory.mkdirs()) {
return unpackDirectory;
}
}
throw new IllegalStateException("Failed to create unpack folder in directory '" + parent + "'");
throw new IllegalStateException("Failed to create unpack directory in directory '" + parent + "'");
}
private void unpack(JarEntry entry, File file) throws IOException {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,7 +16,7 @@
/**
* Abstraction over logical Archives be they backed by a JAR file or unpacked into a
* folder.
* directory.
*
* @see org.springframework.boot.loader.archive.Archive
*/

View File

@@ -55,8 +55,8 @@ class ClassPathIndexFileTests {
}
@Test
void loadIfPossibleWhenRootIsFolderThrowsException() throws Exception {
File root = new File(this.temp, "folder");
void loadIfPossibleWhenRootIsDirectoryThrowsException() throws Exception {
File root = new File(this.temp, "directory");
root.mkdirs();
assertThat(ClassPathIndexFile.loadIfPossible(root.toURI().toURL(), "test.idx")).isNull();
}

View File

@@ -102,7 +102,7 @@ class PropertiesLauncherTests {
void testNonExistentHome() {
System.setProperty("loader.home", "src/test/resources/nonexistent");
assertThatIllegalStateException().isThrownBy(PropertiesLauncher::new)
.withMessageContaining("Invalid source folder").withCauseInstanceOf(IllegalArgumentException.class);
.withMessageContaining("Invalid source directory").withCauseInstanceOf(IllegalArgumentException.class);
}
@Test

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -51,7 +51,7 @@ class ExplodedArchiveTests {
@TempDir
File tempDir;
private File rootFolder;
private File rootDirectory;
private ExplodedArchive archive;
@@ -71,16 +71,16 @@ class ExplodedArchiveTests {
createArchive(null);
}
private void createArchive(String folderName) throws Exception {
private void createArchive(String directoryName) throws Exception {
File file = new File(this.tempDir, "test.jar");
TestJarCreator.createTestJar(file);
this.rootFolder = (StringUtils.hasText(folderName) ? new File(this.tempDir, folderName)
this.rootDirectory = (StringUtils.hasText(directoryName) ? new File(this.tempDir, directoryName)
: new File(this.tempDir, UUID.randomUUID().toString()));
JarFile jarFile = new JarFile(file);
Enumeration<JarEntry> entries = jarFile.entries();
while (entries.hasMoreElements()) {
JarEntry entry = entries.nextElement();
File destination = new File(this.rootFolder.getAbsolutePath() + File.separator + entry.getName());
File destination = new File(this.rootDirectory.getAbsolutePath() + File.separator + entry.getName());
destination.getParentFile().mkdirs();
if (entry.isDirectory()) {
destination.mkdir();
@@ -89,7 +89,7 @@ class ExplodedArchiveTests {
FileCopyUtils.copy(jarFile.getInputStream(entry), new FileOutputStream(destination));
}
}
this.archive = new ExplodedArchive(this.rootFolder);
this.archive = new ExplodedArchive(this.rootDirectory);
jarFile.close();
}
@@ -106,20 +106,20 @@ class ExplodedArchiveTests {
@Test
void getUrl() throws Exception {
assertThat(this.archive.getUrl()).isEqualTo(this.rootFolder.toURI().toURL());
assertThat(this.archive.getUrl()).isEqualTo(this.rootDirectory.toURI().toURL());
}
@Test
void getUrlWithSpaceInPath() throws Exception {
createArchive("spaces in the name");
assertThat(this.archive.getUrl()).isEqualTo(this.rootFolder.toURI().toURL());
assertThat(this.archive.getUrl()).isEqualTo(this.rootDirectory.toURI().toURL());
}
@Test
void getNestedArchive() throws Exception {
Entry entry = getEntriesMap(this.archive).get("nested.jar");
Archive nested = this.archive.getNestedArchive(entry);
assertThat(nested.getUrl().toString()).isEqualTo(this.rootFolder.toURI() + "nested.jar");
assertThat(nested.getUrl().toString()).isEqualTo(this.rootDirectory.toURI() + "nested.jar");
nested.close();
}
@@ -129,7 +129,7 @@ class ExplodedArchiveTests {
Archive nested = this.archive.getNestedArchive(entry);
Map<String, Entry> nestedEntries = getEntriesMap(nested);
assertThat(nestedEntries.size()).isEqualTo(1);
assertThat(nested.getUrl().toString()).isEqualTo("file:" + this.rootFolder.toURI().getPath() + "d/");
assertThat(nested.getUrl().toString()).isEqualTo("file:" + this.rootDirectory.toURI().getPath() + "d/");
}
@Test

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -126,20 +126,20 @@ class HandlerTests {
@Test
void urlWithSpecReferencingParentDirectory() throws MalformedURLException {
assertStandardAndCustomHandlerUrlsAreEqual("file:/test.jar!/BOOT-INF/classes!/xsd/folderA/a.xsd",
"../folderB/c/d/e.xsd");
assertStandardAndCustomHandlerUrlsAreEqual("file:/test.jar!/BOOT-INF/classes!/xsd/directoryA/a.xsd",
"../directoryB/c/d/e.xsd");
}
@Test
void urlWithSpecReferencingAncestorDirectoryOutsideJarStopsAtJarRoot() throws MalformedURLException {
assertStandardAndCustomHandlerUrlsAreEqual("file:/test.jar!/BOOT-INF/classes!/xsd/folderA/a.xsd",
"../../../../../../folderB/b.xsd");
assertStandardAndCustomHandlerUrlsAreEqual("file:/test.jar!/BOOT-INF/classes!/xsd/directoryA/a.xsd",
"../../../../../../directoryB/b.xsd");
}
@Test
void urlWithSpecReferencingCurrentDirectory() throws MalformedURLException {
assertStandardAndCustomHandlerUrlsAreEqual("file:/test.jar!/BOOT-INF/classes!/xsd/folderA/a.xsd",
"./folderB/c/d/e.xsd");
assertStandardAndCustomHandlerUrlsAreEqual("file:/test.jar!/BOOT-INF/classes!/xsd/directoryA/a.xsd",
"./directoryB/c/d/e.xsd");
}
@Test