We're updating the issue view to help you get more done. 

validateAllParameters not working for constraints on List

Description

I have a scenario where I am validating a List as NotNull for a method getTest see below example:

1 2 public interface IApplication { void getTest(@NotNull List<String> someList); }
1 2 3 4 5 6 7 8 @AutoValidator //This is similar to the MethodValidation Interceptor and using guice as DI @Slf4j public class ApplicationImpl implements IApplication { @Override public void getTest(List<String> app) { log.debug("Entered the method"); } }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 public class ValidationInterceptor implements MethodInterceptor { @Inject private ValidatorFactory validatorFactory; @Override public Object invoke(MethodInvocation invocation) throws Throwable { MethodValidator validator = validatorFactory.getValidator().unwrap( MethodValidator.class); //validate the all parameter values if they have been annotated with any constraints Set<MethodConstraintViolation<Object>> violations = validator.validateAllParameters(invocation.getThis(), invocation.getMethod(), invocation.getArguments()); if (!violations.isEmpty()) { throw new MethodConstraintViolationException(violations); } Object result = invocation.proceed(); //validate the return values if they have been annotated with any constraints violations = validator.validateReturnValue(invocation.getThis(), invocation.getMethod(), result); if (!violations.isEmpty()) { throw new MethodConstraintViolationException(violations); } return result; } }

Unit test:

1 2 3 4 5 6 7 public class AppTest { @Test public void getTest() { List<String> app = null; appSvc.getTest(app); } }

Environment

4.3.0 Final

Status

Assignee

Unassigned

Reporter

softmentor

Labels

Worked in

None

Feedback Requested

None

Feedback Requested By

None

backPortable

None

Community Help Wanted

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

backportReEvaluate

None

Components

Priority

Major