rspec/rules/S2095/java/rule.adoc

37 lines
900 B
Plaintext
Raw Normal View History

2020-06-30 12:48:07 +02:00
include::../description.adoc[]
include::../noncompliant.adoc[]
include::../compliant.adoc[]
== Exceptions
2021-01-27 13:42:22 +01:00
Instances of the following classes are ignored by this rule because ``++close++`` has no effect:
2021-01-27 13:42:22 +01:00
* ``++java.io.ByteArrayOutputStream++``
* ``++java.io.ByteArrayInputStream++``
* ``++java.io.CharArrayReader++``
* ``++java.io.CharArrayWriter++``
* ``++java.io.StringReader++``
* ``++java.io.StringWriter++``
2020-06-30 12:48:07 +02:00
2021-01-27 13:42:22 +01:00
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.
2020-06-30 12:48:07 +02:00
----
try (BufferedReader br = new BufferedReader(new FileReader(fileName))) {
//...
}
catch ( ... ) {
//...
}
----
include::../see.adoc[]
ifdef::env-github,rspecator-view[]
== Comments And Links
(visible only on this page)
include::../comments-and-links.adoc[]
endif::env-github,rspecator-view[]