Skip to content

Commit d8abbc5

Browse files
committed
CorsInterceptor skips async dispatch
Closes gh-24223
1 parent 6ce19ff commit d8abbc5

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

spring-webmvc/src/main/java/org/springframework/web/servlet/handler/AbstractHandlerMapping.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
import org.springframework.util.PathMatcher;
3737
import org.springframework.web.HttpRequestHandler;
3838
import org.springframework.web.context.request.WebRequestInterceptor;
39+
import org.springframework.web.context.request.async.WebAsyncManager;
40+
import org.springframework.web.context.request.async.WebAsyncUtils;
3941
import org.springframework.web.context.support.WebApplicationObjectSupport;
4042
import org.springframework.web.cors.CorsConfiguration;
4143
import org.springframework.web.cors.CorsConfigurationSource;
@@ -569,6 +571,12 @@ public CorsInterceptor(@Nullable CorsConfiguration config) {
569571
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
570572
throws Exception {
571573

574+
// Consistent with CorsFilter, ignore ASYNC dispatches
575+
WebAsyncManager asyncManager = WebAsyncUtils.getAsyncManager(request);
576+
if (asyncManager.hasConcurrentResult()) {
577+
return true;
578+
}
579+
572580
return corsProcessor.processRequest(this.config, request, response);
573581
}
574582

0 commit comments

Comments
 (0)