java.util.Properties
objects:
java.util.Hashtable#put
java.util.Hashtable#putIfAbsent
java.util.Hashtable#putAll
java.util.Hashtable#get
For historical reasons, java.util.Properties
inherits java.util.Hashtable
,
but using those methods is discouraged to prevent corruption of properties values of types other than String
.
Although java.util.Properties#putAll
overrides java.util.Hashtable#putAll
it doesn't get reported when
both the key and the value parameters in the map are of the String
type.
Example:
Object f(Properties props) {
props.put("hello", "world");
props.putIfAbsent("hello", "world");
props.putAll(new HashMap<>());
return props.get("Hello");
}
After the quick-fix is applied:
Object f(Properties props) {
props.setProperty("hello", "world");
props.putIfAbsent("hello", "world");
props.putAll(new HashMap<>());
return props.getProperty("hello");
}