The following code starts throwing a ClassCastException after upgrading to Tomcat 8.5.49: URL url = this.getClass().getResource("/preset.propetries"); String scheme = url.getProtocol(); if ("jar".equals(scheme)) { JarURLConnection con = (JarURLConnection) url.openConnection(); } I guess it happens because of this commit https://github.com/apache/tomcat/commit/03e7bc8487cb706adf1f56586948a7762dd42d14#diff-b718dcafc40f187cc9aaa1518e63033d
Yes, this is caused by that commit. The fix looks fairly simple but we are at the limit of what the current implementation can reasonably do in terms of guaranteeing consistency. Chances are you are going to end up accessing the resource directly, bypassing the cache and running the risk of seeing inconsistent results. That said, the chances of a resource inside a JAR changing should be a lot lower.
Thanks for the answer. Sorry, I didn't quite understand, does it mean that you are not going to fix it?
Don't worry - I've already fixed it. I was just waiting for a couple of test builds to upload so I could point you towards them for testing. I'd like to try and avoid further regressions in the next round of releases.
OK. The upload is complete. The dev build is here: http://people.apache.org/~markt/dev/v9.0.30-dev/ If you could download, test and report back that would be very helpful. Note: - this is NOT an official release - this is NOT for production use - this is ONLY for testing this bug - please don't blame me if your server catches fire during testing ;) (Sorry to go on about this but ASF releases have various bits of QA and legal machinery behind them whereas test/dev builds like this don't and we need to make sure folks reading this understand there is a difference.)
Hi, thanks for the build. We are using the 8.5.x version, could you please backport the fix there? Otherwise, I can't test it
Already done. Test build here: http://people.apache.org/~markt/dev/v8.5.50-dev/
Hi, thanks, it works! Do you have any estimates for the 8.5.50 release?
I'm expecting to start the release early next week so it should be available towards the end of next week / beginning of the following week.
Thanks!