xds: fix eds balancer nil pointer panic without addresses (#2809)
This commit is contained in:
@ -277,7 +277,9 @@ func (xdsB *EDSBalancer) UpdateBalancerState(s connectivity.State, p balancer.Pi
|
|||||||
|
|
||||||
// Close closes the balancer.
|
// Close closes the balancer.
|
||||||
func (xdsB *EDSBalancer) Close() {
|
func (xdsB *EDSBalancer) Close() {
|
||||||
xdsB.bg.close()
|
if xdsB.bg != nil {
|
||||||
|
xdsB.bg.close()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type dropPicker struct {
|
type dropPicker struct {
|
||||||
|
@ -337,6 +337,13 @@ func TestEDS_TwoLocalities(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestClose(t *testing.T) {
|
||||||
|
edsb := NewXDSBalancer(nil, nil)
|
||||||
|
// This is what could happen when switching between fallback and eds. This
|
||||||
|
// make sure it doesn't panic.
|
||||||
|
edsb.Close()
|
||||||
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
balancer.Register(&testConstBalancerBuilder{})
|
balancer.Register(&testConstBalancerBuilder{})
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user