diff --git a/Kuroba/app/src/main/java/com/github/adamantcheese/chan/Chan.java b/Kuroba/app/src/main/java/com/github/adamantcheese/chan/Chan.java index dad5e843c3..7a7891a4c2 100644 --- a/Kuroba/app/src/main/java/com/github/adamantcheese/chan/Chan.java +++ b/Kuroba/app/src/main/java/com/github/adamantcheese/chan/Chan.java @@ -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 diff --git a/Kuroba/app/src/main/java/com/github/adamantcheese/chan/core/database/DatabaseManager.java b/Kuroba/app/src/main/java/com/github/adamantcheese/chan/core/database/DatabaseManager.java index 626334e1c6..350e6c1ae2 100644 --- a/Kuroba/app/src/main/java/com/github/adamantcheese/chan/core/database/DatabaseManager.java +++ b/Kuroba/app/src/main/java/com/github/adamantcheese/chan/core/database/DatabaseManager.java @@ -207,7 +207,12 @@ public void runTaskAsync(final Callable taskCallable, final TaskResult public T runTask(final Callable 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); } }