Closeable Not Closed (ARCH8080)
Ce contenu n’est pas encore disponible dans votre langue.
Key kotlin.performance.disposable-not-disposed · Severity error · Category performance
Flags Closeable resources (streams, readers, connections) created without use { } or a try/finally close.
Incorrect
Section titled “Incorrect”val reader = File(path).bufferedReader()return reader.readLine()Correct
Section titled “Correct”return File(path).bufferedReader().use { it.readLine() }Wrap the resource in use { } so it closes on every path.