AmshikaH commented on PR #816: URL: https://github.com/apache/tomcat/pull/816#issuecomment-2633658818
Sorry, I meant absolute and relative paths, not URLs. I have updated the description body to reflect this. An example case would be the calling the [`getResourceAsStream` method in Apache CXF Core's Version class](https://github.com/apache/cxf/blob/cxf-3.5.9/core/src/main/java/org/apache/cxf/version/Version.java#L38) (I use cxf-3.5.9) where the class loader is Tomcat's webapp class loader. The relevant snippet from Apache CXF Core's Version class is given below: <img width="564" alt="Screenshot 2025-02-04 at 16 33 40" src="https://github.com/user-attachments/assets/06afccbf-8534-4312-9df9-83ae3c6e6ffd" /> In line 40, Apache CXF Core calls Tomcat's `getResourceAsStream` method by passing the absolute path `/org/apache/cxf/version/version.properties` as the name. In line 42, Tomcat's `getResourceAsStream` method is called a second time by passing the relative path `org/apache/cxf/version/version.properties` as the name. In both calls, the variables within Tomcat's `getResourceAsStream` are as follows. - First call: - name: `/org/apache/cxf/version/version.properties` (absolute) - path: `/org/apache/cxf/version/version.properties` (absolute) - Second call: - name: `org/apache/cxf/version/version.properties` (relative) - path: `/org/apache/cxf/version/version.properties` (absolute) Regardless of whether the `name ` variable is relative or absolute, the `path` variable is always absolute as it is derived using Tomcat's [`nameToPath` method](https://github.com/apache/tomcat/blob/9647a025443861f6fb6159b9c90f91dba6c7e7b4/java/org/apache/catalina/loader/WebappClassLoaderBase.java#L2379) in Tomcat's [`getResourceAsStream` method](https://github.com/apache/tomcat/blob/08206671035f05e205806140b11c10c6eb3ca5c3/java/org/apache/catalina/loader/WebappClassLoaderBase.java#L1100): <img width="556" alt="Screenshot 2025-02-04 at 17 06 43" src="https://github.com/user-attachments/assets/a5dafacf-9983-452c-b1f9-e2e6ff74fdcb" /> Since the caching logic within Tomcat's `getResourceAsStream` only checks the `path` variable which is absolute, the second call based on the relative path gives a false positive that the resource has already been looked up and found to be unavailable with Tomcat 9.0.97 and 9.0.98. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org