google / google/error-prone

Feature Request - detect key of wrong type passed to Map.get() or Map.remove()

Open
#2,482 6 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
7.2k
Forks
820
Avg merge
5h 9m
Merged PRs (30d)
50

Description

Since the signature of these methods, by design, does not constrict you to use the generic type of the key, and is just `Object`, it is easy to accidentally pass the wrong variable.

This is especially true for remove(), which in the case of cache clean-up code, might not have full test coverage, or missing/difficult to assert behaviour. This has been seen to lead to leaked memory.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.