Repository navigation
Conversation
paulrutter
reviewed
Oct 15, 2026
paulrutter
left a comment
Contributor
There was a problem hiding this comment.
Thanks for the fix. I traced defineClassParallel and the root cause is right. putIfAbsent in the loop condition can return null (this thread took the lock) and the body then finds the class. The loop exits with clazz != null and the finally that removes the lock is skipped, so the entry (and its Thread) leaks.
remove(name, me) is the correct release here. It cannot drop another thread's entry. It also cannot drop an outer re-entrant entry of the same thread: in that case the first putIfAbsent returns me, the loop exits with clazz == null, and the else branch is never reached.
No blocking issues. Three optional follow-ups are in the inline comments:
- Release consistency: the
finallystill uses the unconditionalremove(name). - Test coverage: nothing covers the case where another thread owns the lock.
- Test setup: it duplicates
findClassExistant.
RefuX
force-pushed
the
bundle-classloader-lock-leak
branch
from
October 15, 2026 12:10
094352c to
b639a1e
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.
Fixes FELIX-6871.
BundleWiringImplTest.defineClassParallelReleasesItsLockWhenTheClassIsAlreadyDefinedtakes the late thread's path on a single thread, so its result is deterministic. It defines a class throughfindClass, callsdefineClassParallelagain for the same name, and asserts that the sameClasscomes back andm_classLocksis empty. Without the fix it fails: