Hi,

We're seeing an issue with how WebResources are cached that started
occurring in Tomcat 8.0.39 (we're using Ubuntu Xenial but I don't believe
it's related to anything in the OS).


Some of the CSS/JS files that we serve are packed inside JAR files. These
files are served by a filter that listens for an allowed path, /_resource/*
in this case, and then uses Thread.currentThread().getContextClassLoader().
getResourceAsStream(path) to fetch them out of the appropriate jar file and
serve them.


The issue we're seeing in 8.0.39 and later is that the lookup using
getResourceAsStream(path) returns null. We've traced the issue

to this specific commit: https://github.
com/apache/tomcat80/commit/184703b966fab28a27eddf4a49014bf92e5a34eb.


This is the expected request flow:


- User requests /_resource/bootstrap/js/bootstrap.js which is embedded in a
JAR included in the WAR file

- ResourceFilter (our simple filter in the example project below) looks up
the resource using getResourceAsStream(path)

- If a stream is return it's copied to the response and processing stops


What we think is happening when the issue occurs in 8.0.39:


- User requests /_resource/bootstrap/js/bootstrap.js which is embedded in a
JAR included in the WAR file

- Tomcat Mapper looks for the resource and fails to find it and caches an
EmptyResource for that path

- ResourceFilter (our simple filter in the example project below) looks up
the resource using getResourceAsStream(path)

- The resource isn't found because the EmptyResource is cached


I've created a small example project that exhibits this behavior:
https://github.com/beetlebugorg/tomcat-8-cache-issue


At this point we're unsure if this is an actual bug in Tomcat or an
incorrect usage of getResourceAsStream(path) on our part so

we're looking for advice.


Thanks,

Jeremy


-- 

JEREMY COLLINS

PERFECTSENSE  //  BRIGHTSPOT

www.perfectsensedigital.com

www.brightspot.com

O 703-956-5815

Reply via email to