@@ -472,7 +472,7 @@ private Set<String> addTopLevelClustersToBuilder(
472
472
XdsConfig .XdsClusterConfig .ClusterChild child ;
473
473
switch (cdsUpdate .clusterType ()) {
474
474
case AGGREGATE :
475
- Set <String > leafNames = new HashSet <>();
475
+ List <String > leafNames = new ArrayList <>();
476
476
addLeafNames (leafNames , cdsUpdate );
477
477
child = new AggregateConfig (leafNames );
478
478
leafClusterNames .addAll (leafNames );
@@ -508,15 +508,27 @@ private Set<String> addTopLevelClustersToBuilder(
508
508
return leafClusterNames ;
509
509
}
510
510
511
- private void addLeafNames (Set <String > leafNames , XdsClusterResource .CdsUpdate cdsUpdate ) {
511
+ /**
512
+ * Recursively adds the leaf names of the clusters in the aggregate cluster to the list.
513
+ * @param leafNames priority ordered list of leaf names we will add to
514
+ * @param cdsUpdate the cluster config being processed
515
+ */
516
+ private void addLeafNames (List <String > leafNames , XdsClusterResource .CdsUpdate cdsUpdate ) {
512
517
for (String cluster : cdsUpdate .prioritizedClusterNames ()) {
513
518
if (leafNames .contains (cluster )) {
514
519
continue ;
515
520
}
521
+
516
522
StatusOr <XdsClusterResource .CdsUpdate > data = getCluster (cluster ).getData ();
517
- if (data == null || ! data . hasValue () || data . getValue () == null ) {
523
+ if (data == null ) {
518
524
continue ;
519
525
}
526
+ if (!data .hasValue ()) {
527
+ leafNames .add (cluster );
528
+ continue ;
529
+ }
530
+ assert data .getValue () != null ;
531
+
520
532
if (data .getValue ().clusterType () == ClusterType .AGGREGATE ) {
521
533
addLeafNames (leafNames , data .getValue ());
522
534
} else {
0 commit comments