Description:
|
The code seems to assume that all methods which are named getX/setX are bean properties - even when they don't match the required constraints for a bean (i.e. no arg getter, single arg setter).
When using method validation, hibernate validator errors with a "wrong number of arguments" when it encounters annotated methods of this type which don't match the bean constraints.
The property detection should follow the JavaBeans specification.
{code} public interface MyService { @NotNull String getGreeting(@NotNull String greetee); }
{code}
{code}
public class MyServiceImpl implements MyService { @NotNull String greeting;
public void setGreeting(String greeting) { this.greeting = greeting; }
public String getGreeting(String greetee) { return greeting + " " + greetee; } }
{code}
public class TestCase { public static void main(String[] args) { MyService myService = new MyServiceImpl(); myService.setGreeting("Hello"); Validator validator = Validation.buildDefaultValidatorFactory().getValidator(); validator.validate(myService); // throws IllegalArgumentException - wrong number of arguments } } {code}
|