Order char encoding filter so it sets encoding before request is read
For the character encoding filter to work, it's vital that it sets the request's encoding before any other filters attempt to read the request. This commit updates the order of OrderedCharacterEncodingFilter to be HIGHEST_PRECEDENCE and improves the existing test to check that the ordering is as required. Closes gh-3912
This commit is contained in:
parent
702b8d041f
commit
c3e447c84c
|
|
@ -27,6 +27,8 @@ import org.junit.Test;
|
|||
import org.junit.rules.ExpectedException;
|
||||
import org.springframework.beans.DirectFieldAccessor;
|
||||
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||
import org.springframework.boot.context.web.OrderedHiddenHttpMethodFilter;
|
||||
import org.springframework.boot.context.web.OrderedHttpPutFormContentFilter;
|
||||
import org.springframework.boot.test.EnvironmentTestUtils;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
|
|
@ -145,8 +147,13 @@ public class HttpEncodingAutoConfigurationTests {
|
|||
static class OrderedConfiguration {
|
||||
|
||||
@Bean
|
||||
public HiddenHttpMethodFilter hiddenHttpMethodFilter() {
|
||||
return new HiddenHttpMethodFilter();
|
||||
public OrderedHiddenHttpMethodFilter hiddenHttpMethodFilter() {
|
||||
return new OrderedHiddenHttpMethodFilter();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public OrderedHttpPutFormContentFilter httpPutFormContentFilter() {
|
||||
return new OrderedHttpPutFormContentFilter();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
|
||||
package org.springframework.boot.context.web;
|
||||
|
||||
import org.springframework.boot.context.embedded.FilterRegistrationBean;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.web.filter.CharacterEncodingFilter;
|
||||
|
||||
|
|
@ -29,7 +28,7 @@ import org.springframework.web.filter.CharacterEncodingFilter;
|
|||
public class OrderedCharacterEncodingFilter extends CharacterEncodingFilter implements
|
||||
Ordered {
|
||||
|
||||
private int order = FilterRegistrationBean.REQUEST_WRAPPER_FILTER_MAX_ORDER - 9800;
|
||||
private int order = Ordered.HIGHEST_PRECEDENCE;
|
||||
|
||||
@Override
|
||||
public int getOrder() {
|
||||
|
|
|
|||
Loading…
Reference in New Issue