Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the same lock for all methods accessing Validation.GetValidationProviderListAction#providersPerClassloader #182

Merged
merged 1 commit into from
Aug 2, 2022

Conversation

yrodiere
Copy link
Contributor

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.

Fixes #180 (possibly?)

…roviderListAction#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 jakartaee#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.
@yrodiere
Copy link
Contributor Author

@gsmet I can't merge this myself :) Could you please review it?

@gsmet gsmet merged commit b9c774c into jakartaee:master Aug 2, 2022
@gsmet
Copy link
Contributor

gsmet commented Aug 2, 2022

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Stuck thread due to WeakHashMap
2 participants