Fixed
Status Update
Comments
da...@google.com <da...@google.com> #2
Makes sense, thanks for the feedback!
el...@google.com <el...@google.com>
da...@google.com <da...@google.com>
ap...@google.com <ap...@google.com> #3
Project: platform/frameworks/support
Branch: androidx-main
Author: Daniel Santiago Rivera <
Link:
Check internal Room's isOpen before checking for inTransaction
Expand for full commit details
Check internal Room's isOpen before checking for inTransaction
Prevents the database from being re-opened if it already closed to check for if in a transaction.
Bug: 325432967
Bug: 344905716
Test: InTransactionTest
Change-Id: Ib8081aa5445a039aca72df1e4750b84e95e0ac2b
Files:
- A
room/integration-tests/kotlintestapp/src/androidTest/java/androidx/room/integration/kotlintestapp/test/InTransactionTest.kt
- M
room/room-runtime/src/androidMain/kotlin/androidx/room/RoomDatabase.android.kt
Hash: 11847b52aa5b0e4e3f4191d28745b4634393027b
Date: Wed Jun 05 10:19:56 2024
da...@google.com <da...@google.com>
pr...@google.com <pr...@google.com> #4
The following release(s) address this bug.It is possible this bug has only been partially addressed:
androidx.room:room-runtime:2.7.0-beta01
androidx.room:room-runtime-android:2.7.0-beta01
androidx.room:room-runtime-iosarm64:2.7.0-beta01
androidx.room:room-runtime-iossimulatorarm64:2.7.0-beta01
androidx.room:room-runtime-iosx64:2.7.0-beta01
androidx.room:room-runtime-jvm:2.7.0-beta01
androidx.room:room-runtime-linuxarm64:2.7.0-beta01
androidx.room:room-runtime-linuxx64:2.7.0-beta01
androidx.room:room-runtime-macosarm64:2.7.0-beta01
androidx.room:room-runtime-macosx64:2.7.0-beta01
jo...@gmail.com <jo...@gmail.com> #5
Does this change mean that after manually closing the database, we can rely on the fact that db will no longer be reopened by Room for any query?
Asking in context of implementing backup/restore feature in the app.
Asking in context of implementing backup/restore feature in the app.
da...@google.com <da...@google.com> #6
Thats right, an explicit close()
call will make it so that Room won't re-open itself, and if it is attempted to do so to some other call it will cause a crash.
Description
Component useds: androidx.room:room-ktx, androidx.room:room-testing Version used: 2.6.1 Devices/Android versions reproduced on: Robolectric
The definition of
Room.inTransaction()
is:This opens the db even if it wasn't previously open and doesn't close it. This is almost always going to be fine in production, but in tests it can cause a db leak, which is especially painful since it's called by room-internal code.
Since it's
open
, in my project I simply overrode it to bewhich resolved the issue and is similar to a check that most, but not all, room-internal code does anyway.
Would be great to have this catch in the framework though, to prevent this issue for others