core: Avoid exception handling in PF for invalid index

It is trivial to avoid the exception from
addressIndex.getCurrentAddress(). The log message was inaccurate, as the
subchannel might have been TRANSIENT_FAILURE. The only important part of
the condition was whether the subchannel was the current subchannel.
This commit is contained in:
Eric Anderson 2024-08-17 10:26:03 -07:00
parent 33687d3983
commit 4914ffc59a
1 changed files with 3 additions and 6 deletions

View File

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