On Fri, 6 Nov 2026 16:50:00 GMT, Chen Liang <[email protected]> wrote:

>> src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java line 
>> 2151:
>> 
>>> 2149:      * This method is potentially confusing because its name does not 
>>> indicate
>>> 2150:      * whether it checks for the presence of a key or a value. Use 
>>> {@link
>>> 2151:      * #containsValue(Object) containsValue} instead.
>> 
>> Might make sense to say something akin to "use containsValue or containsKey 
>> instead".
>
> It is not right to ask an intentional user of `contains` to migrate to 
> `containsKey`.

Hm, well there is the possibility that the user has come here because they're 
not sure what `contains` actually does. And the text does read a bit awkwardly 
in that it mentions the possibilities of both key and value but then only 
refers to `containsValue`. How about this instead:

> This method is potentially confusing because its name does not indicate
> whether it checks for the presence of a key or a value. Use
> {@link #containsValue(Object) containsValue} in preference to this method, or 
> use
> {@link #containsKey(Object) containsKey} to check for the presence of a key.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/33593#discussion_r4496282444

Reply via email to