Polish
This commit is contained in:
parent
e0678ba583
commit
eb0479dee8
|
@ -46,6 +46,7 @@ public interface AsyncWebRequest extends NativeWebRequest {
|
|||
/**
|
||||
* Add a handler to invoke when an error occurred while concurrent
|
||||
* handling of a request.
|
||||
* @since 5.0
|
||||
*/
|
||||
void addErrorHandler(Consumer<Throwable> exceptionHandler);
|
||||
|
||||
|
|
|
@ -102,17 +102,18 @@ public interface CallableProcessingInterceptor {
|
|||
<T> Object handleTimeout(NativeWebRequest request, Callable<T> task) throws Exception;
|
||||
|
||||
/**
|
||||
* Invoked from a container thread when an error occurred while processing the async request
|
||||
* before the {@code Callable} task completes. Implementations may return a value,
|
||||
* including an {@link Exception}, to use instead of the value the
|
||||
* {@link Callable} did not return in time.
|
||||
* Invoked from a container thread when an error occurred while processing
|
||||
* the async request before the {@code Callable} task completes.
|
||||
* Implementations may return a value, including an {@link Exception}, to
|
||||
* use instead of the value the {@link Callable} did not return in time.
|
||||
* @param request the current request
|
||||
* @param task the task for the current async request
|
||||
* @paramt t the error that occurred while request processing
|
||||
* @param t the error that occurred while request processing
|
||||
* @return a concurrent result value; if the value is anything other than
|
||||
* {@link #RESULT_NONE} or {@link #RESPONSE_HANDLED}, concurrent processing
|
||||
* is resumed and subsequent interceptors are not invoked
|
||||
* @throws Exception in case of errors
|
||||
* @since 5.0
|
||||
*/
|
||||
<T> Object handleError(NativeWebRequest request, Callable<T> task, Throwable t) throws Exception;
|
||||
|
||||
|
|
|
@ -154,11 +154,13 @@ public class DeferredResult<T> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Register code to invoke when an error occurred while processing the async request.
|
||||
* <p>This method is called from a container thread when an error occurred while
|
||||
* processing an async request before the {@code DeferredResult} has been populated.
|
||||
* It may invoke {@link DeferredResult#setResult setResult} or
|
||||
* {@link DeferredResult#setErrorResult setErrorResult} to resume processing.
|
||||
* Register code to invoke when an error occurred during the async request.
|
||||
* <p>This method is called from a container thread when an error occurs
|
||||
* while processing an async request before the {@code DeferredResult} has
|
||||
* been populated. It may invoke {@link DeferredResult#setResult setResult}
|
||||
* or {@link DeferredResult#setErrorResult setErrorResult} to resume
|
||||
* processing.
|
||||
* @since 5.0
|
||||
*/
|
||||
public void onError(Consumer<Throwable> callback) {
|
||||
this.errorCallback = callback;
|
||||
|
|
|
@ -27,7 +27,7 @@ import org.springframework.web.context.request.NativeWebRequest;
|
|||
* @author Violeta Georgieva
|
||||
* @since 5.0
|
||||
*/
|
||||
public class ErrorCallableProcessingInterceptor extends CallableProcessingInterceptorAdapter {
|
||||
class ErrorCallableProcessingInterceptor extends CallableProcessingInterceptorAdapter {
|
||||
|
||||
@Override
|
||||
public <T> Object handleError(NativeWebRequest request, Callable<T> task, Throwable t) throws Exception {
|
||||
|
|
|
@ -143,23 +143,17 @@ public class StandardServletAsyncWebRequest extends ServletWebRequest implements
|
|||
|
||||
@Override
|
||||
public void onError(AsyncEvent event) throws IOException {
|
||||
for (Consumer<Throwable> handler : this.exceptionHandlers) {
|
||||
handler.accept(event.getThrowable());
|
||||
}
|
||||
this.exceptionHandlers.forEach(consumer -> consumer.accept(event.getThrowable()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTimeout(AsyncEvent event) throws IOException {
|
||||
for (Runnable handler : this.timeoutHandlers) {
|
||||
handler.run();
|
||||
}
|
||||
this.timeoutHandlers.forEach(Runnable::run);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete(AsyncEvent event) throws IOException {
|
||||
for (Runnable handler : this.completionHandlers) {
|
||||
handler.run();
|
||||
}
|
||||
this.completionHandlers.forEach(Runnable::run);
|
||||
this.asyncContext = null;
|
||||
this.asyncCompleted.set(true);
|
||||
}
|
||||
|
|
|
@ -153,12 +153,14 @@ public class WebAsyncTask<V> implements BeanFactoryAware {
|
|||
}
|
||||
|
||||
/**
|
||||
* Register code to invoke when an error occurred while processing the async request.
|
||||
* <p>This method is called from a container thread when an error occurred while processing
|
||||
* an async request before the {@code Callable} has completed. The callback is executed in
|
||||
* the same thread and therefore should return without blocking. It may return
|
||||
* an alternative value to use, including an {@link Exception} or return
|
||||
* Register code to invoke for an error during async request processing.
|
||||
* <p>This method is called from a container thread when an error occurred
|
||||
* while processing an async request before the {@code Callable} has
|
||||
* completed. The callback is executed in the same thread and therefore
|
||||
* should return without blocking. It may return an alternative value to
|
||||
* use, including an {@link Exception} or return
|
||||
* {@link CallableProcessingInterceptor#RESULT_NONE RESULT_NONE}.
|
||||
* @since 5.0
|
||||
*/
|
||||
public void onError(Callable<V> callback) {
|
||||
this.errorCallback = callback;
|
||||
|
|
|
@ -217,9 +217,10 @@ public class ResponseBodyEmitter {
|
|||
}
|
||||
|
||||
/**
|
||||
* Register code to invoke when an error occurred while processing the async request.
|
||||
* This method is called from a container thread when an error occurred while processing
|
||||
* an async request.
|
||||
* Register code to invoke for an error during async request processing.
|
||||
* This method is called from a container thread when an error occurred
|
||||
* while processing an async request.
|
||||
* @since 5.0
|
||||
*/
|
||||
public synchronized void onError(Consumer<Throwable> callback) {
|
||||
this.errorCallback.setDelegate(callback);
|
||||
|
|
Loading…
Reference in New Issue