-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Description:
Multiple SharedPreferences files are accessed from different threads without proper synchronization, creating race conditions.
Affected Files:
- ThemeManager.kt: "app_prefs"
- CashuWalletManager.kt: "CashuWalletPrefs"
- ModernPOSActivity.kt: "NumoPrefs"
- AmountDisplayManager.kt: preference access
Issues:
- Inconsistent preference file naming
- No synchronization for concurrent access
- Potential data corruption in multi-threaded scenarios
Fix Instructions:
Option 1 - Add synchronization:
@Synchronized
private fun getPrefs(): SharedPreferences {
return context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE)
}Option 2 - Migrate to DataStore (recommended):
// Replace SharedPreferences with Jetpack DataStore
implementation "androidx.datastore:datastore-preferences:1.0.0"Recommendation: Migrate to DataStore for better thread safety and async support.
Metadata
Metadata
Assignees
Labels
No labels