Skip to content

Commit

Permalink
Fixed BulkheadAspect: An ExecutionException is wrapped by a Completio…
Browse files Browse the repository at this point in the history
…nException, but instead the cause should be wrapped. (ReactiveX#841)

Fixed FixedThreadPoolBulkhead: A CompletionException should not be wrapped inside of another CompletionException.
  • Loading branch information
RobWin authored Feb 4, 2020
1 parent eb96750 commit 22931ca
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ public <T> CompletableFuture<T> submit(Callable<T> callable) {
publishBulkheadEvent(() -> new BulkheadOnCallPermittedEvent(name));
return callable.call();
} catch (Exception e) {
if(e instanceof CompletionException){
throw (CompletionException)e;
}
throw new CompletionException(e);
}
}), executorService).whenComplete((result, throwable) -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import java.util.List;
import java.util.concurrent.CompletionException;
import java.util.concurrent.CompletionStage;
import java.util.concurrent.ExecutionException;

/**
* This Spring AOP aspect intercepts all methods which are annotated with a {@link Bulkhead}
Expand Down Expand Up @@ -249,8 +250,10 @@ private Object proceedInThreadPoolBulkhead(ProceedingJoinPoint proceedingJoinPoi
try {
return ((CompletionStage<?>) proceedingJoinPoint.proceed())
.toCompletableFuture().get();
} catch (Throwable throwable) {
throw new CompletionException(throwable);
} catch (ExecutionException e) {
throw new CompletionException(e.getCause());
} catch (Throwable e) {
throw new CompletionException(e);
}
});
} else {
Expand Down

0 comments on commit 22931ca

Please sign in to comment.