You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hbase.apache.org by "David Mollitor (Jira)" <ji...@apache.org> on 2019/10/01 13:04:00 UTC
[jira] [Created] (HBASE-23102) Improper Usage of Map putIfAbsent
David Mollitor created HBASE-23102:
--------------------------------------
Summary: Improper Usage of Map putIfAbsent
Key: HBASE-23102
URL: https://issues.apache.org/jira/browse/HBASE-23102
Project: HBase
Issue Type: Improvement
Affects Versions: 2.3.0
Reporter: David Mollitor
When using {{Map#putIfAbsent}}, the argument should not be a {{new}} object. Otherwise, if the item is present, the object that was instantiated is immediately thrown away. Instead, use {{Map#computeIfAbsent}} so that the object is only instantiated if it is needed.
There exists a good example in the {{Map}} JavaDoc:
https://docs.oracle.com/javase/8/docs/api/java/util/Map.html#computeIfAbsent-K-java.util.function.Function-
----
h2. Locations
https://github.com/apache/hbase/blob/9370347efea5b09e2fa8f4e5d82fa32491e1181b/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/QuotaCache.java#L227-L236
https://github.com/apache/hbase/blob/025ddce868eb06b4072b5152c5ffae5a01e7ae30/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/throttle/StoreHotnessProtector.java#L124-L129
https://github.com/apache/hbase/blob/1170f28122d9d36e511ba504a5263ec62e11ef6a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/assignment/RegionStates.java#L555
https://github.com/apache/hbase/blob/4ca760fe9dd373b8d8a4c48db15e42424920653c/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupAdminServer.java#L584-L586
https://github.com/apache/hbase/blob/4ca760fe9dd373b8d8a4c48db15e42424920653c/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupAdminServer.java#L585
https://github.com/apache/hbase/blob/5b01e613fbbb92e243e99a1d199b4ffbb21ed2d9/hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/ProcedureExecutor.java#L834
--
This message was sent by Atlassian Jira
(v8.3.4#803005)