== Why is this an issue?

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

[source,java]
----
@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[]

'''
== Implementation Specification
(visible only on this page)

=== Message

Make "xxx" static, remove it, or give the class "prototype" scope.


'''
== Comments And Links
(visible only on this page)

=== on 2 Mar 2018, 14:15:29 Alexandre Gigleux wrote:
\[~ann.campbell.2] This RSPEC is obsolete because better described RSPEC-3749 and already implemented by SONARJAVA-2168.


Shall we simply "Close Won't Fix" this RSPEC or delete it?

=== on 2 Mar 2018, 15:14:59 Ann Campbell wrote:
\[~alexandre.gigleux] the scope is slightly different: 


||this||RSPEC-3749||

|@Service|@Service|

|@Component| |

|@Repository|@Repository|

|@Scope("singleton")| |

| |@Controller|


Should the missing elements be added to RSPEC-3749 or just dropped? Either way, I'm fine to Won't-Fix this.

endif::env-github,rspecator-view[]
