2021-09-16 17:42:50 +03:00
|
|
|
include::../jvm-description.adoc[]
|
2020-12-21 15:38:52 +01:00
|
|
|
|
2021-02-02 15:02:10 +01:00
|
|
|
|
2020-12-21 15:38:52 +01:00
|
|
|
== Noncompliant Code Example
|
|
|
|
|
|
|
|
----
|
|
|
|
public void doSomething(File file, Lock lock) {
|
|
|
|
file.delete(); // Noncompliant
|
|
|
|
// ...
|
|
|
|
lock.tryLock(); // Noncompliant
|
|
|
|
}
|
|
|
|
----
|
|
|
|
|
|
|
|
== Compliant Solution
|
|
|
|
|
|
|
|
----
|
|
|
|
public void doSomething(File file, Lock lock) {
|
|
|
|
if (!lock.tryLock()) {
|
|
|
|
// lock failed; take appropriate action
|
|
|
|
}
|
|
|
|
if (!file.delete()) {
|
|
|
|
// file delete failed; take appropriate action
|
|
|
|
}
|
|
|
|
}
|
|
|
|
----
|
|
|
|
|
|
|
|
== See
|
|
|
|
|
|
|
|
* https://wiki.sei.cmu.edu/confluence/x/xzdGBQ[CERT, EXP00-J.] - Do not ignore values returned by methods
|
|
|
|
* https://wiki.sei.cmu.edu/confluence/x/TTZGBQ[CERT, FIO02-J.] - Detect and handle file-related errors
|
2021-10-28 10:07:16 +02:00
|
|
|
* https://cwe.mitre.org/data/definitions/754.html[MITRE, CWE-754] - Improper Check for Unusual Exceptional Conditions
|
2021-06-02 20:44:38 +02:00
|
|
|
|
2021-06-03 09:05:38 +02:00
|
|
|
ifdef::env-github,rspecator-view[]
|
2021-09-20 15:38:42 +02:00
|
|
|
|
|
|
|
'''
|
|
|
|
== Implementation Specification
|
|
|
|
(visible only on this page)
|
|
|
|
|
|
|
|
include::../message.adoc[]
|
|
|
|
|
2021-06-08 15:52:13 +02:00
|
|
|
'''
|
2021-06-02 20:44:38 +02:00
|
|
|
== Comments And Links
|
|
|
|
(visible only on this page)
|
|
|
|
|
|
|
|
include::comments-and-links.adoc[]
|
2021-06-03 09:05:38 +02:00
|
|
|
endif::env-github,rspecator-view[]
|