Add default ContentTypeResolver initialization

Previously AbstractMessageConverter did not have a ContentTypeResolver
configured by default. However the Java config and XML namespace in
spring-messaging and spring-websocket always configured one.

This change ensures every AbstractMessageConverter is configured with an
instance of DefaultContentTypeResolver by default. This makes sense since
all the resolver does is make an attempt to find a content type to use
for matching. If it can't it returns null and it's up to the converter
to decide whether it can convert or not.

Issue: SPR-11462
This commit is contained in:
Rossen Stoyanchev
2014-02-27 17:10:15 -05:00
parent 801237aec1
commit 0da1eefd74
4 changed files with 9 additions and 15 deletions

View File

@@ -46,7 +46,7 @@ public abstract class AbstractMessageConverter implements MessageConverter {
private final List<MimeType> supportedMimeTypes;
private ContentTypeResolver contentTypeResolver;
private ContentTypeResolver contentTypeResolver = new DefaultContentTypeResolver();
private boolean strictContentTypeMatch = false;
@@ -83,10 +83,12 @@ public abstract class AbstractMessageConverter implements MessageConverter {
* Configure the {@link ContentTypeResolver} to use to resolve the content
* type of an input message.
* <p>
* By default, no {@code ContentTypeResolver} is configured. When a resolver
* is not configured, then {@link #setStrictContentTypeMatch(boolean)} should
* be left {@code false} (the default) or otherwise this converter will ignore
* all input messages.
* Note that if no resolver is configured, then
* {@link #setStrictContentTypeMatch(boolean) strictContentTypeMatch} should
* be left as {@code false} (the default) or otherwise this converter will
* ignore all messages.
* <p>
* By default, a {@code DefaultContentTypeResolver} instance is used.
*/
public void setContentTypeResolver(ContentTypeResolver resolver) {
this.contentTypeResolver = resolver;