RFR: JDK-8323760 putIfAbsent documentation conflicts with itself

Pavel Rappo prappo at openjdk.org
Tue Feb 13 16:39:05 UTC 2024


On Tue, 16 Jan 2024 07:40:44 GMT, John Hendrikx <jhendrikx at openjdk.org> wrote:

> Update the documentation for `@return` tag of `putIfAbsent` to match the main description. `putIfAbsent` uses the same wording as `put` for its `@return` tag, but that is incorrect.  `putIfAbsent` never returns the **previous** value, as the whole point of the method is not the replace the value if it was present.  As such, if it returns a value, it is the **current** value, and in all other cases it will return `null`.

@hjohn, I think this PR is worth pursuing. I again pinged those who might help you see this through.

I generally note that the phrase "current value", which is used in some Map methods that take a value argument, sounds a bit ambiguous to my non-native English speaker's ear. "Current value" might be confused with the passed value. "Associated", "currently mapped",  might be better.

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

PR Comment: https://git.openjdk.org/jdk/pull/17438#issuecomment-1941964756


More information about the core-libs-dev mailing list