Unwrap CompletionException in return value handler
See gh-22476
This commit is contained in:
parent
b3bc2d9253
commit
325fb5d97e
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2019 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.
|
||||
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
package org.springframework.web.servlet.mvc.method.annotation;
|
||||
|
||||
import java.util.concurrent.CompletionException;
|
||||
import java.util.concurrent.CompletionStage;
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
|
|
@ -93,6 +94,9 @@ public class DeferredResultMethodReturnValueHandler implements HandlerMethodRetu
|
|||
DeferredResult<Object> result = new DeferredResult<>();
|
||||
future.handle((BiFunction<Object, Throwable, Object>) (value, ex) -> {
|
||||
if (ex != null) {
|
||||
if (ex instanceof CompletionException && ex.getCause() != null) {
|
||||
ex = ex.getCause();
|
||||
}
|
||||
result.setErrorResult(ex);
|
||||
}
|
||||
else {
|
||||
|
|
|
|||
Loading…
Reference in New Issue