
org.sonar.l10n.squidjava.rules.squid.S1149.html Maven / Gradle / Ivy
Early classes of the Java API, such as Vector
, Hashtable
and StringBuffer
, were synchronized to make them thread-safe.
Unfortunately, synchronization has a big negative impact on performance, even when using these collections from a single thread.
It is better to use their new unsynchronized replacements:
ArrayList
or LinkedList
instead of Vector
HashMap
instead of Hashtable
StringBuilder
instead of StringBuffer
The following code:
Vector cats = new Vector(); // Non-Compliant
should be refactored into:
ArrayList cats = new ArrayList(); // Compliant
Use of those synchronized classes is allowed in method signatures when overriding an existing method.
@Override
public Vector getCats() {...} //Compliant
© 2015 - 2025 Weber Informatics LLC | Privacy Policy