Status Update
Comments
np...@google.com <np...@google.com>
ba...@google.com <ba...@google.com> #2
Could you please confirm that this is a problem in the last Android Studio Stable version (Chipmunk)?
Thanks!
cm...@gmail.com <cm...@gmail.com> #3
aTalk uses Jarjar tool which is only compatible with android studio Electric Eel, the highest version supported.
So unable to entertain your request.
jl...@google.com <jl...@google.com> #4
Giraffe is the latest stable version, so it's safe to assume this will not be fixed in Electric Eel.
Please let us know if this persists in newer versions.
cm...@gmail.com <cm...@gmail.com> #5
Does this means your team has positively confirmed the reported problem has been fixed in Giraffe.
jl...@google.com <jl...@google.com>
tn...@google.com <tn...@google.com> #6
I created a repro scenario from this and I can still reproduce it:
@file:Suppress("unused", "MemberVisibilityCanBePrivate")
package test.pkg
import android.database.Cursor
import android.database.sqlite.SQLiteDatabase
import android.database.sqlite.SQLiteOpenHelper
private const val TABLE_NAME = "TABLE_NAME"
private const val COLUMN_NAME = "COLUMN_NAME"
private const val COLUMN_VALUE = "COLUMN_VALUE"
object AccountID {
const val ACCOUNT_UUID_PREFIX = "ACCOUNT_UUID_PREFIX"
const val TBL_PROPERTIES = "TBL_PROPERTIES"
const val ACCOUNT_UUID = "ACCOUNT_UUID"
}
class RecycleTest(private val openHelper: SQLiteOpenHelper) {
private val properties = mutableMapOf<String,Any>()
lateinit var mDB: SQLiteDatabase
fun getProperty(name: String): Any? {
var value: Any? = properties[name]
if (value == null) {
var cursor: Cursor? = null
val columns: Array<String> = arrayOf(COLUMN_VALUE)
synchronized(openHelper as Any) {
mDB = openHelper.readableDatabase
if (name.startsWith(AccountID.ACCOUNT_UUID_PREFIX)) {
val idx: Int = name.indexOf(".")
if (idx == -1) {
value = name // just return the accountUuid
} else {
val args: Array<String> = arrayOf(name.substring(0, idx), name.substring(idx + 1))
cursor = mDB.query(AccountID.TBL_PROPERTIES, columns,
AccountID.ACCOUNT_UUID + "=? AND " + COLUMN_NAME + "=?",
args, null, null, null, "1")
}
} else {
cursor = mDB.query(TABLE_NAME, columns,
"$COLUMN_NAME=?", arrayOf(name), null, null, null, "1")
}
if (cursor != null) {
try {
if ((cursor!!.count == 1) && cursor!!.moveToFirst()) value = cursor!!.getString(0)
} finally {
cursor!!.close()
}
}
}
if (value == null) value = System.getProperty(name)
}
return value
}
}
tn...@google.com <tn...@google.com> #7
Fixed by
Note that the root cause here was the "!!" which the dataflow analyzer wasn't handling correctly. If you change the code from "cursor!!.close()" to "cursor?.close()" older versions should stop flagging it as well.
cm...@gmail.com <cm...@gmail.com> #8
Note that the root cause here was the "!!" which the dataflow analyzer wasn't handling correctly. If you change the code from "cursor!!.close()" to "cursor?.close()" older versions should stop flagging it as well.
Yes, the above action also remove the error highlight
an...@google.com <an...@google.com> #9
Thank you for your patience while our engineering team worked to resolve this issue. A fix for this issue is now available in:
- Android Studio Iguana | 2023.2.1 Canary 11
- Android Gradle Plugin 8.3.0-alpha11
We encourage you to try the latest update.
If you notice further issues or have questions, please file a new bug report.
Thank you for taking the time to submit feedback — we really appreciate it!
Description
Build: AI-221.6008.13.2211.9514443, 202301210135,
AI-221.6008.13.2211.9514443, JRE 11.0.15+0-b2043.56-8887301x64 JetBrains s.r.o., OS Linux(amd64) v6.2.0-33-generic, screens 3840.0x2160.0, 2560.0x1600.0
AS: Electric Eel | 2022.1.1 Patch 1
Kotlin plugin: 221-1.8.0-release-for-android-studio-AS5591.52
Android Gradle Plugin: 4.2.2
Gradle: 6.9
Gradle JDK: version 11.0.15
NDK: from module: 20.0.5594570, from local.properties: (not specified), latest from SDK: 22.1.7171670
CMake: from local.properties: (not specified), latest from SDK: 3.18.1-g262b901, from PATH: 3.22.1
IMPORTANT: Please read
```
Android Studio Kotlin indicates warning of a perfect source; java source has no such warning
This Cursor should be freed up after use with #close()
override fun getProperty(name: String): Any? {
var value: Any? = properties[name]
if (value == null) {
var cursor: Cursor? = null
val columns: Array<String> = arrayOf(COLUMN_VALUE)
synchronized(openHelper as Any) {
mDB = openHelper.readableDatabase
if (name.startsWith(AccountID.ACCOUNT_UUID_PREFIX)) {
val idx: Int = name.indexOf(".")
if (idx == -1) {
value = name // just return the accountUuid
} else {
val args: Array<String> = arrayOf(name.substring(0, idx), name.substring(idx + 1))
cursor = mDB.query(AccountID.TBL_PROPERTIES, columns,
AccountID.ACCOUNT_UUID + "=? AND " + COLUMN_NAME + "=?",
args, null, null, null, "1")
}
} else {
cursor = mDB.query(TABLE_NAME, columns,
"$COLUMN_NAME=?", arrayOf(name), null, null, null, "1")
}
if (cursor != null) {
try {
if ((cursor!!.count == 1) && cursor!!.moveToFirst()) value = cursor!!.getString(0)
} finally {
cursor!!.close()
}
}
}
if (value == null) value = System.getProperty(name)
}
return value
}