瀏覽代碼

Fix error in getFileSystem

tags/release-2.4.0
Decebal Suiu 5 年之前
父節點
當前提交
d3e6ecda32
共有 1 個文件被更改,包括 6 次插入8 次删除
  1. 6
    8
      pf4j/src/main/java/org/pf4j/util/FileUtils.java

+ 6
- 8
pf4j/src/main/java/org/pf4j/util/FileUtils.java 查看文件

@@ -26,6 +26,7 @@ import java.io.IOException;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import java.nio.file.FileSystem;
import java.nio.file.FileSystemNotFoundException;
import java.nio.file.FileSystems;
import java.nio.file.FileVisitResult;
import java.nio.file.Files;
@@ -228,9 +229,7 @@ public class FileUtils {
}

public static Path getPath(URI uri, String first, String... more) throws IOException {
try (FileSystem fileSystem = getFileSystem(uri)) {
return fileSystem.getPath(first, more);
}
return getFileSystem(uri).getPath(first, more);
}

public static Path findFile(Path directoryPath, String fileName) {
@@ -254,12 +253,11 @@ public class FileUtils {
}

private static FileSystem getFileSystem(URI uri) throws IOException {
FileSystem fileSystem = FileSystems.getFileSystem(uri);
if (fileSystem != null) {
return fileSystem;
try {
return FileSystems.getFileSystem(uri);
} catch (FileSystemNotFoundException e) {
return FileSystems.newFileSystem(uri, Collections.<String, String>emptyMap());
}

return FileSystems.newFileSystem(uri, Collections.<String, String>emptyMap());
}

}

Loading…
取消
儲存