From 50f5cf1f94a10b14fd3def2aab495682128d1816 Mon Sep 17 00:00:00 2001 From: stack Date: Thu, 16 Apr 2020 08:02:33 -0700 Subject: [PATCH] HBASE-24158 [Flakey Tests] TestAsyncTableGetMultiThreaded Addendum to address NPE --- .../hadoop/hbase/client/AsyncRegionLocatorHelper.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncRegionLocatorHelper.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncRegionLocatorHelper.java index 764650afba..4c6cd5a011 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncRegionLocatorHelper.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncRegionLocatorHelper.java @@ -1,4 +1,4 @@ -/** +/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -19,7 +19,6 @@ package org.apache.hadoop.hbase.client; import static org.apache.hadoop.hbase.exceptions.ClientExceptionsUtil.findException; import static org.apache.hadoop.hbase.exceptions.ClientExceptionsUtil.isMetaClearingException; - import java.util.Arrays; import java.util.function.Consumer; import java.util.function.Function; @@ -45,7 +44,13 @@ final class AsyncRegionLocatorHelper { static boolean canUpdateOnError(HRegionLocation loc, HRegionLocation oldLoc) { // Do not need to update if no such location, or the location is newer, or the location is not // the same with us - return oldLoc != null && oldLoc.getSeqNum() <= loc.getSeqNum() && + if (loc == null || loc.getServerName() == null) { + return false; + } + if (oldLoc == null || oldLoc.getServerName() == null) { + return false; + } + return oldLoc.getSeqNum() <= loc.getSeqNum() && oldLoc.getServerName().equals(loc.getServerName()); } -- 2.19.1