Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HBASE-22328 NPE in RegionReplicaReplicationEndpoint
Browse files Browse the repository at this point in the history
Apache9 committed May 4, 2019
1 parent caa1194 commit 9787011
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -151,21 +151,23 @@ private boolean requiresReplication(Optional<TableDescriptor> tableDesc, Entry e
private void getRegionLocations(CompletableFuture<RegionLocations> future,
TableDescriptor tableDesc, byte[] encodedRegionName, byte[] row, boolean reload) {
FutureUtils.addListener(connection.getRegionLocations(tableDesc.getTableName(), row, reload),
(r, e) -> {
(locs, e) -> {
if (e != null) {
future.completeExceptionally(e);
return;
}
// if we are not loading from cache, just return
if (reload) {
future.complete(r);
future.complete(locs);
return;
}
// check if the number of region replicas is correct, and also the primary region name
// matches
if (r.size() == tableDesc.getRegionReplication() && Bytes.equals(
r.getDefaultRegionLocation().getRegion().getEncodedNameAsBytes(), encodedRegionName)) {
future.complete(r);
// matches, and also there is no null elements in the returned RegionLocations
if (locs.size() == tableDesc.getRegionReplication() &&
locs.size() == locs.numNonNullElements() &&
Bytes.equals(locs.getDefaultRegionLocation().getRegion().getEncodedNameAsBytes(),
encodedRegionName)) {
future.complete(locs);
} else {
// reload again as the information in cache maybe stale
getRegionLocations(future, tableDesc, encodedRegionName, row, true);

0 comments on commit 9787011

Please sign in to comment.