bbeaudreault commented on code in PR #4335:
URL: https://github.com/apache/hbase/pull/4335#discussion_r851622804


##########
hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncTableRegionLocatorImpl.java:
##########
@@ -61,8 +62,23 @@ public CompletableFuture<List<HRegionLocation>> 
getAllRegionLocations() {
         return conn.registry.getMetaRegionLocations()
           .thenApply(locs -> Arrays.asList(locs.getRegionLocations()));
       }
-      return ClientMetaTableAccessor
-        .getTableHRegionLocations(conn.getTable(TableName.META_TABLE_NAME), 
tableName);
+      CompletableFuture<List<HRegionLocation>> future = new 
CompletableFuture<>();
+      addListener(ClientMetaTableAccessor.getTableHRegionLocations(conn
+          .getTable(TableName.META_TABLE_NAME), tableName), (locs, error) -> {
+          if (error != null) {
+            future.completeExceptionally(error);
+            return;
+          }
+          try {
+            locs.forEach(loc -> conn.getLocator()
+              .getNonMetaRegionLocator().addLocationToCache(loc));
+          } catch (Exception e) {
+            future.completeExceptionally(e);
+          } finally {
+            future.complete(locs);

Review Comment:
   can you move this to right after the `locs.forEach`?
   
   As is, this will result in completing the future twice when an exception is 
raised. I think CompletableFuture will handle this correctly, but it's more 
correct and less confusing to future readers to not do that.



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to