bbeaudreault commented on code in PR #4335:
URL: https://github.com/apache/hbase/pull/4335#discussion_r848646581
##########
hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncTableRegionLocatorImpl.java:
##########
@@ -62,7 +62,10 @@ public CompletableFuture<List<HRegionLocation>>
getAllRegionLocations() {
.thenApply(locs -> Arrays.asList(locs.getRegionLocations()));
}
return ClientMetaTableAccessor
- .getTableHRegionLocations(conn.getTable(TableName.META_TABLE_NAME),
tableName);
+ .getTableHRegionLocations(conn.getTable(TableName.META_TABLE_NAME),
tableName)
+ .whenComplete((locs, error) -> {
Review Comment:
Thanks for the congrats!
Here's the javadoc for whenComplete:
> Returns a new CompletionStage with the same result or exception as this
stage, that executes the given action when this stage completes.
> When this stage is complete, the given action is invoked with the result
(or null if none) and the exception (or null if none) of this stage as
arguments. The returned stage is completed when the action returns.
Unlike method handle, this method is not designed to translate completion
outcomes, so the supplied action should not throw an exception. However, if it
does, the following rules apply: if this stage completed normally but the
supplied action throws an exception, then the returned stage completes
exceptionally with the supplied action's exception. Or, if this stage completed
exceptionally and the supplied action throws an exception, then the returned
stage completes exceptionally with this stage's exception.
My understanding of that is, if there were an error the callback would get
called with `locs == null` and `error != null`. And then, your callback should
not throw an exception. But since you're callback is called with locs == null,
your callback is-was would throw an NPE. Then basd on the last 2 sentences, it
would be the same result for the end-user, but they'd see an NPE instead of the
originating error.
--
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]