瀏覽代碼

Prevent FileSystemAlreadyExistsException (#229)

tags/release-2.4.0
Decebal Suiu 6 年之前
父節點
當前提交
bb88abaea2
共有 1 個檔案被更改,包括 12 行新增3 行删除
  1. 12
    3
      pf4j/src/main/java/org/pf4j/util/FileUtils.java

+ 12
- 3
pf4j/src/main/java/org/pf4j/util/FileUtils.java 查看文件

@@ -228,9 +228,9 @@ public class FileUtils {
}

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

public static Path findFile(Path directoryPath, String fileName) {
@@ -253,4 +253,13 @@ public class FileUtils {
return null;
}

private static FileSystem getFileSystem(URI uri) throws IOException {
FileSystem fileSystem = FileSystems.getFileSystem(uri);
if (fileSystem != null) {
return fileSystem;
}

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

}

Loading…
取消
儲存