WebAsyncManager defensively ignores attribute type mismatch
Issue: SPR-15709
This commit is contained in:
parent
af69c5b6a9
commit
c4694c3f5c
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2016 the original author or authors.
|
* Copyright 2002-2017 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -32,7 +32,8 @@ import org.springframework.web.context.request.WebRequest;
|
||||||
*/
|
*/
|
||||||
public abstract class WebAsyncUtils {
|
public abstract class WebAsyncUtils {
|
||||||
|
|
||||||
public static final String WEB_ASYNC_MANAGER_ATTRIBUTE = WebAsyncManager.class.getName() + ".WEB_ASYNC_MANAGER";
|
public static final String WEB_ASYNC_MANAGER_ATTRIBUTE =
|
||||||
|
WebAsyncManager.class.getName() + ".WEB_ASYNC_MANAGER";
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -40,7 +41,11 @@ public abstract class WebAsyncUtils {
|
||||||
* found, create and associate it with the request.
|
* found, create and associate it with the request.
|
||||||
*/
|
*/
|
||||||
public static WebAsyncManager getAsyncManager(ServletRequest servletRequest) {
|
public static WebAsyncManager getAsyncManager(ServletRequest servletRequest) {
|
||||||
WebAsyncManager asyncManager = (WebAsyncManager) servletRequest.getAttribute(WEB_ASYNC_MANAGER_ATTRIBUTE);
|
WebAsyncManager asyncManager = null;
|
||||||
|
Object asyncManagerAttr = servletRequest.getAttribute(WEB_ASYNC_MANAGER_ATTRIBUTE);
|
||||||
|
if (asyncManagerAttr instanceof WebAsyncManager) {
|
||||||
|
asyncManager = (WebAsyncManager) asyncManagerAttr;
|
||||||
|
}
|
||||||
if (asyncManager == null) {
|
if (asyncManager == null) {
|
||||||
asyncManager = new WebAsyncManager();
|
asyncManager = new WebAsyncManager();
|
||||||
servletRequest.setAttribute(WEB_ASYNC_MANAGER_ATTRIBUTE, asyncManager);
|
servletRequest.setAttribute(WEB_ASYNC_MANAGER_ATTRIBUTE, asyncManager);
|
||||||
|
@ -54,7 +59,11 @@ public abstract class WebAsyncUtils {
|
||||||
*/
|
*/
|
||||||
public static WebAsyncManager getAsyncManager(WebRequest webRequest) {
|
public static WebAsyncManager getAsyncManager(WebRequest webRequest) {
|
||||||
int scope = RequestAttributes.SCOPE_REQUEST;
|
int scope = RequestAttributes.SCOPE_REQUEST;
|
||||||
WebAsyncManager asyncManager = (WebAsyncManager) webRequest.getAttribute(WEB_ASYNC_MANAGER_ATTRIBUTE, scope);
|
WebAsyncManager asyncManager = null;
|
||||||
|
Object asyncManagerAttr = webRequest.getAttribute(WEB_ASYNC_MANAGER_ATTRIBUTE, scope);
|
||||||
|
if (asyncManagerAttr instanceof WebAsyncManager) {
|
||||||
|
asyncManager = (WebAsyncManager) asyncManagerAttr;
|
||||||
|
}
|
||||||
if (asyncManager == null) {
|
if (asyncManager == null) {
|
||||||
asyncManager = new WebAsyncManager();
|
asyncManager = new WebAsyncManager();
|
||||||
webRequest.setAttribute(WEB_ASYNC_MANAGER_ATTRIBUTE, asyncManager, scope);
|
webRequest.setAttribute(WEB_ASYNC_MANAGER_ATTRIBUTE, asyncManager, scope);
|
||||||
|
|
Loading…
Reference in New Issue