sonar——Synchronized classes Vector, Hashtable, Stack and StringBuffer should not be used

It is better to use their new unsynchronized replacements:

  • ArrayList or LinkedList instead of Vector
  • Deque instead of Stack
  • HashMap instead of Hashtable
  • StringBuilder instead of StringBuffer

Noncompliant Code Example

Vector cats = new Vector();

Compliant Solution

ArrayList cats = new ArrayList();

Exceptions

Use of those synchronized classes is ignored in the signatures of overriding methods.

@Override
public Vector getCats() {...}

posted @ 2018-10-16 15:02  赭山东路  阅读(2448)  评论(0编辑  收藏  举报