Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
115ea87b
Commit
115ea87b
authored
Sep 07, 2020
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Restore ordering of ErrorPageFilter lost in
49f8943a
See gh-19471
parent
c948c70c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
3 deletions
+29
-3
ErrorPageFilter.java
...ngframework/boot/web/servlet/support/ErrorPageFilter.java
+6
-3
ErrorPageFilterConfiguration.java
...oot/web/servlet/support/ErrorPageFilterConfiguration.java
+1
-0
SpringBootServletInitializerTests.java
...eb/servlet/support/SpringBootServletInitializerTests.java
+22
-0
No files found.
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/support/ErrorPageFilter.java
View file @
115ea87b
...
@@ -43,7 +43,6 @@ import org.springframework.boot.web.server.ErrorPage;
...
@@ -43,7 +43,6 @@ import org.springframework.boot.web.server.ErrorPage;
import
org.springframework.boot.web.server.ErrorPageRegistrar
;
import
org.springframework.boot.web.server.ErrorPageRegistrar
;
import
org.springframework.boot.web.server.ErrorPageRegistry
;
import
org.springframework.boot.web.server.ErrorPageRegistry
;
import
org.springframework.core.Ordered
;
import
org.springframework.core.Ordered
;
import
org.springframework.core.annotation.Order
;
import
org.springframework.util.ClassUtils
;
import
org.springframework.util.ClassUtils
;
import
org.springframework.web.filter.OncePerRequestFilter
;
import
org.springframework.web.filter.OncePerRequestFilter
;
import
org.springframework.web.util.NestedServletException
;
import
org.springframework.web.util.NestedServletException
;
...
@@ -62,8 +61,7 @@ import org.springframework.web.util.NestedServletException;
...
@@ -62,8 +61,7 @@ import org.springframework.web.util.NestedServletException;
* @author Andy Wilkinson
* @author Andy Wilkinson
* @since 2.0.0
* @since 2.0.0
*/
*/
@Order
(
Ordered
.
HIGHEST_PRECEDENCE
+
1
)
public
class
ErrorPageFilter
implements
Filter
,
ErrorPageRegistry
,
Ordered
{
public
class
ErrorPageFilter
implements
Filter
,
ErrorPageRegistry
{
private
static
final
Log
logger
=
LogFactory
.
getLog
(
ErrorPageFilter
.
class
);
private
static
final
Log
logger
=
LogFactory
.
getLog
(
ErrorPageFilter
.
class
);
...
@@ -298,6 +296,11 @@ public class ErrorPageFilter implements Filter, ErrorPageRegistry {
...
@@ -298,6 +296,11 @@ public class ErrorPageFilter implements Filter, ErrorPageRegistry {
public
void
destroy
()
{
public
void
destroy
()
{
}
}
@Override
public
int
getOrder
()
{
return
Ordered
.
HIGHEST_PRECEDENCE
+
1
;
}
private
static
void
addClassIfPresent
(
Collection
<
Class
<?>>
collection
,
String
className
)
{
private
static
void
addClassIfPresent
(
Collection
<
Class
<?>>
collection
,
String
className
)
{
try
{
try
{
collection
.
add
(
ClassUtils
.
forName
(
className
,
null
));
collection
.
add
(
ClassUtils
.
forName
(
className
,
null
));
...
...
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/support/ErrorPageFilterConfiguration.java
View file @
115ea87b
...
@@ -38,6 +38,7 @@ class ErrorPageFilterConfiguration {
...
@@ -38,6 +38,7 @@ class ErrorPageFilterConfiguration {
@Bean
@Bean
FilterRegistrationBean
<
ErrorPageFilter
>
errorPageFilterRegistration
(
ErrorPageFilter
filter
)
{
FilterRegistrationBean
<
ErrorPageFilter
>
errorPageFilterRegistration
(
ErrorPageFilter
filter
)
{
FilterRegistrationBean
<
ErrorPageFilter
>
registration
=
new
FilterRegistrationBean
<>(
filter
);
FilterRegistrationBean
<
ErrorPageFilter
>
registration
=
new
FilterRegistrationBean
<>(
filter
);
registration
.
setOrder
(
filter
.
getOrder
());
registration
.
setDispatcherTypes
(
DispatcherType
.
REQUEST
,
DispatcherType
.
ASYNC
);
registration
.
setDispatcherTypes
(
DispatcherType
.
REQUEST
,
DispatcherType
.
ASYNC
);
return
registration
;
return
registration
;
}
}
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/support/SpringBootServletInitializerTests.java
View file @
115ea87b
...
@@ -41,6 +41,7 @@ import org.springframework.context.ConfigurableApplicationContext;
...
@@ -41,6 +41,7 @@ import org.springframework.context.ConfigurableApplicationContext;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.support.AbstractApplicationContext
;
import
org.springframework.context.support.AbstractApplicationContext
;
import
org.springframework.core.Ordered
;
import
org.springframework.core.env.PropertySource
;
import
org.springframework.core.env.PropertySource
;
import
org.springframework.mock.web.MockServletContext
;
import
org.springframework.mock.web.MockServletContext
;
import
org.springframework.web.context.WebApplicationContext
;
import
org.springframework.web.context.WebApplicationContext
;
...
@@ -120,6 +121,27 @@ class SpringBootServletInitializerTests {
...
@@ -120,6 +121,27 @@ class SpringBootServletInitializerTests {
}
}
}
}
@Test
@SuppressWarnings
(
"rawtypes"
)
void
errorPageFilterIsRegisteredWithNearHighestPrecedence
()
{
WebServer
webServer
=
new
UndertowServletWebServerFactory
(
0
).
getWebServer
((
servletContext
)
->
{
try
(
AbstractApplicationContext
context
=
(
AbstractApplicationContext
)
new
WithErrorPageFilter
()
.
createRootApplicationContext
(
servletContext
))
{
Map
<
String
,
FilterRegistrationBean
>
registrations
=
context
.
getBeansOfType
(
FilterRegistrationBean
.
class
);
assertThat
(
registrations
).
hasSize
(
1
);
FilterRegistrationBean
errorPageFilterRegistration
=
registrations
.
get
(
"errorPageFilterRegistration"
);
assertThat
(
errorPageFilterRegistration
.
getOrder
()).
isEqualTo
(
Ordered
.
HIGHEST_PRECEDENCE
+
1
);
}
});
try
{
webServer
.
start
();
}
finally
{
webServer
.
stop
();
}
}
@Test
@Test
@SuppressWarnings
(
"rawtypes"
)
@SuppressWarnings
(
"rawtypes"
)
void
errorPageFilterIsRegisteredForRequestAndAsyncDispatch
()
{
void
errorPageFilterIsRegisteredForRequestAndAsyncDispatch
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment