Replace Hashtable With Map
ID |
java.replace_hashtable_map |
Severity |
info |
Remediation Complexity |
trivial |
Remediation Risk |
low |
Remediation Effort |
low |
Resource |
Efficiency |
Language |
Java |
Tags |
efficiency |
Rationale
Hashtable is a legacy JDK 1.0 type. Every method is synchronized, which means callers pay a monitor cost on every access even in strictly single-threaded code. Hashtable also rejects null keys and values, while HashMap accepts them.
When genuine thread-safety is required, java.util.concurrent.ConcurrentHashMap gives finer-grained locking and better scalability than Hashtable.