Bug 58436

Summary: Data Race in class org/apache/juli/ClassLoaderLogManager
Product: Tomcat 8 Reporter: Thomas Krieger <krieger.thomas>
Component: UtilAssignee: Tomcat Developers Mailing List <dev>
Status: RESOLVED FIXED    
Severity: minor    
Priority: P2    
Version: 8.0.26   
Target Milestone: ----   
Hardware: PC   
OS: All   

Description Thomas Krieger 2015-09-21 10:03:46 UTC
Using http://vmlens.com to find data races I found the following data race:
In ClassLoaderLogManager the method addLogger access the classLoaderLoggers hashmap synchronized but the method shutdown does not use any synchronization.

Here are example stacktraces:
localhost-startStop-1 (16)
java/util/concurrent/ThreadPoolExecutor$Worker.run 
java/util/concurrent/ThreadPoolExecutor.runWorker 
java/util/concurrent/FutureTask.run 
java/util/concurrent/Executors$RunnableAdapter.call
org/apache/catalina/startup/HostConfig$DeployWar.run
org/apache/catalina/startup/HostConfig.deployWAR
org/apache/catalina/core/StandardHost.addChild
org/apache/catalina/core/ContainerBase.addChild
org/apache/catalina/core/ContainerBase.addChildInternal
org/apache/catalina/util/LifecycleBase.start
org/apache/catalina/core/StandardContext.startInternal
org/apache/catalina/core/ContainerBase.getLogger
org/apache/juli/logging/LogFactory.getLog
org/apache/juli/logging/LogFactory.getInstance
org/apache/juli/logging/DirectJDKLog.getInstance
org/apache/juli/logging/DirectJDKLog.<init>
java/util/logging/Logger.getLogger
java/util/logging/Logger.demandLogger
java/util/logging/LogManager.demandLogger
org/apache/juli/ClassLoaderLogManager.getLogger
org/apache/juli/ClassLoaderLogManager.getClassLoaderInfo
org/apache/juli/ClassLoaderLogManager$2.run
org/apache/juli/ClassLoaderLogManager$2.run
org/apache/juli/ClassLoaderLogManager.readConfiguration
java/util/WeakHashMap.put 

Thread-1 (12)
java/util/concurrent/ThreadPoolExecutor$Worker.run	
org/apache/juli/ClassLoaderLogManager$Cleaner.run	
org/apache/juli/ClassLoaderLogManager.shutdown	
java/util/WeakHashMap$HashIterator.nextEntry
Comment 1 Mark Thomas 2015-09-21 13:01:22 UTC
Thanks for the report. Fixed in trunk, 8.0.x (for 8.0.27 onwards) and 7.0.x (for 7.0.65 onwards).