core: Eliminate NPE seen in PickFirstLeafLoadBalancer (#11013)

ref b/329420531
This commit is contained in:
Larry Safran 2024-03-14 03:53:34 +00:00 committed by GitHub
parent 8a9ce990b0
commit 36e9f0dfac
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 3 deletions

View File

@ -465,9 +465,13 @@ final class PickFirstLeafLoadBalancer extends LoadBalancer {
log.log(Level.FINE, "Received health status {0} for subchannel {1}",
new Object[]{newState, subchannelData.subchannel});
healthStateInfo = newState;
if (addressIndex.isValid()
&& subchannels.get(addressIndex.getCurrentAddress()).healthListener == this) {
updateHealthCheckedState(subchannelData);
try {
SubchannelData curSubChanData = subchannels.get(addressIndex.getCurrentAddress());
if (curSubChanData != null && curSubChanData.healthListener == this) {
updateHealthCheckedState(subchannelData);
}
} catch (IllegalStateException e) {
log.fine("Health listener received state change after subchannel was removed");
}
}
}