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:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user