@@ -566,7 +566,6 @@ private interface RdsUpdateSupplier {
566566
567567 private class LdsWatcher extends XdsWatcherBase <XdsListenerResource .LdsUpdate >
568568 implements RdsUpdateSupplier {
569- String rdsName ;
570569
571570 private LdsWatcher (String resourceName ) {
572571 super (XdsListenerResource .getInstance (), resourceName );
@@ -581,43 +580,36 @@ public void onChanged(XdsListenerResource.LdsUpdate update) {
581580
582581 HttpConnectionManager httpConnectionManager = update .httpConnectionManager ();
583582 List <VirtualHost > virtualHosts ;
584- String rdsName ;
585583 if (httpConnectionManager == null ) {
586584 // TCP listener. Unsupported config
587585 virtualHosts = Collections .emptyList (); // Not null, to not delegate to RDS
588- rdsName = null ;
589586 } else {
590587 virtualHosts = httpConnectionManager .virtualHosts ();
591- rdsName = httpConnectionManager .rdsName ();
592588 }
593-
594589 if (virtualHosts != null ) {
595- // No RDS watcher since we are getting RDS updates via LDS
596590 updateRoutes (virtualHosts );
597- this .rdsName = null ;
598- } else {
599- this .rdsName = rdsName ;
591+ }
592+
593+ String rdsName = getRdsName (update );
594+ if (rdsName != null ) {
600595 addRdsWatcher (rdsName );
601596 }
602597
603598 setData (update );
604599 maybePublishConfig ();
605600 }
606601
607- @ Override
608- public void onResourceDoesNotExist (String resourceName ) {
609- if (cancelled ) {
610- return ;
602+ private String getRdsName (XdsListenerResource .LdsUpdate update ) {
603+ HttpConnectionManager httpConnectionManager = update .httpConnectionManager ();
604+ if (httpConnectionManager == null ) {
605+ // TCP listener. Unsupported config
606+ return null ;
611607 }
612-
613- checkArgument (resourceName ().equals (resourceName ), "Resource name does not match" );
614- setDataAsStatus (Status .UNAVAILABLE .withDescription (
615- toContextString () + " does not exist" + nodeInfo ()));
616- rdsName = null ;
617- maybePublishConfig ();
608+ return httpConnectionManager .rdsName ();
618609 }
619610
620- private RdsWatcher getRdsWatcher (WatcherTracer tracer ) {
611+ private RdsWatcher getRdsWatcher (XdsListenerResource .LdsUpdate update , WatcherTracer tracer ) {
612+ String rdsName = getRdsName (update );
621613 if (rdsName == null ) {
622614 return null ;
623615 }
@@ -636,7 +628,7 @@ public RdsUpdateSupplier getRouteSource(WatcherTracer tracer) {
636628 if (virtualHosts != null ) {
637629 return this ;
638630 }
639- RdsWatcher rdsWatcher = getRdsWatcher (tracer );
631+ RdsWatcher rdsWatcher = getRdsWatcher (getData (). getValue (), tracer );
640632 assert rdsWatcher != null ;
641633 return rdsWatcher ;
642634 }
0 commit comments