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

Optional configuration parameter validation problem in 0.90-rc5 #1292

Closed
lehcim opened this issue Oct 22, 2015 · 0 comments · Fixed by #1293
Closed

Optional configuration parameter validation problem in 0.90-rc5 #1292

lehcim opened this issue Oct 22, 2015 · 0 comments · Fixed by #1293
Assignees
Labels
Milestone

Comments

@lehcim
Copy link
Contributor

lehcim commented Oct 22, 2015

After swtiching to version 0.90-rc5, my server failed to load its configuration with the following error message :

Exception in thread "main" javax.validation.UnexpectedTypeException: HV000186: 
The constraint of type 'javax.validation.constraints.NotNull' defined on 'client.userAgent' 
has multiple matching constraint validators which is due to an additional value handler of type 
'io.dropwizard.validation.valuehandling.OptionalValidatedValueUnwrapper'. 
It is unclear which value needs validating. Clarify configuration via @UnwrapValidatedValue.

The configuration field which trigger the exception is a dropwizard HttpClientConfiguration with a @Valid annotation:

public class PetConfiguration extends Configuration {
    @Valid    // remove this annotation to avoid HV000186
    public HttpClientConfiguration client ;
}

The problem is caused by the annotation @NotNull on the property userAgent in class HttpClientConfiguration. It can be reproduced with a simple String parameter, like this :

public class PetConfiguration extends Configuration {
    @NotNull
    @Valid    // remove this annotation to avoid HV000186 
    public Optional<String> foo = Optional.absent() ;
}

Everything is fine with the two configurations classes above using 0.90-rc4, I think it's a 0.90-rc5 regression, but I don't known the cause yet : to my knowledge, there was no change on HttpClientConfiguration.userAgent between rc4 and rc5 ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants