Fix Validator initialization with a no-op implementation
Issue: SPR-11185
This commit is contained in:
parent
2c8f670d5f
commit
15d7d6d7ab
|
|
@ -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) {
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue