mirror of https://github.com/grpc/grpc-java.git
xds: Check for validity of xdsClient in ClusterImplLbHelper (#11553)
* Added null check for xdsClient in onSubChannelState. This avoids NPE for xdsClient when LB is shutdown and onSubChannelState is called later as part of listener callback. As shutdown is racy and eventually consistent, this check would avoid calculating locality after LB is shutdown.
This commit is contained in:
parent
c92453fb14
commit
3e8ef8cf0c
|
@ -236,7 +236,8 @@ final class ClusterImplLoadBalancer extends LoadBalancer {
|
|||
delegate().start(new SubchannelStateListener() {
|
||||
@Override
|
||||
public void onSubchannelState(ConnectivityStateInfo newState) {
|
||||
if (newState.getState().equals(ConnectivityState.READY)) {
|
||||
// Do nothing if LB has been shutdown
|
||||
if (xdsClient != null && newState.getState().equals(ConnectivityState.READY)) {
|
||||
// Get locality based on the connected address attributes
|
||||
ClusterLocality updatedClusterLocality = createClusterLocalityFromAttributes(
|
||||
subchannel.getConnectedAddressAttributes());
|
||||
|
|
Loading…
Reference in New Issue