We're updating the issue view to help you get more done. 

Validator invokes hashCode() with null mandatory field

Description

Hello,

I have mandatory field in object which I want to validate:

1 2 @NotNull private final LocalDate datumHinfahrt;

But when I'm trying to validate it using the Hibernate Validator I receive an exception:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 javax.validation.ValidationException: HV000041: Call to TraversableResolver.isReachable() threw an exception. at org.hibernate.validator.internal.engine.ValidatorImpl.isValidationRequired(ValidatorImpl.java:1257) at org.hibernate.validator.internal.engine.ValidatorImpl.validateConstraint(ValidatorImpl.java:459) at org.hibernate.validator.internal.engine.ValidatorImpl.validateConstraintsForDefaultGroup(ValidatorImpl.java:406) at org.hibernate.validator.internal.engine.ValidatorImpl.validateConstraintsForCurrentGroup(ValidatorImpl.java:370) at org.hibernate.validator.internal.engine.ValidatorImpl.validateInContext(ValidatorImpl.java:322) at org.hibernate.validator.internal.engine.ValidatorImpl.validateCascadedConstraint(ValidatorImpl.java:625) at org.hibernate.validator.internal.engine.ValidatorImpl.validateCascadedConstraints(ValidatorImpl.java:490) at org.hibernate.validator.internal.engine.ValidatorImpl.validateInContext(ValidatorImpl.java:331) at org.hibernate.validator.internal.engine.ValidatorImpl.validate(ValidatorImpl.java:152) ... Caused by: java.lang.NullPointerException at ch.voev.oevp.services.wegsuche.serviceobjects.WegAnfrage.hashCode(WegAnfrage.java:223) at org.hibernate.validator.internal.engine.resolver.SingleThreadCachedTraversableResolver$TraversableHolder.buildHashCode(SingleThreadCachedTraversableResolver.java:153) at org.hibernate.validator.internal.engine.resolver.SingleThreadCachedTraversableResolver$TraversableHolder.<init>(SingleThreadCachedTraversableResolver.java:114) at org.hibernate.validator.internal.engine.resolver.SingleThreadCachedTraversableResolver$TraversableHolder.<init>(SingleThreadCachedTraversableResolver.java:96) at org.hibernate.validator.internal.engine.resolver.SingleThreadCachedTraversableResolver.isReachable(SingleThreadCachedTraversableResolver.java:41) at org.hibernate.validator.internal.engine.ValidatorImpl.isValidationRequired(ValidatorImpl.java:1248)

Problem is that Validator invokes hashCode() with null mandatory field. But purpose of validation is to check nullability of this field and produce a validation error. Current behavior is conceptually wrong from my point of view.

Thanks in advance!

Environment

Hibernate 4.2.12.Final

Status

Assignee

Gunnar Morling

Reporter

oleg

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

4.2.0.Final

Priority

Minor