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.
This problem was found as part of arquillian/arquillian-extension-warp#131 - full details see there.
"arquillian-extension-warp" initializes an Arquillian "Manager" in a
javax.servlet.Filter
implementation.When running on a GlassFish server, the Filter
init
method is called on a different thread thandestroy
, where "Manager.shutdown" is called. This causes ThreadLocal leaks.This results in a lot of warnings in GlassFish console:
The ThreadLocal variables are in
org.jboss.arquillian.core.impl.ManagerImpl
andorg.jboss.arquillian.core.spi.context.AbstractContext
.Creating the
ManagerImpl
creates ThreadLocal entries that cannot be removed later. And I don't have enough Arquillian knowledge to decide whether the implementation could be changed not to write data to the ThreadLocal variables.So I followed this article to force ThreadLocal cleanup by using reflection: https://stackoverflow.com/questions/3869026/how-to-clean-up-threadlocals
On GlassFish, this mainly avoids warning messages.
But besides one less warning, the cleanup brings a real improvement: I can reproduce an OutOfMemoryException when running the test suite of "arquillian-extension-warp" several times against a remote WildFly server without restarting it (about 5-7 turns). After testing with my ThreadLocal workaround, I did not observe this error after 20 test runs. So it seems to really have a positive effect.