Skip to content

Commit 325fb5d

Browse files
committed
Unwrap CompletionException in return value handler
See gh-22476
1 parent b3bc2d9 commit 325fb5d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/DeferredResultMethodReturnValueHandler.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,6 +16,7 @@
1616

1717
package org.springframework.web.servlet.mvc.method.annotation;
1818

19+
import java.util.concurrent.CompletionException;
1920
import java.util.concurrent.CompletionStage;
2021
import java.util.function.BiFunction;
2122

@@ -93,6 +94,9 @@ private DeferredResult<Object> adaptCompletionStage(CompletionStage<?> future) {
9394
DeferredResult<Object> result = new DeferredResult<>();
9495
future.handle((BiFunction<Object, Throwable, Object>) (value, ex) -> {
9596
if (ex != null) {
97+
if (ex instanceof CompletionException && ex.getCause() != null) {
98+
ex = ex.getCause();
99+
}
96100
result.setErrorResult(ex);
97101
}
98102
else {

0 commit comments

Comments
 (0)