Fix #12771: remove KeystoreEncryptionSpi Cipher ThreadLocal on stop and after use - #13582
Open
arimu1 wants to merge 1 commit into
Open
Fix #12771: remove KeystoreEncryptionSpi Cipher ThreadLocal on stop and after use#13582arimu1 wants to merge 1 commit into
arimu1 wants to merge 1 commit into
Conversation
Remove static Cipher ThreadLocal entries after crypto operations and in spiStop to avoid pinning classloaders on long-lived worker threads. Fixes apache#12771
arimu1
force-pushed
the
fix/12771-keystore-threadlocal
branch
from
September 13, 2026 00:57
feccf98 to
69f2a44
Compare
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
aesWithPaddingandaesWithoutPaddingstaticThreadLocal<Cipher>entries inspiStop()and after each encrypt/decrypt path so worker threads do not retain JCACipherinstances (and associated providers) after use.KeystoreEncryptionSpiSelfTest.testCipherThreadLocalsRemovedAfterUseto verify ThreadLocal entries are refreshed after crypto operations and SPI stop.Problem
KeystoreEncryptionSpicachesCipherinstances in staticThreadLocals but never calledremove(). Long-lived threads (e.g. embedded Tomcat workers) could keep references toCipher/provider classes and pin the webapp classloader, leading to metaspace OOM on redeploy.spiStop()alone only clears the calling thread.Test plan
./mvnw -pl modules/core test -Dtest=org.apache.ignite.spi.encryption.KeystoreEncryptionSpiSelfTest(JBR 17, MavenMAVEN_OPTSwith Ignite--add-opensflags from parent POM)Fixes #12771