rspec/rules/S1114/java/rule.adoc
Fred Tingaud 16f6c0aecf
Inline adoc when include has no additional value (#1940)
Inline adoc files when they are included exactly once.

Also fix language tags because this inlining gives us better information
on what language the code is written in.
2023-05-25 14:18:12 +02:00

63 lines
1.4 KiB
Plaintext

== Why is this an issue?
Overriding the ``++Object.finalize()++`` method must be done with caution to dispose some system resources.
Calling the ``++super.finalize()++`` at the end of this method implementation is highly recommended in case parent implementations must also dispose some system resources.
=== Noncompliant code example
[source,java]
----
protected void finalize() { // Noncompliant; no call to super.finalize();
releaseSomeResources();
}
protected void finalize() {
super.finalize(); // Noncompliant; this call should come last
releaseSomeResources();
}
----
=== Compliant solution
[source,java]
----
protected void finalize() {
releaseSomeResources();
super.finalize();
}
----
== Resources
* https://cwe.mitre.org/data/definitions/568[MITRE, CWE-568] - finalize() Method Without super.finalize()
* https://wiki.sei.cmu.edu/confluence/x/4jZGBQ[CERT, MET12-J.] - Do not use finalizers
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
Add a call to super.finalize() at the end of this Object.finalize() implementation.
Move this super.finalize() call to the end of this Object.finalize() implementation.
'''
== Comments And Links
(visible only on this page)
=== is related to: S1115
=== on 4 Jul 2013, 12:09:44 Freddy Mallet wrote:
Is implemented by \http://jira.codehaus.org/browse/SONARJAVA-197
endif::env-github,rspecator-view[]