rspec/rules/S2095/java/rule.adoc
2021-01-27 13:42:22 +01:00

30 lines
740 B
Plaintext

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 ( ... ) {
//...
}
----
include::../see.adoc[]