Re: Bug: StackOverflowError on some unusual filenames

Splash Forums PrettyFaces Users Bug: StackOverflowError on some unusual filenames Re: Bug: StackOverflowError on some unusual filenames

#23331

adequmoda
Participant

Paste of the diff, hopefully you can see what I mean about avoiding URL and use the String from ServletContext#getResourcePaths so you get the trailing-slash contract.

--- com/ocpsoft/pretty/faces/config/annotation/WebClassesFinder.java.orig	2012-03-05 19:00:56.000000000 -0800
+++ com/ocpsoft/pretty/faces/config/annotation/WebClassesFinder.java 2012-12-20 10:49:34.969867014 -0800
@@ -111,23 +111,20 @@
String relativeDirectoryName = getPathRelativeToClassesFolder(directoryUrl.getPath(), classesFolderPath);
// call getResourcePaths to get directory entries
- Set<?> paths = servletContext.getResourcePaths(CLASSES_FOLDER+relativeDirectoryName);
+ Set<String> paths = servletContext.getResourcePaths(CLASSES_FOLDER+relativeDirectoryName);
if (paths != null) {
// loop over all entries of the directory
- for (Object relativePath : paths)
+ for (String relativePath : paths)
{
- // get full URL for this entry
- URL entryUrl = servletContext.getResource(relativePath.toString());
-
// if this URL ends with .class it is a Java class
- if (entryUrl.getPath().endsWith(".class"))
+ if (relativePath.endsWith(".class"))
{
// the name of the entry relative to the '/WEB-INF/classes/' folder
- String entryRelativeName = getPathRelativeToClassesFolder(entryUrl.getPath(), classesFolderPath);
+ String entryRelativeName = getPathRelativeToClassesFolder(relativePath, classesFolderPath);
// build class name from relative name
String className = getClassName(entryRelativeName);
@@ -152,13 +149,16 @@
*/
try
{
+ // get full URL for this entry
+ URL entryUrl = servletContext.getResource(relativePath);
+
classFileStream = entryUrl.openStream();
}
catch (IOException e)
{
if (log.isDebugEnabled())
{
- log.debug("Cound not obtain InputStream for class file: " + entryUrl.toString(), e);
+ log.debug("Cound not obtain InputStream for class file: " + relativePath, e);
}
}
@@ -188,8 +188,10 @@
}
// if this URL ends with a slash, its a directory
- if (entryUrl.getPath().endsWith("/"))
+ if (relativePath.endsWith("/"))
{
+ // get full URL for this entry
+ URL entryUrl = servletContext.getResource(relativePath);
// walk down the directory
processDirectory(classesFolderUrl, entryUrl, handler);