https://bz.apache.org/bugzilla/show_bug.cgi?id=64074
Bug ID: 64074 Summary: getResource() for directories started to return nulls instead of list of files that directory contains Product: Tomcat 9 Version: 9.0.30 Hardware: PC OS: All Status: NEW Severity: regression Priority: P2 Component: Catalina Assignee: dev@tomcat.apache.org Reporter: kcicho...@atlassian.com Target Milestone: ----- Created attachment 36963 --> https://bz.apache.org/bugzilla/attachment.cgi?id=36963&action=edit a test case that reproduces a bug In tomcat 9.0.27 when you invoke getClass().getResource(<directory>).getInputStream() you would get an input stream containing all files from the directory. In tomcat 9.0.30 that logic has changed and you get a null instead of an input stream. We created a small test project to reproduce this error (added to this ticket as an attachment). When you deploy it to the tomcat 9.0.27 (under namespace test_tomcat9_war) and access http://localhost:8080/test_tomcat9_war/DemoServlet you will get "Full: blah.txt blah2.txt test" message while when you deploy the same artifact to the tomcat 9.0.30 you will get "Full was null" We did some investigation on our side about what has changed and it looks like When you, in a DemoServlet, invoke getClass().getResource("/full/") you get an URL object back in both cases. in tomcat 9.0.30: you will get an URL object with a handler of class org.apache.catalina.webresources.CachedResource$CachedResourceURLStreamHandler then when you call openConnection on that URL object it will delegate the openConnection to the mentioned handler. That will return org.apache.catalina.webresources.CachedResource$CachedResourceURLConnection object. Then when you call getInputStream on it it will return you a null because it doesn't handle properly a case when the resource is a directory. This is a simplified description as there are more layers of delegation here - eventually the org/apache/catalina/webresources/FileResource.java doGetInputStream() method is invoked and it fails when it tries to return FileInputStream(resource) - because the resource is a directory. in tomcat 9.0.27 you will get an URL object with a handler of class sun.net.www.protocol.file.Handler then when you call openConnection on that RUL object it will delegate the openConnection to the mentioned handler again. That will return class sun.net.www.protocol.file.FileURLConnection object. Then when you call getInputStream() method on it it will return you an input stream that has a list of files in that directory (the FileURL connection object has a special logic to handle directories. Parts of our system rely on this functionality and because of this bug we can't update to the newest version of tomcat which may be an issue especially when there is some security fix to be applied. -- You are receiving this mail because: You are the assignee for the bug. --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org