Function PathImpl.createCopy(PathImpl path) creates new PathImpl that has hashCode==0. This value is fixed and never changes (due to the algorithm in hascode() funcion). The correct value after copying should have been -1 or the same value as in the source object.
The problematic PathImpl with the zero hashCode is unfortunately returned from the validate() function: Set<ConstraintViolation<MyBean>> constraintViolations = validator.validate(myBean ); System.out.println(constraintViolations.iterator().next().getPropertyPath().hashCode()); // – always 0 (provided the set is not empty, of course)
Test: PathImpl p = PathImpl.createPathFromString("just.testing"); System.out.println(p.hashCode()); PathImpl pBad = PathImpl.createCopy(p1); System.out.println(pBad.hashCode()); // ----- returns always 0
|