Uploaded image for project: 'Hibernate Validator'
  1. HV-1013

Validator invokes hashCode() with null mandatory field

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 4.2.0.Final
    • Fix Version/s: 5.3.0.CR1
    • Component/s: validators
    • Labels:
      None
    • Environment:
      Hibernate 4.2.12.Final

      Description

      Hello,

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

      @NotNull
      private final LocalDate datumHinfahrt;
      

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

      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!

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: