WW-5537 fix(core): resolve classloader/memory leaks during Tomcat hot deployment#1631
Open
lukaszlenart wants to merge 3 commits intorelease/struts-6-8-xfrom
Open
WW-5537 fix(core): resolve classloader/memory leaks during Tomcat hot deployment#1631lukaszlenart wants to merge 3 commits intorelease/struts-6-8-xfrom
lukaszlenart wants to merge 3 commits intorelease/struts-6-8-xfrom
Conversation
… deployment Introduce InternalDestroyable interface with container-based discovery to clean up static caches, daemon threads, and shared references that pin the webapp classloader after undeploy. This prevents OutOfMemoryError (Metaspace) on repeated hot deployments. Changes: - Add InternalDestroyable/ContextAwareDestroyable interfaces for cleanup hooks - Clear OGNL, Component, ScopeInterceptor, DefaultFileManager static caches - Stop FinalizableReferenceQueue daemon thread and null its classloader - Clear FreeMarker template/introspection caches from ServletContext - Replace ContainerHolder ThreadLocal with volatile to prevent thread-pool leaks - Clear static dispatcherListeners list on Dispatcher cleanup - Add JSONCacheDestroyable for json plugin cache cleanup - Register all destroyables via struts-beans.xml / struts-plugin.xml Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… Servlet container Without log4j-web, Log4j2 SoftReferences delay classloader GC after undeploy. The log4j-web module provides Log4jServletContextListener which ensures proper Log4j2 shutdown during ServletContext destruction. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…erHolder Replace the volatile shared reference with a ThreadLocal backed by a volatile generation counter. Per-request clear() only affects the current thread (safe for concurrent requests and tests). On undeploy, invalidateAll() advances the generation counter so idle pool threads detect staleness on next access and self-clear, preventing classloader leaks without breaking test isolation. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.




Summary
OutOfMemoryError(Metaspace) during Tomcat hot redeployment (WW-5537)InternalDestroyableinterface with container-based discovery so static caches, daemon threads, and shared references are cleaned up whenDispatcher.cleanup()runsFinalizableReferenceQueuedaemon thread; replacesContainerHolderThreadLocalwithvolatileChanges
InternalDestroyable/ContextAwareDestroyableinterfacesComponentCacheDestroyable,OgnlCacheDestroyable,ScopeInterceptorCacheDestroyable,FinalizableReferenceQueueDestroyable,FreemarkerCacheDestroyableContainerHolderThreadLocal → volatileDispatcher.cleanup()refactored into focused destroy methodsJSONCacheDestroyableregistered instruts-plugin.xmlDispatcherCleanupLeakTest(8 tests),FinalizableReferenceQueueTestTest plan
DispatcherCleanupLeakTest— verifies each static cache is cleared afterdispatcher.cleanup()FinalizableReferenceQueueTest— verifies daemon thread stops and singleton is nulledjmap/MAT🤖 Generated with Claude Code