Fix null parameterName issue in content negotiation

After this change ParameterContentNegotiationStrategy no longer allows
a null parameter name, ContentNegotiationManagerFactoryBean also
requires it.

Issue: SPR-10139
This commit is contained in:
Rossen Stoyanchev
2013-01-03 11:15:36 -05:00
parent 0b2c305072
commit 42cdb200ed
3 changed files with 5 additions and 4 deletions

View File

@@ -27,6 +27,7 @@ import javax.servlet.ServletContext;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.http.MediaType;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
import org.springframework.web.context.ServletContextAware;
@@ -55,7 +56,7 @@ public class ContentNegotiationManagerFactoryBean
private Boolean useJaf;
private String parameterName;
private String parameterName = "format";
private MediaType defaultContentType;
@@ -126,6 +127,7 @@ public class ContentNegotiationManagerFactoryBean
* <p>The default parameter name is {@code "format"}.
*/
public void setParameterName(String parameterName) {
Assert.notNull(parameterName, "parameterName is required");
this.parameterName = parameterName;
}

View File

@@ -44,7 +44,6 @@ public class ParameterContentNegotiationStrategy extends AbstractMappingContentN
*/
public ParameterContentNegotiationStrategy(Map<String, MediaType> mediaTypes) {
super(mediaTypes);
Assert.notEmpty(mediaTypes, "Cannot look up media types without any mappings");
}
/**
@@ -52,6 +51,7 @@ public class ParameterContentNegotiationStrategy extends AbstractMappingContentN
* <p>The default parameter name is {@code format}.
*/
public void setParameterName(String parameterName) {
Assert.notNull(parameterName, "parameterName is required");
this.parameterName = parameterName;
}