11/*
2- * Copyright 2002-2015 the original author or authors.
2+ * Copyright 2002-2017 the original author or authors.
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
@@ -44,7 +44,11 @@ public abstract class WebAsyncUtils {
4444 * found, create and associate it with the request.
4545 */
4646 public static WebAsyncManager getAsyncManager (ServletRequest servletRequest ) {
47- WebAsyncManager asyncManager = (WebAsyncManager ) servletRequest .getAttribute (WEB_ASYNC_MANAGER_ATTRIBUTE );
47+ WebAsyncManager asyncManager = null ;
48+ Object asyncManagerAttr = servletRequest .getAttribute (WEB_ASYNC_MANAGER_ATTRIBUTE );
49+ if (asyncManagerAttr instanceof WebAsyncManager ) {
50+ asyncManager = (WebAsyncManager ) asyncManagerAttr ;
51+ }
4852 if (asyncManager == null ) {
4953 asyncManager = new WebAsyncManager ();
5054 servletRequest .setAttribute (WEB_ASYNC_MANAGER_ATTRIBUTE , asyncManager );
@@ -58,7 +62,11 @@ public static WebAsyncManager getAsyncManager(ServletRequest servletRequest) {
5862 */
5963 public static WebAsyncManager getAsyncManager (WebRequest webRequest ) {
6064 int scope = RequestAttributes .SCOPE_REQUEST ;
61- WebAsyncManager asyncManager = (WebAsyncManager ) webRequest .getAttribute (WEB_ASYNC_MANAGER_ATTRIBUTE , scope );
65+ WebAsyncManager asyncManager = null ;
66+ Object asyncManagerAttr = webRequest .getAttribute (WEB_ASYNC_MANAGER_ATTRIBUTE , scope );
67+ if (asyncManagerAttr instanceof WebAsyncManager ) {
68+ asyncManager = (WebAsyncManager ) asyncManagerAttr ;
69+ }
6270 if (asyncManager == null ) {
6371 asyncManager = new WebAsyncManager ();
6472 webRequest .setAttribute (WEB_ASYNC_MANAGER_ATTRIBUTE , asyncManager , scope );
0 commit comments