fb-contrib
fb-contrib copied to clipboard
NMCS_NEEDLESS_MEMBER_COLLECTION_SYNCHRONIZATION false positive
computeIfAbsent is not listed as modifyingMethod; as a result the following piece of code generates a false positive:
public abstract class CacheFbBug {
private final Map<String, String> hashableStringCache;
public CacheFbBug() {
hashableStringCache = Collections.synchronizedMap(new HashMap<>());
}
public String getHashedString(String val) {
return hashableStringCache.computeIfAbsent(val, this::hashString);
}
public abstract String hashString(String stringToHash);
}
looking at https://download.java.net/java/early_access/jdk15/docs/api/java.base/java/util/Map.html I see a few more methods missing:
- compute
- computeIfAbsent
- computeIfPresent
- merge
- putAll
- putIfAbsent
- replace
- replaceAll
would be nice to get this fixed 👍