You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by fm...@apache.org on 2010/01/21 13:06:45 UTC
svn commit: r901668 -
/sling/trunk/bundles/extensions/fsresource/src/main/java/org/apache/sling/fsprovider/internal/FsResource.java
Author: fmeschbe
Date: Thu Jan 21 12:06:45 2010
New Revision: 901668
URL: http://svn.apache.org/viewvc?rev=901668&view=rev
Log:
Check whether the abstract file is a directory before trying to open the FileInputStream on it (to prevent a nasty log message)
Modified:
sling/trunk/bundles/extensions/fsresource/src/main/java/org/apache/sling/fsprovider/internal/FsResource.java
Modified: sling/trunk/bundles/extensions/fsresource/src/main/java/org/apache/sling/fsprovider/internal/FsResource.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/fsresource/src/main/java/org/apache/sling/fsprovider/internal/FsResource.java?rev=901668&r1=901667&r2=901668&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/fsresource/src/main/java/org/apache/sling/fsprovider/internal/FsResource.java (original)
+++ sling/trunk/bundles/extensions/fsresource/src/main/java/org/apache/sling/fsprovider/internal/FsResource.java Thu Jan 21 12:06:45 2010
@@ -144,12 +144,22 @@
return (AdapterType) file;
- } else if (type == InputStream.class && file.canRead()) {
+ } else if (type == InputStream.class) {
+
+ if (!file.isDirectory() && file.canRead()) {
+
+ try {
+ return (AdapterType) new FileInputStream(file);
+ } catch (IOException ioe) {
+ getLog().info(
+ "adaptTo: Cannot open a stream on the file " + file,
+ ioe);
+ }
+
+ } else {
+
+ getLog().debug("adaptTo: File {} is not a readable file", file);
- try {
- return (AdapterType) new FileInputStream(file);
- } catch (IOException ioe) {
- getLog().info("Cannot open a stream on the file " + file, ioe);
}
} else if (type == URL.class) {
@@ -158,8 +168,10 @@
return (AdapterType) file.toURI().toURL();
} catch (MalformedURLException mue) {
getLog().info(
- "Cannot convert the file path " + file + " to an URL", mue);
+ "adaptTo: Cannot convert the file path " + file
+ + " to an URL", mue);
}
+
}
return super.adaptTo(type);