You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hbase.apache.org by GitBox <gi...@apache.org> on 2020/03/19 01:47:45 UTC

[GitHub] [hbase] mwkang commented on a change in pull request #1287: HBASE-23983 Fixed Spotbugs complaint in RegionStates related to ignored return value

mwkang commented on a change in pull request #1287: HBASE-23983 Fixed Spotbugs complaint in RegionStates related to ignored return value
URL: https://github.com/apache/hbase/pull/1287#discussion_r394745894
 
 

 ##########
 File path: hbase-server/src/main/java/org/apache/hadoop/hbase/master/assignment/RegionStates.java
 ##########
 @@ -130,8 +130,7 @@ RegionStateNode createRegionStateNode(RegionInfo regionInfo) {
     synchronized (regionsMapLock) {
       RegionStateNode node = regionsMap.computeIfAbsent(regionInfo.getRegionName(),
         key -> new RegionStateNode(regionInfo, regionInTransition));
-      encodedRegionsMap.putIfAbsent(regionInfo.getEncodedName(), node);
-      return node;
+      return encodedRegionsMap.putIfAbsent(regionInfo.getEncodedName(), node);
 
 Review comment:
   How about using `put` rather than `putIfAbsent`?
   Because the value of `encodedRegionsMap` must always be the same as the `valuesMap`.
   I used `putIfAbsent` because I didn't want to put it all the time when encodedRegionsMap already had a value.
   I think compare the value of `encodedRegionsMap` and `node` and it to put only when different.
   
   ```java
   RegionStateNode node = regionsMap.computeIfAbsent(regionInfo.getRegionName(),
     key -> new RegionStateNode(regionInfo, regionInTransition));
   if (encodedRegionsMap.get(regionInfo.getEncodedName()) != node) {
     encodedRegionsMap.put(regionInfo.getEncodedName(), node);
   }
   return node;
   ```
   
   I'm sorry to bother you.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services