Skip to content

Commit

Permalink
Merge pull request #3361 from artem-zinnatullin/blocking-to-future-be…
Browse files Browse the repository at this point in the history
…tter-error-handling

Safer error handling in BlockingOperatorToFuture
  • Loading branch information
abersnaze committed Oct 7, 2015
2 parents 5b50c3a + 82c13b0 commit aed1186
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,10 @@ public T get(long timeout, TimeUnit unit) throws InterruptedException, Execution
}

private T getValue() throws ExecutionException {
if (error.get() != null) {
throw new ExecutionException("Observable onError", error.get());
final Throwable throwable = error.get();

if (throwable != null) {
throw new ExecutionException("Observable onError", throwable);
} else if (cancelled) {
// Contract of Future.get() requires us to throw this:
throw new CancellationException("Subscription unsubscribed");
Expand Down

0 comments on commit aed1186

Please sign in to comment.