Skip to content

Commit

Permalink
fix: fix not call close in strict mode (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
yuhao900914 authored Aug 5, 2022
1 parent bf497d9 commit 20bf7ef
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions id/src/main/java/com/amplitude/id/utilities/PropertiesFile.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,19 @@ class PropertiesFile(directory: File, key: String, prefix: String) : KeyValueSto
*/
fun load() {
if (propertiesFile.exists()) {
underlyingProperties.load(FileInputStream(propertiesFile))
FileInputStream(propertiesFile).use {
underlyingProperties.load(it)
}
} else {
propertiesFile.parentFile.mkdirs()
propertiesFile.createNewFile()
}
}

private fun save() {
underlyingProperties.store(FileOutputStream(propertiesFile), null)
FileOutputStream(propertiesFile).use {
underlyingProperties.store(it, null)
}
}

override fun getLong(key: String, defaultVal: Long): Long =
Expand Down

0 comments on commit 20bf7ef

Please sign in to comment.