Bug 62897

Summary: Provide a property to disable WebappClassLoaderBase.checkThreadLocalsForLeaks()
Product: Tomcat 9 Reporter: Andy Wilkinson <awilkinson>
Component: CatalinaAssignee: Tomcat Developers Mailing List <dev>
Status: RESOLVED FIXED    
Severity: normal CC: xxammuxx
Priority: P2    
Version: 9.0.x   
Target Milestone: -----   
Hardware: All   
OS: All   

Description Andy Wilkinson 2018-11-09 09:39:51 UTC
When running on Java 11 with clearReferencesObjectStreamClassCaches and clearReferencesRmiTargets both set to false, a number of reflective access warnings are still generated when the web app class loader is stopped:

WARNING: Illegal reflective access by org.apache.catalina.loader.WebappClassLoaderBase (file:/Users/awilkinson/.m2/repository/org/apache/tomcat/embed/tomcat-embed-core/9.0.12/tomcat-embed-core-9.0.12.jar) to field java.lang.Thread.threadLocals
WARNING: Illegal reflective access by org.apache.catalina.loader.WebappClassLoaderBase (file:/Users/awilkinson/.m2/repository/org/apache/tomcat/embed/tomcat-embed-core/9.0.12/tomcat-embed-core-9.0.12.jar) to field java.lang.Thread.inheritableThreadLocals
WARNING: Illegal reflective access by org.apache.catalina.loader.WebappClassLoaderBase (file:/Users/awilkinson/.m2/repository/org/apache/tomcat/embed/tomcat-embed-core/9.0.12/tomcat-embed-core-9.0.12.jar) to field java.lang.ThreadLocal$ThreadLocalMap.table
WARNING: Illegal reflective access by org.apache.catalina.loader.WebappClassLoaderBase (file:/Users/awilkinson/.m2/repository/org/apache/tomcat/embed/tomcat-embed-core/9.0.12/tomcat-embed-core-9.0.12.jar) to method java.lang.ThreadLocal$ThreadLocalMap.expungeStaleEntries()
WARNING: Illegal reflective access by org.apache.catalina.loader.WebappClassLoaderBase (file:/Users/awilkinson/.m2/repository/org/apache/tomcat/embed/tomcat-embed-core/9.0.12/tomcat-embed-core-9.0.12.jar) to field java.lang.ThreadLocal$ThreadLocalMap$Entry.value

I believe these all originate from code that's called by WebappClassLoaderBase.checkThreadLocalsForLeaks(). It would be useful to have a property that allows these checks to be disabled in the same way as the others.
Comment 1 Mark Thomas 2018-11-09 12:08:29 UTC
Fixed in:
- trunk for 9.0.14 onwards
- 8.5.x for 8.5.36 onwards
- 7.0.x for 7.0.93 onwards
Comment 2 Mark Thomas 2018-11-10 20:29:45 UTC
*** Bug 62901 has been marked as a duplicate of this bug. ***