@@ -36,6 +36,9 @@ public abstract class WebAsyncUtils {
36
36
37
37
public static final String WEB_ASYNC_MANAGER_ATTRIBUTE = WebAsyncManager .class .getName () + ".WEB_ASYNC_MANAGER" ;
38
38
39
+ private static Constructor <?> standardAsyncRequestConstructor ;
40
+
41
+
39
42
/**
40
43
* Obtain the {@link WebAsyncManager} for the current request, or if not
41
44
* found, create and associate it with the request.
@@ -80,10 +83,12 @@ public static AsyncWebRequest createAsyncWebRequest(HttpServletRequest request,
80
83
81
84
private static AsyncWebRequest createStandardServletAsyncWebRequest (HttpServletRequest request , HttpServletResponse response ) {
82
85
try {
83
- String className = "org.springframework.web.context.request.async.StandardServletAsyncWebRequest" ;
84
- Class <?> clazz = ClassUtils .forName (className , WebAsyncUtils .class .getClassLoader ());
85
- Constructor <?> constructor = clazz .getConstructor (HttpServletRequest .class , HttpServletResponse .class );
86
- return (AsyncWebRequest ) BeanUtils .instantiateClass (constructor , request , response );
86
+ if (standardAsyncRequestConstructor == null ) {
87
+ String className = "org.springframework.web.context.request.async.StandardServletAsyncWebRequest" ;
88
+ Class <?> clazz = ClassUtils .forName (className , WebAsyncUtils .class .getClassLoader ());
89
+ standardAsyncRequestConstructor = clazz .getConstructor (HttpServletRequest .class , HttpServletResponse .class );
90
+ }
91
+ return (AsyncWebRequest ) BeanUtils .instantiateClass (standardAsyncRequestConstructor , request , response );
87
92
}
88
93
catch (Throwable t ) {
89
94
throw new IllegalStateException ("Failed to instantiate StandardServletAsyncWebRequest" , t );
0 commit comments