Status Update
Comments
ly...@gmail.com <ly...@gmail.com> #2
This happens when blocking thread interrupted.
Use case: RxJava, When switchMap is upstream, downstream blocking operation will be interrupted.
In older version room, runInTransaction is not interruptible, never throws exception like this.
da...@google.com <da...@google.com> #3
We updated Room internals to Coroutines and one of the improvements is interruption. Before the internal changes, Room would ignore thread interruption, database operations where not really cancellable, but in the latest version and due to Coroutines, Room can be interrupted but since it has to return some value which it couldn't compute it then throws InterruptedException
as part of the runBlocking
used to bridge blocking DAO functions with Coroutine internals. I think you will need to handle the exception as any other and determine what to return or ignore since Room can't make that decision for you.
ly...@gmail.com <ly...@gmail.com> #4
That's a big change.
I think some method should be marked with @Throws(InterruptedException::class)
like runBlocking.
ly...@gmail.com <ly...@gmail.com> #5
runBlocking used to bridge blocking DAO functions with Coroutine internals
It seems that all non-suspend DAO query function are throws InterruptedException
.
Huge migration.
da...@google.com <da...@google.com> #6
An update: I agree this is a big behavior change and for compatibility reasons we want to continue having Room blocking DAO functions and API be uninterruptible. We are trying to work on a solution for this.
ap...@google.com <ap...@google.com> #7
Project: platform/frameworks/support
Branch: androidx-main
Author: Daniel Santiago Rivera <
Link:
Use Coroutines RxJava builders in RxRoom
Expand for full commit details
Use Coroutines RxJava builders in RxRoom
The coroutines-rxjava builders have better handling for cancellation and allows Room to use Coroutine internals more natively which in turns avoids performBlocking.
Bug: 400584611
Test: RxJava2Test and RxJava3Test
Change-Id: I639162c82584eea358d061d0e2c48ce0f260a47c
Files:
- M
room/integration-tests/kotlintestapp/src/androidTest/java/androidx/room/integration/kotlintestapp/test/DeferredBooksDaoTest.kt
- M
room/integration-tests/kotlintestapp/src/androidTest/java/androidx/room/integration/kotlintestapp/test/RxJava2QueryTest.kt
- M
room/integration-tests/kotlintestapp/src/androidTest/java/androidx/room/integration/kotlintestapp/test/UpsertTest.kt
- M
room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/test/RxJava2Test.java
- M
room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/test/RxJava3Test.java
- M
room/room-rxjava2/src/main/java/androidx/room/RxRoom.kt
- M
room/room-rxjava3/src/main/java/androidx/room/rxjava3/RxRoom.kt
Hash: 52899e0b7ab58364d7467f39dfee82cc3dc2c04d
Date: Wed Mar 12 11:38:37 2025
ap...@google.com <ap...@google.com> #8
Project: platform/frameworks/support
Branch: androidx-main
Author: Daniel Santiago Rivera <
Link:
Use an uninterruptible version of runBlocking
Expand for full commit details
Use an uninterruptible version of runBlocking
As part of Room KMP the internals in Room were migrated to Coroutines and for compatibility reasons blocking functions (APIs and generated code) where migrated to use a bridge that relied on runBlocking. This introduced a behaviour change where if the thread that called runBlocking was interrupted, then runBlocking would throw an InterruptedException. The behaviour in general is not bad since it means work is abandoned faster but it breaks behaviour compatibility as Room never threw this exception before.
To not break existing application and expectations this change adds a runBlockingUninterruptible to be used in Room's bridge that works like runBlocking but ignores thread interruption.
Bug: 342709652
Bug: 400584611
Test: RunBlockingUninterruptibleTest
Change-Id: Ib591225477829e77b51e65a14556d6caddc62222
Files:
- A
room/integration-tests/kotlintestapp/src/androidTest/java/androidx/room/integration/kotlintestapp/test/InterruptionTest.kt
- A
room/room-runtime/src/androidInstrumentedTest/kotlin/androidx/room/coroutines/RunBlockingUninterruptibleTest.kt
- M
room/room-runtime/src/androidMain/kotlin/androidx/room/InvalidationTracker.android.kt
- M
room/room-runtime/src/androidMain/kotlin/androidx/room/RoomDatabase.android.kt
- A
room/room-runtime/src/androidMain/kotlin/androidx/room/coroutines/RunBlockingUninterruptible.android.kt
- M
room/room-runtime/src/androidMain/kotlin/androidx/room/util/DBUtil.android.kt
Hash: e20fec969cc938655537f87624a6f45e942c370d
Date: Thu Mar 13 10:37:44 2025
Description
Component used:room
Version used:2.7.0-rc01
Exception
PS, please don't reference my email in comment