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

MethodValidationPostProcessor could be more open to extension [SPR-12863] #17461

spring-issuemaster opened this issue Mar 30, 2015 · 2 comments


None yet
2 participants
Copy link

commented Mar 30, 2015

Thibault Kruse opened SPR-12863 and commented

Using JSR303 annotations and bean validation works gret for validating, but sadly the ConstraintViolationException class thrown by MethodValidationInterceptor does not provide any useful output as to the context of validation. So the log file does not help telling what went wrong.


In order to work around this, it would be nice to wrap/extend Spring to prove an Exception with a better Error message.

Ideally I would want to override a method that creates the interceptor, such as:

    public MethodValidationPostProcessor methodValidator() {
        return new MethodValidationPostProcessor() {
             protected Advisor createAdvisor() {
Pointcut pointcut = new AnnotationMatchingPointcut(this.getValidatedAnnotationType(), true);
		Advice advice = (this.getValidator() != null ? new CustomMethodValidationInterceptor(this.getValidator() :
				new CustomMethodValidationInterceptor());
		this.advisor = new DefaultPointcutAdvisor(pointcut, advice);

or something similar like

protected MethodValidationInterceptor createMethodValidationInterceptor() {...}

so that I can provide an interceptor that throws an Exception with a more useful message.

Affects: 4.1.6


This comment has been minimized.

Copy link
Collaborator Author

commented Mar 31, 2015

Juergen Hoeller commented

I've introduced a protected Advice createMethodValidationAdvice(Validator) template method for those purposes. This will typically, but not necessarily, return a MethodValidationInterceptor or subclass thereof.



This comment has been minimized.

Copy link
Collaborator Author

commented Mar 31, 2015

Thibault Kruse commented

sounds good, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.