Details
-
Bug
-
Resolution: Fixed
-
Minor
-
1.0 RC1
-
None
-
getResource getResourceAsStream patch
-
Description
The Servlet 2.3 specification (and later) states that calls to getResource() and getResourceAsStream() must begin with a "/". SRV.3.5 states:
The getResource and getResourceAsStream methods take a String with a
leading "/" as argument which gives the path of the resource relative to the root of
the context.
The current implementation first tries to pass it as given (which seems to often be without a slash), and if that fails adds a slash and tries again. Web containers such as WebSphere return null when passed without a "/" (and generates an error), and so each call turns into 2 calls (as well as filling up the log).
A simple fix is as follows in com.xpn.xwiki.XWiki:
public InputStream getResourceAsStream(String s) throws MalformedURLException
{
if (!s.startsWith("/"))
InputStream is = getEngineContext().getResourceAsStream(s);
return is;
}
A better fix would probably be to find the places which do not include the "/" and add it.