Merge branch '6.1.x'
This commit is contained in:
commit
87ea3bd31a
|
|
@ -142,8 +142,8 @@ public final class WebAsyncManager {
|
|||
}
|
||||
|
||||
/**
|
||||
* Whether the selected handler for the current request chose to handle the
|
||||
* request asynchronously. A return value of "true" indicates concurrent
|
||||
* Return whether the selected handler for the current request chose to handle
|
||||
* the request asynchronously. A return value of "true" indicates concurrent
|
||||
* handling is under way and the response will remain open. A return value
|
||||
* of "false" means concurrent handling was either not started or possibly
|
||||
* that it has completed and the request was dispatched for further
|
||||
|
|
@ -154,16 +154,16 @@ public final class WebAsyncManager {
|
|||
}
|
||||
|
||||
/**
|
||||
* Whether a result value exists as a result of concurrent handling.
|
||||
* Return whether a result value exists as a result of concurrent handling.
|
||||
*/
|
||||
public boolean hasConcurrentResult() {
|
||||
return (this.concurrentResult != RESULT_NONE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides access to the result from concurrent handling.
|
||||
* Get the result from concurrent handling.
|
||||
* @return an Object, possibly an {@code Exception} or {@code Throwable} if
|
||||
* concurrent handling raised one.
|
||||
* concurrent handling raised one
|
||||
* @see #clearConcurrentResult()
|
||||
*/
|
||||
@Nullable
|
||||
|
|
@ -172,8 +172,7 @@ public final class WebAsyncManager {
|
|||
}
|
||||
|
||||
/**
|
||||
* Provides access to additional processing context saved at the start of
|
||||
* concurrent handling.
|
||||
* Get the additional processing context saved at the start of concurrent handling.
|
||||
* @see #clearConcurrentResult()
|
||||
*/
|
||||
@Nullable
|
||||
|
|
@ -214,7 +213,7 @@ public final class WebAsyncManager {
|
|||
|
||||
/**
|
||||
* Register a {@link CallableProcessingInterceptor} without a key.
|
||||
* The key is derived from the class name and hashcode.
|
||||
* The key is derived from the class name and hash code.
|
||||
* @param interceptors one or more interceptors to register
|
||||
*/
|
||||
public void registerCallableInterceptors(CallableProcessingInterceptor... interceptors) {
|
||||
|
|
@ -237,8 +236,8 @@ public final class WebAsyncManager {
|
|||
}
|
||||
|
||||
/**
|
||||
* Register one or more {@link DeferredResultProcessingInterceptor DeferredResultProcessingInterceptors} without a specified key.
|
||||
* The default key is derived from the interceptor class name and hash code.
|
||||
* Register one or more {@link DeferredResultProcessingInterceptor DeferredResultProcessingInterceptors}
|
||||
* without a specified key. The default key is derived from the interceptor class name and hash code.
|
||||
* @param interceptors one or more interceptors to register
|
||||
*/
|
||||
public void registerDeferredResultInterceptors(DeferredResultProcessingInterceptor... interceptors) {
|
||||
|
|
@ -314,7 +313,7 @@ public final class WebAsyncManager {
|
|||
|
||||
this.asyncWebRequest.addTimeoutHandler(() -> {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Async request timeout for " + formatRequestUri());
|
||||
logger.debug("Async request timeout for " + formatUri(this.asyncWebRequest));
|
||||
}
|
||||
Object result = interceptorChain.triggerAfterTimeout(this.asyncWebRequest, callable);
|
||||
if (result != CallableProcessingInterceptor.RESULT_NONE) {
|
||||
|
|
@ -325,7 +324,7 @@ public final class WebAsyncManager {
|
|||
this.asyncWebRequest.addErrorHandler(ex -> {
|
||||
if (!this.errorHandlingInProgress) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Async request error for " + formatRequestUri() + ": " + ex);
|
||||
logger.debug("Async request error for " + formatUri(this.asyncWebRequest) + ": " + ex);
|
||||
}
|
||||
Object result = interceptorChain.triggerAfterError(this.asyncWebRequest, callable, ex);
|
||||
result = (result != CallableProcessingInterceptor.RESULT_NONE ? result : ex);
|
||||
|
|
@ -361,11 +360,6 @@ public final class WebAsyncManager {
|
|||
}
|
||||
}
|
||||
|
||||
private String formatRequestUri() {
|
||||
HttpServletRequest request = this.asyncWebRequest.getNativeRequest(HttpServletRequest.class);
|
||||
return request != null ? request.getRequestURI() : "servlet container";
|
||||
}
|
||||
|
||||
private void setConcurrentResultAndDispatch(@Nullable Object result) {
|
||||
synchronized (WebAsyncManager.this) {
|
||||
if (this.concurrentResult != RESULT_NONE) {
|
||||
|
|
@ -375,9 +369,10 @@ public final class WebAsyncManager {
|
|||
this.errorHandlingInProgress = (result instanceof Throwable);
|
||||
}
|
||||
|
||||
Assert.state(this.asyncWebRequest != null, "AsyncWebRequest must not be null");
|
||||
if (this.asyncWebRequest.isAsyncComplete()) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Async result set but request already complete: " + formatRequestUri());
|
||||
logger.debug("Async result set but request already complete: " + formatUri(this.asyncWebRequest));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
@ -388,7 +383,7 @@ public final class WebAsyncManager {
|
|||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Async " + (this.errorHandlingInProgress ? "error" : "result set") +
|
||||
", dispatch to " + formatRequestUri());
|
||||
", dispatch to " + formatUri(this.asyncWebRequest));
|
||||
}
|
||||
this.asyncWebRequest.dispatch();
|
||||
}
|
||||
|
|
@ -472,11 +467,17 @@ public final class WebAsyncManager {
|
|||
this.concurrentResultContext = processingContext;
|
||||
this.errorHandlingInProgress = false;
|
||||
}
|
||||
this.asyncWebRequest.startAsync();
|
||||
|
||||
Assert.state(this.asyncWebRequest != null, "AsyncWebRequest must not be null");
|
||||
this.asyncWebRequest.startAsync();
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Started async request");
|
||||
}
|
||||
}
|
||||
|
||||
private static String formatUri(AsyncWebRequest asyncWebRequest) {
|
||||
HttpServletRequest request = asyncWebRequest.getNativeRequest(HttpServletRequest.class);
|
||||
return (request != null ? request.getRequestURI() : "servlet container");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -47,12 +47,16 @@ public class WebAsyncTask<V> implements BeanFactoryAware {
|
|||
@Nullable
|
||||
private final String executorName;
|
||||
|
||||
@Nullable
|
||||
private BeanFactory beanFactory;
|
||||
|
||||
@Nullable
|
||||
private Callable<V> timeoutCallback;
|
||||
|
||||
@Nullable
|
||||
private Callable<V> errorCallback;
|
||||
|
||||
@Nullable
|
||||
private Runnable completionCallback;
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue