[fix] Fix use of computeIfPresent with HashMap with possible null values

Signed-off-by: Emmanuel Bigeon <emmanuel@bigeon.fr>
This commit is contained in:
Emmanuel Bigeon 2021-11-07 12:22:11 +01:00
parent ea01d346d3
commit 625cacb198

View File

@ -207,7 +207,11 @@ public final class CommandParameters {
* @param string the key
* @param value the value */
public void set(final String string, final String value) {
stringArguments.computeIfPresent(string,
(final String k, final String v) -> value);
// DO NOT USE computeIfPresent. This is a HashMap, not a ConcurrentHashMap and
// keys can be associated to null, but computeIfPresent will consider them as
// absent!
if (stringArguments.containsKey(string)) {
stringArguments.put(string, value);
}
}
}