Fix Validator initialization with a no-op implementation

Issue: SPR-11185
This commit is contained in:
Brian Clozel 2014-01-03 16:02:57 +01:00
parent 2c8f670d5f
commit 15d7d6d7ab
1 changed files with 13 additions and 1 deletions

View File

@ -54,6 +54,7 @@ import org.springframework.util.AntPathMatcher;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
import org.springframework.util.PathMatcher;
import org.springframework.validation.Errors;
import org.springframework.validation.Validator;
/**
@ -243,7 +244,8 @@ public class SimpAnnotationMethodMessageHandler extends AbstractMethodMessageHan
resolvers.add(new MessageMethodArgumentResolver());
resolvers.addAll(getCustomArgumentResolvers());
resolvers.add(new PayloadArgumentResolver(this.messageConverter, this.validator));
resolvers.add(new PayloadArgumentResolver(this.messageConverter,
this.validator != null ? this.validator : new NoopValidator()));
return resolvers;
}
@ -360,4 +362,14 @@ public class SimpAnnotationMethodMessageHandler extends AbstractMethodMessageHan
return new AnnotationExceptionHandlerMethodResolver(beanType);
}
private static final class NoopValidator implements Validator {
@Override
public boolean supports(Class<?> clazz) {
return false;
}
@Override
public void validate(Object target, Errors errors) {
}
};
}