-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue #10084 - Directory results from getResourcePaths(String)
should include trailing slash
#10085
Issue #10084 - Directory results from getResourcePaths(String)
should include trailing slash
#10085
Conversation
…) should include trailing slash
} | ||
|
||
@Test | ||
@Disabled("There is extra decoding of the nested-reserved paths that is getting in the way") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would also require backporting the fix to 10/11.
String entry = path + item.getFileName(); | ||
if (item.isDirectory()) | ||
entry = entry + '/'; | ||
set.add(entry); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to resolve this within the resource classes? Previously the resource classes would have the trailing '/' on directories so it would be everywhere. Doing it just here as a post process risks not covering all usages.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Resource object returns a List<Resource>
so I think perhaps the place would be Resource.getFileName()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes getFileName, toString and anything else that returns the path as a string. Ideally even the URI should have the trailing slash. But
I don't think Path retains it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Turns out fixing getFileName()
breaks a lot of test cases.
See latest Jenkins build on this PR.
I'll noodle through them on monday.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be good to check if any of these texts existed in jetty 11 and see if they were changed to not expect the trailing slash
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Jetty 11 Resource.getName()
does not return the trailing slash on directories.
However, the Jetty 11 Resource.list()
returns a String array, and that array has the trailing slash.
The Resource.list()
method in Jetty 11 is used ...
- ContextHandler.getResourcePaths(String) which returns a
Set<String>
on the Servlet API - Resource.getListHTML - used to iterate a directory, and build a new set of Resources, that eventually are presented (in HTML)
- MetaInfConfiguration - iterates over WEB-INF/lib/*.jar files, and builds a new set of Resources that eventually wind up in the WebAppClassLoader
- WebAppClassLoader - used in addJars(Resource) to iterate a directory and build a new set of Resources that are added to the WebAppClassLoader
- Runner.Classpath.addJars(Resource) - same a WebAppClassLoader.addJars(Resource)
Turns out that in Jetty 12 we skip the String array step (eg: the Resource -> String array -> List of Resource -> iterate/process flow).
In Jetty 11, we don't rely on the results of Resource.getName()
for anything critical, it seems to be used only for things like debugging, exception messages, keys in the annotation parser, etc.
jetty-core/jetty-util/src/test/java/org/eclipse/jetty/util/resource/PathResourceTest.java
Outdated
Show resolved
Hide resolved
} | ||
|
||
@Test | ||
@Disabled("There is extra decoding of the nested-reserved paths that is getting in the way") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would also require backporting the fix to 10/11.
…iling slash on dirs + Bring Resource.getFileName in alignment with other JVM methods of the same name. eg: Path.getFileName
…ourcePaths(String) again
…tresourcepaths-dirs-with-trailing-slash
jetty-ee9/jetty-ee9-webapp/src/test/java/org/acme/webapp/GetRealPathsServlet.java
Show resolved
Hide resolved
jetty-ee9/jetty-ee9-webapp/src/test/java/org/eclipse/jetty/ee9/webapp/WebAppContextTest.java
Outdated
Show resolved
Hide resolved
jetty-ee9/jetty-ee9-webapp/src/test/java/org/acme/webapp/GetRealPathsServlet.java
Show resolved
Hide resolved
@joakime whoa! you're dismissing my reviews now and merging anyway?!?!?! |
@joakime I have pushed an extra test in c435bfd that checks that for a So I'm less concerned about this PR now... other than dismissing negative review and that it feels wrong that we already have a |
See #10085 (comment) The behavior in Jetty 9/10/11 for this ...
|
The The Examples:
Right? |
Correct, It seams wrong/fragile that in order to implement It is not explicit what space that the return set of But, this got merged without approval, so I guess it is done. But let's remember this when doing any future resource work and look to see if we can avoid duplicating this logic. |
getResourcePaths(String)
results.getRealPath(String)
as well