rspec/rules/S2213/java/rule.adoc
2021-04-28 16:49:39 +02:00

19 lines
581 B
Plaintext

A Spring ``++singleton++`` bean may be used by many threads at once, and the use of instance (non-``++static++``) variables could cause concurrency issues.
This rule applies to classes with the following annotations: ``++@Service++``, ``++@Component++``, ``++@Repository++``, ``++@Scope("singleton")++``
== Noncompliant Code Example
----
@Service("animalService")
public class AnimalService {
private int age = 1; // Noncompliant
private static int count = 0; // Compliant; static
@Inject
private AnimalDAO animalDAO; // Compliant; managed by Spring
...
}
----