Skip to content

Commit 9ba954c

Browse files
committed
Fix FileSystemUtils for Windows/Linux path difference
See gh-35443
1 parent ba52164 commit 9ba954c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

spring-core/src/test/java/org/springframework/util/FileSystemUtilsTests.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,11 @@ void copyRecursively(@TempDir File tempDir) throws Exception {
8484
assertThat(new File(dest, "child")).exists();
8585
assertThat(new File(dest, "child/bar.txt")).exists();
8686

87-
URI uri = URI.create("jar:file:/" + dest.toString().replace('\\', '/') + "/archive.zip");
87+
String destPath = dest.toString().replace('\\', '/');
88+
if (!destPath.startsWith("/")) {
89+
destPath = "/" + destPath;
90+
}
91+
URI uri = URI.create("jar:file:" + destPath + "/archive.zip");
8892
Map<String, String> env = Map.of("create", "true");
8993
FileSystem zipfs = FileSystems.newFileSystem(uri, env);
9094
Path ziproot = zipfs.getPath("/");

0 commit comments

Comments
 (0)