freeacs/freeacs

View on GitHub
common/src/main/java/com/github/freeacs/common/util/Cache.java

Summary

Maintainability
A
0 mins
Test Coverage

Replace the synchronized class "Hashtable" by an unsynchronized one such as "HashMap".
Open

  private final Map<Object, CacheValue> map = new Hashtable<>();

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
  • Deque instead of Stack
  • HashMap instead of Hashtable
  • StringBuilder instead of StringBuffer

Even when used in synchronized context, you should think twice before using it, since it's usage can be tricky. If you are confident the usage is legitimate, you can safely ignore this warning.

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() {...}

Replace the synchronized class "Vector" by an unsynchronized one such as "ArrayList" or "LinkedList".
Open

    List<Object> keysToRemove = new Vector<>();

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
  • Deque instead of Stack
  • HashMap instead of Hashtable
  • StringBuilder instead of StringBuffer

Even when used in synchronized context, you should think twice before using it, since it's usage can be tricky. If you are confident the usage is legitimate, you can safely ignore this warning.

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() {...}

All overloaded methods should be placed next to each other. Placing non-overloaded methods in between overloaded methods with the same type is a violation. Previous overloaded method located at line '84'.
Open

  private void cleanup() {

Checks that overloaded methods are grouped together. Overloaded methods have the samename but different signatures where the signature can differ by the number of inputparameters or type of input parameters or both.

This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

Local variable name 't' must match pattern '^[a-z][a-z0-9][a-zA-Z0-9]*$'.
Open

        Thread t = new Thread(new Cleanup());

Checks that local, non-final variable names conform to a specified pattern.A catch parameter is considered to be a local variable.

This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

Empty line should be followed by <p> tag on the next line.</p>
Open

 *

Checks the Javadoc paragraph.

Checks that:

  • There is one blank line between each of two paragraphs.
  • Each paragraph but the first has <p> immediately before the first word, withno space after.

This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

There are no issues that match your filters.

Category
Status