diff --git a/org.springframework.web.portlet/src/main/java/org/springframework/web/portlet/context/PortletContextResource.java b/org.springframework.web.portlet/src/main/java/org/springframework/web/portlet/context/PortletContextResource.java
index 599c9e3e54e..86f5794b28d 100644
--- a/org.springframework.web.portlet/src/main/java/org/springframework/web/portlet/context/PortletContextResource.java
+++ b/org.springframework.web.portlet/src/main/java/org/springframework/web/portlet/context/PortletContextResource.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2011 the original author or authors.
+ * Copyright 2002-2012 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -107,6 +107,28 @@ public class PortletContextResource extends AbstractFileResolvingResource implem
}
}
+ /**
+ * This implementation delegates to PortletContext.getResourceAsStream,
+ * which returns null in case of a non-readable resource (e.g. a directory).
+ * @see javax.portlet.PortletContext#getResourceAsStream(String)
+ */
+ @Override
+ public boolean isReadable() {
+ InputStream is = this.portletContext.getResourceAsStream(this.path);
+ if (is != null) {
+ try {
+ is.close();
+ }
+ catch (IOException ex) {
+ // ignore
+ }
+ return true;
+ }
+ else {
+ return false;
+ }
+ }
+
/**
* This implementation delegates to PortletContext.getResourceAsStream,
* but throws a FileNotFoundException if not found.
diff --git a/org.springframework.web/src/main/java/org/springframework/web/context/support/ServletContextResource.java b/org.springframework.web/src/main/java/org/springframework/web/context/support/ServletContextResource.java
index 99a028b2dc2..af73e49a436 100644
--- a/org.springframework.web/src/main/java/org/springframework/web/context/support/ServletContextResource.java
+++ b/org.springframework.web/src/main/java/org/springframework/web/context/support/ServletContextResource.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2011 the original author or authors.
+ * Copyright 2002-2012 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -107,6 +107,28 @@ public class ServletContextResource extends AbstractFileResolvingResource implem
}
}
+ /**
+ * This implementation delegates to ServletContext.getResourceAsStream,
+ * which returns null in case of a non-readable resource (e.g. a directory).
+ * @see javax.servlet.ServletContext#getResourceAsStream(String)
+ */
+ @Override
+ public boolean isReadable() {
+ InputStream is = this.servletContext.getResourceAsStream(this.path);
+ if (is != null) {
+ try {
+ is.close();
+ }
+ catch (IOException ex) {
+ // ignore
+ }
+ return true;
+ }
+ else {
+ return false;
+ }
+ }
+
/**
* This implementation delegates to ServletContext.getResourceAsStream,
* but throws a FileNotFoundException if no resource found.