Skip to content

Commit 077e46e

Browse files
committed
GH-419: Remove deprecated RamFileSystemProvider for v1.0.0
- Remove deprecated RamFileSystemProvider - Fix JimfsFileSystemProviderImpl to make use of the provided file system name - Fix a couple of bugs regarding JimfsFileSystemProvider disallowing specific characters in file system names.
1 parent a4fdc8c commit 077e46e

File tree

8 files changed

+9
-169
lines changed

8 files changed

+9
-169
lines changed

java-compiler-testing/src/main/java/io/github/ascopes/jct/utils/FileUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public static void assertValidRootName(@Nullable String name) {
122122
);
123123
}
124124

125-
if (name.contains("/") || name.contains("\\") || name.contains("..")) {
125+
if (name.contains("/") || name.contains("\\") || name.contains("..") || name.contains("_")) {
126126
throw new IllegalArgumentException(
127127
"Invalid file name provided: " + StringUtils.quoted(name)
128128
);

java-compiler-testing/src/main/java/io/github/ascopes/jct/workspaces/RamFileSystemProvider.java

Lines changed: 0 additions & 58 deletions
This file was deleted.

java-compiler-testing/src/main/java/io/github/ascopes/jct/workspaces/impl/MemoryFileSystemProvider.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@
3535
* @since 0.7.0
3636
*/
3737
@API(since = "0.7.0", status = Status.INTERNAL)
38-
@SuppressWarnings("removal")
39-
public final class MemoryFileSystemProvider implements RamFileSystemProvider {
38+
public final class MemoryFileSystemProvider {
4039

4140
// We could initialise this lazily, but this class has fewer fields and initialisation
4241
// overhead than a lazy-loaded object would, so it doesn't really make sense to do it
@@ -57,7 +56,6 @@ private MemoryFileSystemProvider() {
5756
// Singleton object.
5857
}
5958

60-
@Override
6159
public FileSystem createFileSystem(String name) {
6260
try {
6361
return MemoryFileSystemBuilder.newLinux()

java-compiler-testing/src/main/java/io/github/ascopes/jct/workspaces/impl/RamDirectoryImpl.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ public void close() throws IOException {
8585
* @return the in-memory path.
8686
*/
8787
public static RamDirectoryImpl newRamDirectory(String name) {
88-
8988
assertValidRootName(name);
9089

9190
// MemoryFileSystem needs unique FS names to work correctly, so use a UUID to enforce this.

java-compiler-testing/src/main/java/io/github/ascopes/jct/workspaces/impl/WorkspaceImpl.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,12 @@ public ManagedDirectory createPackage(Location location) {
136136
throw new IllegalArgumentException("Location must not be module-oriented");
137137
}
138138

139-
var dir = pathStrategy.newInstance(location.getName());
139+
// Needs to be unique, and JIMFS cannot hold a file system name containing stuff like
140+
// underscores.
141+
var fsName = location.getName().replaceAll("[^A-Za-z0-9]", "")
142+
+ UUID.randomUUID();
143+
144+
var dir = pathStrategy.newInstance(fsName);
140145
paths.computeIfAbsent(location, unused -> new ArrayList<>()).add(dir);
141146
return dir;
142147
}

java-compiler-testing/src/main/java/module-info.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@
9898
* }
9999
* </code></pre>
100100
*/
101-
@SuppressWarnings("removal")
102101
module io.github.ascopes.jct {
103102

104103
////////////////////

java-compiler-testing/src/test/java/io/github/ascopes/jct/tests/unit/utils/FileUtilsTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ void assertValidRootNameSucceedsForValidRootNames(String rootName) {
160160
"foo/bar, Invalid file name provided",
161161
"foo\\bar, Invalid file name provided",
162162
"foo\\../bar, Invalid file name provided",
163+
"foo_bar, Invalid file name provided",
163164
})
164165
@ParameterizedTest(name = "\"{0}\" is not a valid root name and raises \"{1}\"")
165166
void assertValidRootNameFailsForInvalidRootNames(String rootName, String expectedError) {

java-compiler-testing/src/test/java/io/github/ascopes/jct/tests/unit/workspaces/RamFileSystemProviderTest.java

Lines changed: 0 additions & 104 deletions
This file was deleted.

0 commit comments

Comments
 (0)