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
116b2472
Commit
116b2472
authored
Sep 07, 2020
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '2.2.x' into 2.3.x
Closes gh-23200
parents
d39b1079
115ea87b
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 @
116b2472
...
@@ -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 @
116b2472
...
@@ -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 @
116b2472
...
@@ -47,6 +47,7 @@ import org.springframework.context.ConfigurableApplicationContext;
...
@@ -47,6 +47,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
;
...
@@ -133,6 +134,27 @@ class SpringBootServletInitializerTests {
...
@@ -133,6 +134,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