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
6ee0f8df
Commit
6ee0f8df
authored
Jul 30, 2020
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '2.2.x' into 2.3.x
Closes gh-22672
parents
45346b63
49f8943a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
1 deletion
+42
-1
ErrorPageFilterConfiguration.java
...oot/web/servlet/support/ErrorPageFilterConfiguration.java
+11
-1
SpringBootServletInitializerTests.java
...eb/servlet/support/SpringBootServletInitializerTests.java
+31
-0
No files found.
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/support/ErrorPageFilterConfiguration.java
View file @
6ee0f8df
/*
* Copyright 2012-20
19
the original author or authors.
* Copyright 2012-20
20
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -16,6 +16,9 @@
package
org
.
springframework
.
boot
.
web
.
servlet
.
support
;
import
javax.servlet.DispatcherType
;
import
org.springframework.boot.web.servlet.FilterRegistrationBean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
...
...
@@ -32,4 +35,11 @@ class ErrorPageFilterConfiguration {
return
new
ErrorPageFilter
();
}
@Bean
FilterRegistrationBean
<
ErrorPageFilter
>
errorPageFilterRegistration
(
ErrorPageFilter
filter
)
{
FilterRegistrationBean
<
ErrorPageFilter
>
registration
=
new
FilterRegistrationBean
<>(
filter
);
registration
.
setDispatcherTypes
(
DispatcherType
.
REQUEST
,
DispatcherType
.
ASYNC
);
return
registration
;
}
}
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/support/SpringBootServletInitializerTests.java
View file @
6ee0f8df
...
...
@@ -17,9 +17,12 @@
package
org
.
springframework
.
boot
.
web
.
servlet
.
support
;
import
java.util.Collections
;
import
java.util.EnumSet
;
import
java.util.Map
;
import
java.util.Vector
;
import
java.util.concurrent.atomic.AtomicBoolean
;
import
javax.servlet.DispatcherType
;
import
javax.servlet.ServletContext
;
import
javax.servlet.ServletContextEvent
;
import
javax.servlet.ServletContextListener
;
...
...
@@ -37,6 +40,7 @@ import org.springframework.boot.testsupport.system.CapturedOutput;
import
org.springframework.boot.testsupport.system.OutputCaptureExtension
;
import
org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory
;
import
org.springframework.boot.web.server.WebServer
;
import
org.springframework.boot.web.servlet.FilterRegistrationBean
;
import
org.springframework.boot.web.servlet.server.ServletWebServerFactory
;
import
org.springframework.context.ApplicationListener
;
import
org.springframework.context.ConfigurableApplicationContext
;
...
...
@@ -129,6 +133,28 @@ class SpringBootServletInitializerTests {
}
}
@Test
@SuppressWarnings
(
"rawtypes"
)
void
errorPageFilterIsRegisteredForRequestAndAsyncDispatch
()
{
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
).
hasFieldOrPropertyWithValue
(
"dispatcherTypes"
,
EnumSet
.
of
(
DispatcherType
.
ASYNC
,
DispatcherType
.
REQUEST
));
}
});
try
{
webServer
.
start
();
}
finally
{
webServer
.
stop
();
}
}
@Test
void
executableWarThatUsesServletInitializerDoesNotHaveErrorPageFilterConfigured
()
{
try
(
ConfigurableApplicationContext
context
=
new
SpringApplication
(
ExecutableWar
.
class
).
run
())
{
...
...
@@ -237,6 +263,11 @@ class SpringBootServletInitializerTests {
}
@Configuration
(
proxyBeanMethods
=
false
)
static
class
WithErrorPageFilter
extends
SpringBootServletInitializer
{
}
@Configuration
(
proxyBeanMethods
=
false
)
static
class
ExecutableWar
extends
SpringBootServletInitializer
{
...
...
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