rspec/rules/S2151/kotlin/rule.adoc

33 lines
607 B
Plaintext
Raw Normal View History

== Why is this an issue?
include::../description.adoc[]
=== Noncompliant code example
2022-02-04 17:28:24 +01:00
[source,kotlin]
----
fun main() {
System.runFinalizersOnExit(true) // Noncompliant
}
----
=== Compliant solution
2022-02-04 17:28:24 +01:00
[source,kotlin]
----
fun main() {
Runtime.getRuntime().addShutdownHook(object : Thread() {
override fun run() {
doSomething()
}
})
}
----
== Resources
* https://wiki.sei.cmu.edu/confluence/x/4jZGBQ[CERT, MET12-J.] - Do not use finalizers. Although this resource talks about Java, the underlying information concerning the JVM are just as relevant for Kotlin.