This is an automated email from the ASF dual-hosted git repository.
radu pushed a commit to branch master
in repository
https://gitbox.apache.org/repos/asf/sling-org-apache-sling-scripting-sightly-js-provider.git
The following commit(s) were added to refs/heads/master by this push:
new 7889584 SLING-9599 - Incomplete non-existing resource check
7889584 is described below
commit 7889584fcd338eae932aff1925f951ea288a928e
Author: Radu Cotescu <[email protected]>
AuthorDate: Fri Jul 24 18:00:05 2020 +0200
SLING-9599 - Incomplete non-existing resource check
* make sure the resource obtained can be adapted to a stream
---
.../scripting/sightly/js/impl/use/DependencyResolver.java | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git
a/src/main/java/org/apache/sling/scripting/sightly/js/impl/use/DependencyResolver.java
b/src/main/java/org/apache/sling/scripting/sightly/js/impl/use/DependencyResolver.java
index 7b0a09e..fb97c12 100644
---
a/src/main/java/org/apache/sling/scripting/sightly/js/impl/use/DependencyResolver.java
+++
b/src/main/java/org/apache/sling/scripting/sightly/js/impl/use/DependencyResolver.java
@@ -120,10 +120,15 @@ public class DependencyResolver {
}
if (scriptResource == null) {
- throw new SightlyException(String.format("Unable to load
script dependency %s.", dependency));
+ throw new SightlyException(String.format("Unable to load
script dependency %s.", dependency));
}
- reader = new ScriptNameAwareReader(new
StringReader(IOUtils.toString(scriptResource.adaptTo(InputStream.class),
- StandardCharsets.UTF_8)), scriptResource.getPath());
+ InputStream scriptStream =
scriptResource.adaptTo(InputStream.class);
+ if (scriptStream == null) {
+ throw new SightlyException(String.format("Unable to read
script %s.", dependency));
+ }
+ reader = new ScriptNameAwareReader(new
StringReader(IOUtils.toString(scriptStream, StandardCharsets.UTF_8)),
+ scriptResource.getPath());
+ IOUtils.closeQuietly(scriptStream);
} catch (IOException e) {
ioException = e;
}