Servlet/PortletContextResource's "isReadable()" implementation returns false for directories (SPR-9067)
This commit is contained in:
parent
7a170e8005
commit
f8238f5243
|
|
@ -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 <code>PortletContext.getResourceAsStream</code>,
|
||||
* which returns <code>null</code> 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 <code>PortletContext.getResourceAsStream</code>,
|
||||
* but throws a FileNotFoundException if not found.
|
||||
|
|
|
|||
|
|
@ -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 <code>ServletContext.getResourceAsStream</code>,
|
||||
* which returns <code>null</code> 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 <code>ServletContext.getResourceAsStream</code>,
|
||||
* but throws a FileNotFoundException if no resource found.
|
||||
|
|
|
|||
Loading…
Reference in New Issue