You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by kw...@apache.org on 2021/07/06 11:25:27 UTC
[sling-org-apache-sling-feature] 01/01: SLING-10586 prevent
java.nio.file.FileSystemNotFoundException during
DefaultArtifactHandler.getArtifact(...)
This is an automated email from the ASF dual-hosted git repository.
kwin pushed a commit to branch bugfix/preventFileSystemNotFoundException
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-feature.git
commit 0069a0a164b1ab3a1b8fcd18fdab45c3f19162ef
Author: Konrad Windszus <kw...@apache.org>
AuthorDate: Tue Jul 6 13:25:14 2021 +0200
SLING-10586 prevent java.nio.file.FileSystemNotFoundException during
DefaultArtifactHandler.getArtifact(...)
---
.../sling/feature/io/artifacts/ArtifactManager.java | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/src/main/java/org/apache/sling/feature/io/artifacts/ArtifactManager.java b/src/main/java/org/apache/sling/feature/io/artifacts/ArtifactManager.java
index a71c7df..fff8b06 100644
--- a/src/main/java/org/apache/sling/feature/io/artifacts/ArtifactManager.java
+++ b/src/main/java/org/apache/sling/feature/io/artifacts/ArtifactManager.java
@@ -24,10 +24,12 @@ import java.io.InputStreamReader;
import java.io.Reader;
import java.lang.ProcessBuilder.Redirect;
import java.net.MalformedURLException;
+import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLConnection;
import java.nio.charset.Charset;
+import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
@@ -383,16 +385,17 @@ public class ArtifactManager
logger.debug("Checking url to be local file {}", url);
// check if this is already a local file
try {
- final Path f = Paths.get(new URL(url).toURI());
- if (Files.exists(f)) {
- this.config.incLocalArtifacts();
- return f.toUri().toURL();
+ URI uri = new URI(url);
+ if (FileSystems.getDefault().provider().getScheme().equals(uri.getScheme())) {
+ final Path f = Paths.get(uri);
+ if (Files.exists(f)) {
+ this.config.incLocalArtifacts();
+ return f.toUri().toURL();
+ }
+ return null;
}
- return null;
} catch ( final URISyntaxException ise) {
// ignore
- } catch ( final IllegalArgumentException iae) {
- // ignore
} catch ( final MalformedURLException mue) {
// ignore
}