Unexpected behavior multi threads accessing ConstraintValidatorManager

Description

Initializing the validation context, invoking the validator, so the validation process works fine and iterate on each constraint normally.
But when more than one thread is doing that same time, the same exact case execution inside org.hibernate.validator.internal.engine.constraintvalidation.ConstraintValidatorManager.getInitializedValidator, executes if ( constraintValidatorCache.containsKey( key ) ) and evaluates to TRUE, while the constraintValidator is NULL, so the method actually return null.
Then ConstraintTree.getConstraintValidatorNoUnwrapping, execute throwExceptionForNullValidator.

This happen randomly for different fields and then we have a not valid exception message as No validator could be found for constraint 'XXXXXXXXX' validating type 'java.lang.String'. Check configuration for 'XXXXXXXX', while though the validator of this annotation actually accepts String validation

Environment

tomcat 6.0.45
JDK 1.7.0_97
Debian GNU/Linux 8 (jessie)

Status

Assignee

Gunnar Morling

Reporter

Ahmed Hashem Sayed Mostafa

Labels

None

Worked in

None

Feedback Requested

None

Feedback Requested By

None

backPortable

None

Community Help Wanted

None

Suitable for new contributors

None

Requires Release Note

None

backportDecision

None

backportReEvaluate

None

Components

Fix versions

Affects versions

5.1.2.Final

Priority

Minor