[hibernate-issues] [JIRA] (HV-1779) hibernate-validator unnecessarily calls the thread-unsafe CachingJPATraversableResolverForSingleValidation in hibernate-core when validating
Guillaume Smet (JIRA)
jira at hibernate.atlassian.net
Mon May 18 04:12:00 EDT 2020
Guillaume Smet ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%3A71e31052-f0d7-46e3-a9d7-8b9acd6998d8 ) *commented* on HV-1779 ( https://hibernate.atlassian.net/browse/HV-1779?atlOrigin=eyJpIjoiNzI0ZTI1ODE0MjQxNDRkMWEwMzUwNWU4ZDk2NzYxZGUiLCJwIjoiaiJ9 )
Re: hibernate-validator unnecessarily calls the thread-unsafe CachingJPATraversableResolverForSingleValidation in hibernate-core when validating ( https://hibernate.atlassian.net/browse/HV-1779?atlOrigin=eyJpIjoiNzI0ZTI1ODE0MjQxNDRkMWEwMzUwNWU4ZDk2NzYxZGUiLCJwIjoiaiJ9 )
CachingJPATraversableResolverForSingleValidation is not thread safe because it's not supposed to be. It's used to wrap the underlying TraversableResolver for a single validate call.
It's all done automatically so you do not need to care about this.
I don't know exactly what's happening in your case and it would be hard to say without a reproducer but you can for sure define your own traversable resolver to avoid using the default ones. The JPA one is automatically chosen if you have a JPA implementation around. If you are not validating entities, it's indeed better to avoid using it.
You can find a good example of that in Quarkus for instance:
* https://github.com/quarkusio/quarkus/blob/master/extensions/hibernate-validator/runtime/src/main/java/io/quarkus/hibernate/validator/runtime/HibernateValidatorRecorder.java#L87
* https://github.com/quarkusio/quarkus/blob/master/extensions/hibernate-validator/runtime/src/main/java/io/quarkus/hibernate/validator/runtime/TraverseAllTraversableResolver.java
Also some interesting read in the doc:
* https://docs.jboss.org/hibernate/stable/validator/reference/en-US/html_single/#section-validator-factory-traversable-resolver
* https://docs.jboss.org/hibernate/stable/validator/reference/en-US/html_single/#section-configuration-validation-xml
( https://hibernate.atlassian.net/browse/HV-1779#add-comment?atlOrigin=eyJpIjoiNzI0ZTI1ODE0MjQxNDRkMWEwMzUwNWU4ZDk2NzYxZGUiLCJwIjoiaiJ9 ) Add Comment ( https://hibernate.atlassian.net/browse/HV-1779#add-comment?atlOrigin=eyJpIjoiNzI0ZTI1ODE0MjQxNDRkMWEwMzUwNWU4ZDk2NzYxZGUiLCJwIjoiaiJ9 )
Get Jira notifications on your phone! Download the Jira Cloud app for Android ( https://play.google.com/store/apps/details?id=com.atlassian.android.jira.core&referrer=utm_source%3DNotificationLink%26utm_medium%3DEmail ) or iOS ( https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=EmailNotificationLink&mt=8 ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100126- sha1:82783e0 )
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/hibernate-issues/attachments/20200518/bc5f95e5/attachment.html
More information about the hibernate-issues
mailing list