Thanks for reporting an issue for Micronaut, please review the task list below before submitting the
issue. Your issue report will be closed if the issue is incomplete and the below tasks not completed.
[X] Example that reproduces the problem uploaded to Github
[X] Full description of the issue provided (see below)
Steps to Reproduce
Annotate a method attribute as @NotNull
put Optional.empty() in it
get a unexpected ConstraintViolationException
Just run the tests in the example project to reproduce.
Expected Behaviour
Optional.empty() is something different than null and should not cause a ConstraintViolationException exception.
Actual Behaviour
Optional.empty() causes a ConstraintViolationException:
greet.name: the greeting name is required javax.validation.ConstraintViolationException: greet.name: the greeting name is required at io.micronaut.validation.ValidatingInterceptor.intercept(ValidatingInterceptor.java:143) at io.micronaut.aop.chain.MethodInterceptorChain.proceed(MethodInterceptorChain.java:69) at de.flexguse.micronaut.demo.service.ExampleServiceImplTest.should greet #name(ExampleServiceImplTest.groovy:21)
Thanks for reporting an issue for Micronaut, please review the task list below before submitting the issue. Your issue report will be closed if the issue is incomplete and the below tasks not completed.
NOTE: If you are unsure about something and the issue is more of a question a better place to ask questions is on Stack Overflow (http://stackoverflow.com/tags/micronaut) or Gitter (https://gitter.im/micronautfw/). DO NOT use the issue tracker to ask questions.
Task List
Steps to Reproduce
Just run the tests in the example project to reproduce.
Expected Behaviour
Optional.empty() is something different than null and should not cause a ConstraintViolationException exception.
Actual Behaviour
Optional.empty() causes a ConstraintViolationException:
greet.name: the greeting name is required javax.validation.ConstraintViolationException: greet.name: the greeting name is required at io.micronaut.validation.ValidatingInterceptor.intercept(ValidatingInterceptor.java:143) at io.micronaut.aop.chain.MethodInterceptorChain.proceed(MethodInterceptorChain.java:69) at de.flexguse.micronaut.demo.service.ExampleServiceImplTest.should greet #name(ExampleServiceImplTest.groovy:21)
Environment Information
Example Application
https://github.com/flexguse/micronaut-optional-validation-demo