You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Tomcat 9.0.97 has recently introduced a cache to keep track of resources which have been attempted to be loaded once but were not found. This aims to prevent attempting to load resources repeatedly when it has already been identified to be absent.
Prior to loading a resource, Tomcat checks this cache to see if it has been identified to be absent already. If yes, a null stream is returned without re-attempting to load the resource.
Tomcat checks the cache based on the "path" variable alone, which is always the absolute resource name.
However, there are cases such as [1] in the Apache CXF core component where the class loading first tries calling the getResourceAsStream [2] method with the absolute resource name as the “name” and if this returns a null stream, it then tries the relative resource name by calling the getResourceAsStream [2] method with the relative resource name as the “name”.
In both calls to the getResourceAsStream[2], the “path” variable within [3] is the absolute resource name and therefore, Tomcat checks the cache for the absolute resource name both times.
As a result, the second attempt based on the relative resource name gets skipped, and a null stream is returned even though the resource is present.
As a temporary measure, this cache can be disabled, and this will be reverted once the issue is fixed in Tomcat.
A similar issue where external resources were not being loaded was identified and fixed in Tomcat 9.0.98, however, this issue is still present in Tomcat version 9.0.98.
Description
Tomcat 9.0.97 has recently introduced a cache to keep track of resources which have been attempted to be loaded once but were not found. This aims to prevent attempting to load resources repeatedly when it has already been identified to be absent.
Prior to loading a resource, Tomcat checks this cache to see if it has been identified to be absent already. If yes, a null stream is returned without re-attempting to load the resource.
Tomcat checks the cache based on the "path" variable alone, which is always the absolute resource name.
However, there are cases such as [1] in the Apache CXF core component where the class loading first tries calling the getResourceAsStream [2] method with the absolute resource name as the “name” and if this returns a null stream, it then tries the relative resource name by calling the getResourceAsStream [2] method with the relative resource name as the “name”.
In both calls to the getResourceAsStream[2], the “path” variable within [3] is the absolute resource name and therefore, Tomcat checks the cache for the absolute resource name both times.
As a result, the second attempt based on the relative resource name gets skipped, and a null stream is returned even though the resource is present.
As a temporary measure, this cache can be disabled, and this will be reverted once the issue is fixed in Tomcat.
A similar issue where external resources were not being loaded was identified and fixed in Tomcat 9.0.98, however, this issue is still present in Tomcat version 9.0.98.
[1] https://github.com/apache/cxf/blob/cxf-3.5.9/core/src/main/java/org/apache/cxf/version/Version.java#L38
[2] https://github.com/apache/tomcat/blob/08206671035f05e205806140b11c10c6eb3ca5c3/java/org/apache/catalina/loader/WebappClassLoaderBase.java#L1070
[3] https://github.com/apache/tomcat/blob/08206671035f05e205806140b11c10c6eb3ca5c3/java/org/apache/catalina/loader/WebappClassLoaderBase.java#L1100
Steps to Reproduce
Upgrade Tomcat to the 9.0.98 (the latest 9.0.x version at this time).
Version
6.0.0
Environment Details (with versions)
No response
The text was updated successfully, but these errors were encountered: