Fix map concurrency bug in UnitsAnnotatedTypeFactory by removing stat…#7620
Fix map concurrency bug in UnitsAnnotatedTypeFactory by removing stat…#7620dimpal14 wants to merge 2 commits intotypetools:masterfrom
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughChanged the scope of 🚥 Pre-merge checks | ❌ 1❌ Failed checks (1 warning)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Thanks for this fix.
Can you provide a concrete test case (even if nondeterministic)? If not, is this a problem you have observed, or is it a potential (latent) problem that could occur in the future? |
Problem :
UnitsAnnotatedTypeFactory used un-synchronized static HashMaps (aliasMap and externalQualsMap). When multiple projects were compiled concurrently in the same JVM (e.g., using Gradle/Maven daemons), this shared global state caused ConcurrentModificationExceptions, compiler freezes, and cross-project memory leaks.
Fixed:
Removed the static modifier from both maps, converting them into instance variables. This correctly restricts the caches to the lifecycle of a single compilation run, ensuring thread-safety and preventing data bleeding between concurrent compilations.