Issue Type: Bug Bug
Affects Versions: 1.1.0.Beta4
Assignee: Unassigned
Components: api, spec-general
Created: 17/Feb/13 4:24 AM
Description:

It makes for a more complex interceptor implementation that requires knowledge about the Java Reflection API returning "void".

If we fallback on no exception, then we need to change the JavaDoc of ExecutableValidator and it's spec counterpart, change the example in 5.1.2 around sample interceptor implementation

@Interceptor
    public class SampleMethodInterceptor {
        @Inject
        private Validator validator;

        @AroundInvoke
        public Object validateMethodInvocation(InvocationContext ctx) throws Exception {
            //validate parameters
            Set<ConstraintViolation<Object>> violations = validator.forExecutables().validateParameters(
                    ctx.getTarget(),
                    ctx.getMethod(),
                    ctx.getParameters()
            );

            //if a violation occurs for parameters, raise an exception
            if ( !violations.isEmpty() ) {
                throw new ConstraintViolationException(
                        buildMessage( ctx.getMethod(), ctx.getParameters(), violations ),
                        violations
                );
            }

            //execute the method proper
            Object result = ctx.proceed();

            //validate the return type *if it has a return value*
            if ( method.getReturnType() == Void.TYPE ) {
                violations = validator.forExecutables().validateReturnValue(
                        ctx.getTarget(),
                        ctx.getMethod(),
                        result
                );
            }

            //if a violation occurs for the return type, raise an exception
            if ( !violations.isEmpty() ) {
                throw new ConstraintViolationException(
                        buildMessage( ctx.getMethod(), ctx.getParameters(), violations ),
                        violations
                );
            }

            //return the result
            return result;
        }
    }
Fix Versions: 1.1.0.CR1
Project: Bean Validation
Priority: Major Major
Reporter: Emmanuel Bernard
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira