@@ -142,8 +142,8 @@ public void setTaskExecutor(AsyncTaskExecutor taskExecutor) {
142142 }
143143
144144 /**
145- * Whether the selected handler for the current request chose to handle the
146- * request asynchronously. A return value of "true" indicates concurrent
145+ * Return whether the selected handler for the current request chose to handle
146+ * the request asynchronously. A return value of "true" indicates concurrent
147147 * handling is under way and the response will remain open. A return value
148148 * of "false" means concurrent handling was either not started or possibly
149149 * that it has completed and the request was dispatched for further
@@ -154,16 +154,16 @@ public boolean isConcurrentHandlingStarted() {
154154 }
155155
156156 /**
157- * Whether a result value exists as a result of concurrent handling.
157+ * Return whether a result value exists as a result of concurrent handling.
158158 */
159159 public boolean hasConcurrentResult () {
160160 return (this .concurrentResult != RESULT_NONE );
161161 }
162162
163163 /**
164- * Provides access to the result from concurrent handling.
164+ * Get the result from concurrent handling.
165165 * @return an Object, possibly an {@code Exception} or {@code Throwable} if
166- * concurrent handling raised one.
166+ * concurrent handling raised one
167167 * @see #clearConcurrentResult()
168168 */
169169 @ Nullable
@@ -172,8 +172,7 @@ public Object getConcurrentResult() {
172172 }
173173
174174 /**
175- * Provides access to additional processing context saved at the start of
176- * concurrent handling.
175+ * Get the additional processing context saved at the start of concurrent handling.
177176 * @see #clearConcurrentResult()
178177 */
179178 @ Nullable
@@ -214,7 +213,7 @@ public void registerCallableInterceptor(Object key, CallableProcessingIntercepto
214213
215214 /**
216215 * Register a {@link CallableProcessingInterceptor} without a key.
217- * The key is derived from the class name and hashcode .
216+ * The key is derived from the class name and hash code .
218217 * @param interceptors one or more interceptors to register
219218 */
220219 public void registerCallableInterceptors (CallableProcessingInterceptor ... interceptors ) {
@@ -237,8 +236,8 @@ public void registerDeferredResultInterceptor(Object key, DeferredResultProcessi
237236 }
238237
239238 /**
240- * Register one or more {@link DeferredResultProcessingInterceptor DeferredResultProcessingInterceptors} without a specified key.
241- * The default key is derived from the interceptor class name and hash code.
239+ * Register one or more {@link DeferredResultProcessingInterceptor DeferredResultProcessingInterceptors}
240+ * without a specified key. The default key is derived from the interceptor class name and hash code.
242241 * @param interceptors one or more interceptors to register
243242 */
244243 public void registerDeferredResultInterceptors (DeferredResultProcessingInterceptor ... interceptors ) {
@@ -314,7 +313,7 @@ public void startCallableProcessing(final WebAsyncTask<?> webAsyncTask, Object..
314313
315314 this .asyncWebRequest .addTimeoutHandler (() -> {
316315 if (logger .isDebugEnabled ()) {
317- logger .debug ("Async request timeout for " + formatRequestUri ( ));
316+ logger .debug ("Async request timeout for " + formatUri ( this . asyncWebRequest ));
318317 }
319318 Object result = interceptorChain .triggerAfterTimeout (this .asyncWebRequest , callable );
320319 if (result != CallableProcessingInterceptor .RESULT_NONE ) {
@@ -325,7 +324,7 @@ public void startCallableProcessing(final WebAsyncTask<?> webAsyncTask, Object..
325324 this .asyncWebRequest .addErrorHandler (ex -> {
326325 if (!this .errorHandlingInProgress ) {
327326 if (logger .isDebugEnabled ()) {
328- logger .debug ("Async request error for " + formatRequestUri ( ) + ": " + ex );
327+ logger .debug ("Async request error for " + formatUri ( this . asyncWebRequest ) + ": " + ex );
329328 }
330329 Object result = interceptorChain .triggerAfterError (this .asyncWebRequest , callable , ex );
331330 result = (result != CallableProcessingInterceptor .RESULT_NONE ? result : ex );
@@ -361,11 +360,6 @@ public void startCallableProcessing(final WebAsyncTask<?> webAsyncTask, Object..
361360 }
362361 }
363362
364- private String formatRequestUri () {
365- HttpServletRequest request = this .asyncWebRequest .getNativeRequest (HttpServletRequest .class );
366- return request != null ? request .getRequestURI () : "servlet container" ;
367- }
368-
369363 private void setConcurrentResultAndDispatch (@ Nullable Object result ) {
370364 synchronized (WebAsyncManager .this ) {
371365 if (this .concurrentResult != RESULT_NONE ) {
@@ -375,9 +369,10 @@ private void setConcurrentResultAndDispatch(@Nullable Object result) {
375369 this .errorHandlingInProgress = (result instanceof Throwable );
376370 }
377371
372+ Assert .state (this .asyncWebRequest != null , "AsyncWebRequest must not be null" );
378373 if (this .asyncWebRequest .isAsyncComplete ()) {
379374 if (logger .isDebugEnabled ()) {
380- logger .debug ("Async result set but request already complete: " + formatRequestUri ( ));
375+ logger .debug ("Async result set but request already complete: " + formatUri ( this . asyncWebRequest ));
381376 }
382377 return ;
383378 }
@@ -388,7 +383,7 @@ private void setConcurrentResultAndDispatch(@Nullable Object result) {
388383
389384 if (logger .isDebugEnabled ()) {
390385 logger .debug ("Async " + (this .errorHandlingInProgress ? "error" : "result set" ) +
391- ", dispatch to " + formatRequestUri ( ));
386+ ", dispatch to " + formatUri ( this . asyncWebRequest ));
392387 }
393388 this .asyncWebRequest .dispatch ();
394389 }
@@ -472,11 +467,17 @@ private void startAsyncProcessing(Object[] processingContext) {
472467 this .concurrentResultContext = processingContext ;
473468 this .errorHandlingInProgress = false ;
474469 }
475- this .asyncWebRequest .startAsync ();
476470
471+ Assert .state (this .asyncWebRequest != null , "AsyncWebRequest must not be null" );
472+ this .asyncWebRequest .startAsync ();
477473 if (logger .isDebugEnabled ()) {
478474 logger .debug ("Started async request" );
479475 }
480476 }
481477
478+ private static String formatUri (AsyncWebRequest asyncWebRequest ) {
479+ HttpServletRequest request = asyncWebRequest .getNativeRequest (HttpServletRequest .class );
480+ return (request != null ? request .getRequestURI () : "servlet container" );
481+ }
482+
482483}
0 commit comments