Skip to content

Commit b02bda9

Browse files
committed
Document better ASYNC dispatch type config for Filters
Although the need to map the ASYNC dispatcher type to a Filter was already mentioned, it wasn't very prominent and can be quite critical in some cases. This change addresses that. Issue: SPR-10440
1 parent b70148c commit b02bda9

File tree

1 file changed

+39
-1
lines changed

1 file changed

+39
-1
lines changed

src/asciidoc/index.adoc

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29960,7 +29960,8 @@ To use Servlet 3 async request processing, you need to update `web.xml` to versi
2996029960
----
2996129961
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
2996229962
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
29963-
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
29963+
http://java.sun.com/xml/ns/javaee
29964+
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
2996429965
version="3.0">
2996529966

2996629967
...
@@ -29975,6 +29976,43 @@ ASYNC dispatcher type. Note that it is safe to enable the ASYNC dispatcher type
2997529976
filters provided with the Spring Framework since they will not get involved in async
2997629977
dispatches unless needed.
2997729978

29979+
[WARNING]
29980+
====
29981+
Note that for some Filters it is absolutely critical to ensure they are mapped to
29982+
be invoked during asynchronous dispatches. For example if a filter such as the
29983+
`OpenEntityManagerInViewFilter` is responsible for releasing database connection
29984+
resources and must be invoked at the end of an async request.
29985+
29986+
Below is an example of a propertly configured filter:
29987+
====
29988+
29989+
[source,xml,indent=0]
29990+
[subs="verbatim,quotes"]
29991+
----
29992+
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
29993+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
29994+
xsi:schemaLocation="
29995+
http://java.sun.com/xml/ns/javaee
29996+
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
29997+
version="3.0">
29998+
29999+
<filter>
30000+
<filter-name>Spring OpenEntityManagerInViewFilter</filter-name>
30001+
<filter-class>org.springframework.~.OpenEntityManagerInViewFilter</filter-class>
30002+
<async-supported>true</async-supported>
30003+
</filter>
30004+
30005+
<filter-mapping>
30006+
<filter-name>Spring OpenEntityManagerInViewFilter</filter-name>
30007+
<url-pattern>/*</url-pattern>
30008+
<dispatcher>REQUEST</dispatcher>
30009+
<dispatcher>ASYNC</dispatcher>
30010+
</filter-mapping>
30011+
30012+
</web-app>
30013+
30014+
----
30015+
2997830016
If using Servlet 3, Java based configuration, e.g. via `WebApplicationInitializer`,
2997930017
you'll also need to set the "asyncSupported" flag as well as the ASYNC dispatcher type
2998030018
just like with `web.xml`. To simplify all this configuration, consider extending

0 commit comments

Comments
 (0)