[hibernate-issues] [Hibernate-JIRA] Created: (HV-146) ValidatorTypeHelper.resolveTypes ignores return value of recursive call

Eddy Verbruggen (JIRA) noreply at atlassian.com
Fri Apr 24 10:52:17 EDT 2009


ValidatorTypeHelper.resolveTypes ignores return value of recursive call
-----------------------------------------------------------------------

                 Key: HV-146
                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HV-146
             Project: Hibernate Validator
          Issue Type: Bug
    Affects Versions: 4.0.0.Alpha3
            Reporter: Eddy Verbruggen


My Validator classes extend a common superclass, which in turn implements the ConstraintValidator interface. This version of Hibernate Validator can't cope with that class structure due to a little bug in ValidatorTypeHelper.resolveTypes.

The last bit of that method calls itself recursively, but ignores returnvalues, so the code always falls through to "return null".

			else {
				resolveTypes( resolvedTypes, rawType.getGenericSuperclass() );
				for ( Type genericInterface : rawType.getGenericInterfaces() ) {
					resolveTypes( resolvedTypes, genericInterface );
				}
			}
		}
		//else we don't care I think
		return null;


Can it be changed to something like this please:

			else {
				Type returnedType = resolveTypes( resolvedTypes, rawType.getGenericSuperclass() );
        if ( returnedType != null ) {
          return returnedType;
        }
				for ( Type genericInterface : rawType.getGenericInterfaces() ) {
          returnedType = resolveTypes( resolvedTypes, genericInterface );
          if ( returnedType != null ) {
            return returnedType;
          }
				}
			}
		}
		//else we don't care I think
		return null;




The stacktrace is:
java.lang.NullPointerException
	at org.hibernate.validation.util.ValidatorTypeHelper.extractType(ValidatorTypeHelper.java:68)
	at org.hibernate.validation.util.ValidatorTypeHelper.getValidatorsTypes(ValidatorTypeHelper.java:57)
	at org.hibernate.validation.engine.ConstraintTree.findMatchingValidatorClass(ConstraintTree.java:163)
	at org.hibernate.validation.engine.ConstraintTree.getInitalizedValidator(ConstraintTree.java:144)
	at org.hibernate.validation.engine.ConstraintTree.validateConstraints(ConstraintTree.java:113)
	at org.hibernate.validation.engine.MetaConstraint.validateConstraint(MetaConstraint.java:126)
	at org.hibernate.validation.engine.ValidatorImpl.validatePropertyForGroup(ValidatorImpl.java:419)
	at org.hibernate.validation.engine.ValidatorImpl.validateProperty(ValidatorImpl.java:373)
	at org.hibernate.validation.engine.ValidatorImpl.validateProperty(ValidatorImpl.java:132)

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the hibernate-issues mailing list