Skip to content

Commit

Permalink
Merge pull request #782 from Adamantcheese/(#781)-filter-interrupted-…
Browse files Browse the repository at this point in the history
…excetions-coming-from-db-calls

(#781) Filter out InterruptedExceptions coming into RxJava onError handler inside RuntimeExceptions
  • Loading branch information
Adamantcheese authored Mar 3, 2020
2 parents 7810e30 + 16b0a14 commit 471196f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,11 @@ public void onCreate() {
// fine, some blocking code was interrupted by a dispose call
return;
}
if (e instanceof RuntimeException && e.getCause() instanceof InterruptedException) {
// fine, DB synchronous call (via runTask) was interrupted when a reactive stream
// was disposed of.
return;
}
if (e instanceof FileCacheException.CancellationException
|| e instanceof FileCacheException.FileNotFoundOnTheServerException) {
// fine, sometimes they get through all the checks but it doesn't really matter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,12 @@ public <T> void runTaskAsync(final Callable<T> taskCallable, final TaskResult<T>
public <T> T runTask(final Callable<T> taskCallable) {
try {
return executeTask(taskCallable, null).get();
} catch (InterruptedException | ExecutionException e) {
} catch (InterruptedException e) {
// Since we don't rethrow InterruptedException we need to at least restore the
// "interrupted" flag.
Thread.currentThread().interrupt();
throw new RuntimeException(e);
} catch (ExecutionException e) {
throw new RuntimeException(e);
}
}
Expand Down

0 comments on commit 471196f

Please sign in to comment.