Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception when validating a method taking no parameter. #36

Closed
cyr62110 opened this issue Oct 31, 2018 · 3 comments
Closed

Exception when validating a method taking no parameter. #36

cyr62110 opened this issue Oct 31, 2018 · 3 comments

Comments

@cyr62110
Copy link

Hi again,

After I registered a Validator I started to get the following exception when the RestRouter tries to validate a function that takes no parameter. The validator library that I am using is hibernate-validators 6.0.13.

The exception I get is the following:

java.lang.IllegalArgumentException: HV000116: The method parameter array cannot not be null.
	at org.hibernate.validator.internal.util.Contracts.assertNotNull(Contracts.java:45) ~[hibernate-validator-6.0.13.Final.jar:6.0.13.Final]
	at org.hibernate.validator.internal.engine.ValidatorImpl.validateParameters(ValidatorImpl.java:222) ~[hibernate-validator-6.0.13.Final.jar:6.0.13.Final]
	at com.zandero.rest.RestRouter.validate(RestRouter.java:533) [rest.vertx-0.8.7.jar:?]

And below you will find the signature of one of the method that cause the problem:

@GET
@RolesAllowed(Scope.CATEGORIES_LIST_PUBLIC)
fun listCategories(): Future<List<CategoryUserResource>>

A simple fix may be to check if there is at least one parameters before trying to call validateParameters.

Best,

@drejc
Copy link
Member

drejc commented Oct 31, 2018

Hm ... not quite sure it is a rest.vertx issue ... can you provide the assigned validator you use.

@cyr62110
Copy link
Author

Yes, I uses hibernate-validator 6.0.13.

To create my validator, I do:

val validatorFactory = Validation.buildDefaultValidatorFactory()
val validator = validatorFactory.validator

Then I assign it to the RestBuilder:

val builder = RestBuilder(router)
                .validateWith(validator)

Best,

@drejc
Copy link
Member

drejc commented Oct 31, 2018 via email

@drejc drejc closed this as completed in 87c9b7c Nov 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants