Browse Source

Fix Validator initialization with a no-op implementation

Issue: SPR-11185
pull/432/head
Brian Clozel 11 years ago
parent
commit
15d7d6d7ab
  1. 14
      spring-messaging/src/main/java/org/springframework/messaging/simp/annotation/support/SimpAnnotationMethodMessageHandler.java

14
spring-messaging/src/main/java/org/springframework/messaging/simp/annotation/support/SimpAnnotationMethodMessageHandler.java

@ -54,6 +54,7 @@ import org.springframework.util.AntPathMatcher; @@ -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 @@ -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 @@ -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) {
}
};
}

Loading…
Cancel
Save