[ https://issues.apache.org/jira/browse/HBASE-23102?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Nick Dimiduk reopened HBASE-23102: ---------------------------------- Reopen for back-ports. > 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 > Assignee: David Mollitor > Priority: Minor > Labels: newbie, noob > Fix For: 3.0.0-alpha-1 > > Attachments: HBASE-23102.1.patch > > > 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.20.10#820010)