[hibernate-issues] [Hibernate-JIRA] Commented: (HV-573) Need graceful handling of return value constraint applied to method with void return type

Gunnar Morling (JIRA) noreply at atlassian.com
Thu Apr 5 15:35:50 EDT 2012


    [ https://hibernate.onjira.com/browse/HV-573?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=46197#comment-46197 ] 

Gunnar Morling commented on HV-573:
-----------------------------------

I think the best would be to throw a {{ConstraintDeclarationException}} in this case (per the spec to be thrown "when a constraint declaration is illegal").

Btw. the HV [annotation processor|http://docs.jboss.org/hibernate/stable/validator/reference/en-US/html_single/#validator-annotation-processor] should be able to detect this kind of error at compile time/within the IDE.

> Need graceful handling of return value constraint applied to method with void return type
> -----------------------------------------------------------------------------------------
>
>                 Key: HV-573
>                 URL: https://hibernate.onjira.com/browse/HV-573
>             Project: Hibernate Validator
>          Issue Type: Bug
>            Reporter: Ron Sigal
>            Priority: Minor
>
> In Resteasy, I inadvertently created a method
> {code}
>       @FooConstraint(min=3,max=5)
>       public void postImposed(Foo foo)
>       {
>       }
> {code}
> and got
> java.lang.RuntimeException: Unhandled primitive type.
> 	at org.hibernate.validator.util.ReflectionHelper.boxedType(ReflectionHelper.java:722)
> 	at org.hibernate.validator.metadata.location.MethodConstraintLocation.typeOfAnnotatedElement(MethodConstraintLocation.java:74)
> 	at org.hibernate.validator.metadata.MetaConstraint.typeOfAnnotatedElement(MetaConstraint.java:92)
> 	at org.hibernate.validator.metadata.MetaConstraint.validateConstraint(MetaConstraint.java:82)
> 	at org.hibernate.validator.engine.ValidatorImpl.validateReturnValueForGroup(ValidatorImpl.java:1120)
> 	at org.hibernate.validator.engine.ValidatorImpl.validateReturnValueForGroup(ValidatorImpl.java:1082)
> 	at org.hibernate.validator.engine.ValidatorImpl.validateReturnValueInContext(ValidatorImpl.java:1022)
> 	at org.hibernate.validator.engine.ValidatorImpl.validateReturnValue(ValidatorImpl.java:245)
> 	at org.jboss.resteasy.plugins.providers.validation.GeneralValidatorImpl.validateReturnValue(GeneralValidatorImpl.java:71)
>         ...

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list