Fix NullPointerException in getStore (#359) (#364)

This commit is contained in:
ti-srebot 2021-12-07 09:42:53 +08:00 committed by GitHub
parent e672c46dfe
commit bf1eefacd3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 4 deletions

View File

@ -280,9 +280,16 @@ public class PDClient extends AbstractGRPCClient<PDBlockingStub, PDFutureStub>
@Override
public Store getStore(BackOffer backOffer, long storeId) {
return callWithRetry(
backOffer, PDGrpc.getGetStoreMethod(), buildGetStoreReq(storeId), buildPDErrorHandler())
.getStore();
GetStoreResponse resp =
callWithRetry(
backOffer,
PDGrpc.getGetStoreMethod(),
buildGetStoreReq(storeId),
buildPDErrorHandler());
if (resp != null) {
return resp.getStore();
}
return null;
}
@Override

View File

@ -81,7 +81,7 @@ public class StoreHealthyChecker implements Runnable {
private boolean checkStoreTombstone(TiStore store) {
try {
Metapb.Store newStore = pdClient.getStore(ConcreteBackOffer.newRawKVBackOff(), store.getId());
if (newStore.getState() == Metapb.StoreState.Tombstone) {
if (newStore != null && newStore.getState() == Metapb.StoreState.Tombstone) {
return true;
}
} catch (Exception e) {