[fix][test] Whitelist SharedPulsarCluster threads in thread leak detector#25375
Merged
lhotari merged 4 commits intoapache:masterfrom Mar 21, 2026
Merged
Conversation
…ctor The SharedPulsarCluster is a JVM-wide singleton shut down via shutdown hook, so its threads are not real leaks. The first SharedPulsarBaseTest subclass that triggers lazy initialization was being blamed for ~90-100 broker/BK/client threads. Add ThreadLeakDetectorListener.resetCapturedThreads() to re-capture the thread baseline after shared infrastructure is initialized. Call it from SharedPulsarCluster.start() so the shared cluster threads become part of the baseline before any test class is evaluated.
…d-cluster-threads
…eeper - ManagedLedgerTest: Add @cleanup("shutdown") to two ManagedLedgerFactoryImpl local variables in testNonDurableCursorCreateForInactiveLedger and testNoOrphanScheduledTasksAfterCloseML that were never shut down, leaking OrderedScheduler and cache eviction threads - PulsarMockBookKeeper: Use shutdownNow() instead of shutdown() for the scheduler so the mock BK thread terminates immediately on cleanup
Add explicit type witness to Collectors.toCollection() to fix generic type inference failure with Collections.unmodifiableSet().
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #25375 +/- ##
============================================
+ Coverage 72.52% 72.74% +0.21%
+ Complexity 34275 34255 -20
============================================
Files 1927 1954 +27
Lines 154339 154791 +452
Branches 17683 17730 +47
============================================
+ Hits 111935 112600 +665
+ Misses 33389 33161 -228
- Partials 9015 9030 +15
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
lhotari
approved these changes
Mar 21, 2026
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
SharedPulsarClusteris a JVM-wide singleton (shut down via shutdown hook), so its ~90-100 broker/BK/client threads are not real leaksSharedPulsarBaseTestsubclass that triggers lazy initialization was being blamed for all those threads by the thread leak detectorThreadLeakDetectorListener.resetCapturedThreads()to allow re-capturing the thread baseline after shared infrastructure is initializedSharedPulsarCluster.start()so the shared cluster threads become part of the baselineThis eliminates false-positive thread leak warnings from 16 test classes that extend
SharedPulsarBaseTest.Documentation
doc-requireddoc-not-neededdoc-completeMatching PR in forked repository
none
Documentation Checklist
Note
Ready to test
Labels:
area/test