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

NPE when validating an object tree whith a class whose parent has defined property constraints


    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 5.2.1.Final
    • Fix Version/s: 5.2.2.Final
    • Component/s: validators
    • Labels:
    • Environment:
      Java: 8u60
      HV: 5.2.1.Final
      TestNG 6.9.5


      Today I switched from HV 5.0.1 to 5.2.1 and happily enough to know that it was claimed to be a drop-in replacement for all 5.x versions, I started my code and WOW! My code throws NPE at our initial system validations with this stack trace:

      	at org.hibernate.validator.internal.engine.ValueContext.appendNode(ValueContext.java:131)
      	at org.hibernate.validator.internal.engine.ValidatorImpl.validateConstraint(ValidatorImpl.java:539)
      	at org.hibernate.validator.internal.engine.ValidatorImpl.validateConstraintsForDefaultGroup(ValidatorImpl.java:490)
      	at org.hibernate.validator.internal.engine.ValidatorImpl.validateConstraintsForCurrentGroup(ValidatorImpl.java:454)
      	at org.hibernate.validator.internal.engine.ValidatorImpl.validateInContext(ValidatorImpl.java:406)
      	at org.hibernate.validator.internal.engine.ValidatorImpl.validateCascadedConstraint(ValidatorImpl.java:770)
      	at org.hibernate.validator.internal.engine.ValidatorImpl.validateCascadedConstraints(ValidatorImpl.java:656)
      	at org.hibernate.validator.internal.engine.ValidatorImpl.validateInContext(ValidatorImpl.java:415)
      	at org.hibernate.validator.internal.engine.ValidatorImpl.validate(ValidatorImpl.java:204)

      Working a little bit on the issue, I could manage to reproduce it in a simple unit test that I've attached. I repeat it here for the sake of description.

      Suppose that we have these simple classes:

      public class MainBean
      	public TopBean child;
      public class TopBean
      	private String getProperty()
      		return null;
      public class BottomBean extends TopBean

      If I want to validate an instance of MainBean which has an instance of BottomBean as its child, the mentioned exception occurs!

      I searched the issue database to find that HV-975 Closed has already reported this same issue, but since there has been no test cases, the issue was resolved with "Cannot Reproduce". As I could not reopen the issue, I decided to report it here since I think it is a downside to a very reliable library.




            • Votes:
              0 Vote for this issue
              2 Start watching this issue


              • Created: