Merge "Allow nullable locking directory in SupportSQLiteLock." into snap-temp-L60900000959093030
diff --git a/sqlite/sqlite-framework/src/main/java/androidx/sqlite/util/ProcessLock.kt b/sqlite/sqlite-framework/src/main/java/androidx/sqlite/util/ProcessLock.kt
index 3b79342..dc07eb9 100644
--- a/sqlite/sqlite-framework/src/main/java/androidx/sqlite/util/ProcessLock.kt
+++ b/sqlite/sqlite-framework/src/main/java/androidx/sqlite/util/ProcessLock.kt
@@ -52,12 +52,12 @@
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
class ProcessLock(
name: String,
- lockDir: File,
+ lockDir: File?,
private val processLock: Boolean
) {
- private val lockFile: File = File(lockDir, "$name.lck")
+ private val lockFile: File? = lockDir?.let { File(it, "$name.lck") }
@SuppressLint("SyntheticAccessor")
- private val threadLock: Lock = getThreadLock(lockFile.absolutePath)
+ private val threadLock: Lock = getThreadLock(name)
private var lockChannel: FileChannel? = null
/**
@@ -69,6 +69,9 @@
threadLock.lock()
if (processLock) {
try {
+ if (lockFile == null) {
+ throw IOException("No lock directory was provided.")
+ }
// Verify parent dir
val parentDir = lockFile.parentFile
parentDir?.mkdirs()