
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.
62 lines
1.7 KiB
Plaintext
62 lines
1.7 KiB
Plaintext
== Why is this an issue?
|
|
|
|
include::../description.adoc[]
|
|
|
|
include::../noncompliant.adoc[]
|
|
|
|
include::../compliant.adoc[]
|
|
|
|
=== Exceptions
|
|
|
|
Instances of the following classes are ignored by this rule because ``++close++`` has no effect:
|
|
|
|
* ``++java.io.ByteArrayOutputStream++``
|
|
* ``++java.io.ByteArrayInputStream++``
|
|
* ``++java.io.CharArrayReader++``
|
|
* ``++java.io.CharArrayWriter++``
|
|
* ``++java.io.StringReader++``
|
|
* ``++java.io.StringWriter++``
|
|
|
|
Java 7 introduced the try-with-resources statement, which implicitly closes ``++Closeables++``. All resources opened in a try-with-resources statement are ignored by this rule.
|
|
|
|
----
|
|
try (BufferedReader br = new BufferedReader(new FileReader(fileName))) {
|
|
//...
|
|
}
|
|
catch ( ... ) {
|
|
//...
|
|
}
|
|
----
|
|
|
|
== Resources
|
|
|
|
* https://cwe.mitre.org/data/definitions/459[MITRE, CWE-459] - Incomplete Cleanup
|
|
* https://cwe.mitre.org/data/definitions/772[MITRE, CWE-772] - Missing Release of Resource after Effective Lifetime
|
|
* https://wiki.sei.cmu.edu/confluence/x/vjdGBQ[CERT, FIO04-J.] - Release resources when they are no longer needed
|
|
* https://wiki.sei.cmu.edu/confluence/x/QtUxBQ[CERT, FIO42-C.] - Close files when they are no longer needed
|
|
* https://docs.oracle.com/javase/tutorial/essential/exceptions/tryResourceClose.html[Try With Resources]
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
include::../message.adoc[]
|
|
|
|
=== Parameters
|
|
|
|
.excludedResourceTypes
|
|
****
|
|
|
|
Comma separated list of the excluded resource types, using fully qualified names (example: "org.apache.hadoop.fs.FileSystem")
|
|
****
|
|
|
|
|
|
'''
|
|
== Comments And Links
|
|
(visible only on this page)
|
|
|
|
include::../comments-and-links.adoc[]
|
|
endif::env-github,rspecator-view[]
|