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
...
}
----


ifdef::env-github,rspecator-view[]
'''
== Comments And Links
(visible only on this page)

include::comments-and-links.adoc[]
endif::env-github,rspecator-view[]
