From 15d7d6d7abd4c7ba8e96e7c56ea9ec7d72d9aec8 Mon Sep 17 00:00:00 2001 From: Brian Clozel Date: Fri, 3 Jan 2014 16:02:57 +0100 Subject: [PATCH] Fix Validator initialization with a no-op implementation Issue: SPR-11185 --- .../SimpAnnotationMethodMessageHandler.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/spring-messaging/src/main/java/org/springframework/messaging/simp/annotation/support/SimpAnnotationMethodMessageHandler.java b/spring-messaging/src/main/java/org/springframework/messaging/simp/annotation/support/SimpAnnotationMethodMessageHandler.java index 40fdb884a2..5beb830252 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/simp/annotation/support/SimpAnnotationMethodMessageHandler.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/simp/annotation/support/SimpAnnotationMethodMessageHandler.java @@ -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) { + } + }; + }