rspec/rules/S2654/java/rule.adoc

43 lines
1.1 KiB
Plaintext
Raw Normal View History

2021-04-28 16:49:39 +02:00
Proper synchronization and thread management can be tricky under the best of circumstances, but it's particularly difficult in JEE application, and is even forbidden under some circumstances by the JEE standard.
This rule raises an issue for each ``++Runnable++``, and use of the ``++synchronized++`` keyword.
2021-04-28 16:49:39 +02:00
== Noncompliant Code Example
2022-02-04 17:28:24 +01:00
[source,java]
2021-04-28 16:49:39 +02:00
----
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// ...
Runnable r = new Runnable() { // Noncompliant
public void run() {
// ...
}
};
new Thread(r).start();
----
2021-04-28 16:49:39 +02:00
== See
* https://cwe.mitre.org/data/definitions/383[MITRE, CWE-383] - J2EE Bad Practices: Direct Use of Threads
* https://cwe.mitre.org/data/definitions/574[MITRE, CWE-574] - EJB Bad Practices: Use of Synchronization Primitives
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
include::message.adoc[]
'''
== Comments And Links
(visible only on this page)
include::comments-and-links.adoc[]
endif::env-github,rspecator-view[]