Open Bwaim opened 2 years ago
I think the reason should be that two DataStore's writing at the same time, one of the renames seems to be failing, because the file no longer exists.
I think the place where the problem occurs should be in the TestDataStoreModule.kt
file, We should instead create the DataStore once, then inject the instance where necessary or manage it as a singleton.
Hi, is this still an issue with the latest version?
FWIW, on a Windows machine, I'm unable to run the whole test suite. Many unit tests fail while SingleProcessDataStore
tries to write the new data as shown above.
androidx.datastore:datastore-*:1.1.0-beta02
landed:
Fixed the issue where file rename fails during updateData in non-Android JVM environments. (b/203087070) https://developer.android.com/jetpack/androidx/releases/datastore#1.1.0-beta02
Unfortunately, the issue persists...
Hello @SimonMarquis I am also experiencing this java.io.IOException: Unable to rename C:\Users\User\AppData\Local\Temp\junit481202955115791832\user_preferences_test.pb.tmp.This likely means that there are multiple instances of DataStore for this file. Ensure that you are only creating a single instance of datastore for this file.
Is there a way to make this work on my Windows 10?
No, but you can ⭐ & +1 this issue: https://issuetracker.google.com/issues/203087070
@Bwaim a fix has been implemented in #1542, can you check if the fix works for you as well?
@SimonMarquis unfortunately I can't check as I don't have a Windows anymore 😞
Is there an existing issue for this?
Is there a StackOverflow question about this issue?
What happened?
Windows environment Running the unit test offlineFirstTopicsRepository_toggle_followed_topics_logic_delegates_to_nia_preferences() fails. There is an exception thrown that is cached but the log of this exception causes crash because it's not mocked, the original exception is :
java.io.IOException: Unable to rename C:\xxxxx\Temp\junit2206256684596171052\user_preferences_test.pb.tmp.This likely means that there are multiple instances of DataStore for this file. Ensure that you are only creating a single instance of datastore for this file.
The stacktrace :
I think the problem is because the test was executed under a Windows environment and the rename failed on that platform (
SingleProcessDataStore.kt : 432
) :Relevant logcat output
Code of Conduct