[jakartaee/validation] 1aac33: Use the same lock for all methods accessing Valida...
by Guillaume Smet
Branch: refs/heads/master
Home: https://github.com/jakartaee/validation
Commit: 1aac3390f131665dd46fadc4a0b13849d0fa0afe
https://github.com/jakartaee/validation/commit/1aac3390f131665dd46fadc4a0...
Author: Yoann Rodière <yoann(a)hibernate.org>
Date: 2022-07-20 (Wed, 20 Jul 2022)
Changed paths:
M src/main/java/jakarta/validation/Validation.java
Log Message:
-----------
Use the same lock for all methods accessing Validation.GetValidationProviderListAction#providersPerClassloader
`clearCache` was a static method and thus was synchronized on the class,
while `getCachedValidationProviders`/`cacheValidationProviders`
are instance methods and thus are synchronized on a particular instance.
This means it was theoretically possible for `clearCache` and
`getCachedValidationProviders`/`cacheValidationProviders` to access the
providersPerClassloader map concurrently,
which is a problem because WeakHashMap is not thread-safe.
This may fix #180, though it's hard to say without a proper thread dump
showing what the cause of the deadlock was exactly.
In any case, this will prevent synchronization issues for integrators
that call Validation#clearDefaultValidationProviderResolverCache
concurrently to Validation.DefaultValidationProviderResolver#getValidationProviders.
Commit: b9c774c5e1810fde68d6c2fb4e6264747298dd4f
https://github.com/jakartaee/validation/commit/b9c774c5e1810fde68d6c2fb4e...
Author: Guillaume Smet <guillaume.smet(a)gmail.com>
Date: 2022-08-02 (Tue, 02 Aug 2022)
Changed paths:
M src/main/java/jakarta/validation/Validation.java
Log Message:
-----------
Merge pull request #182 from yrodiere/clearcache-synchronization
Use the same lock for all methods accessing Validation.GetValidationProviderListAction#providersPerClassloader
Compare: https://github.com/jakartaee/validation/compare/33481c47873d...b9c774c5e181
2 years, 4 months