From 18e274de658edfdc8356460860e61635bb17863a Mon Sep 17 00:00:00 2001 From: Terry Wilson Date: Tue, 4 Apr 2023 14:34:11 -0700 Subject: [PATCH] xds: Synchronize access to test control plane collections (#10012) Fixes #9938 --- .../grpc/xds/XdsTestControlPlaneService.java | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/xds/src/test/java/io/grpc/xds/XdsTestControlPlaneService.java b/xds/src/test/java/io/grpc/xds/XdsTestControlPlaneService.java index 9a1ce3350d..d7ac5bdd3c 100644 --- a/xds/src/test/java/io/grpc/xds/XdsTestControlPlaneService.java +++ b/xds/src/test/java/io/grpc/xds/XdsTestControlPlaneService.java @@ -29,6 +29,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicInteger; import java.util.logging.Level; import java.util.logging.Logger; @@ -75,25 +76,24 @@ final class XdsTestControlPlaneService extends "type.googleapis.com/envoy.config.endpoint.v3.ClusterLoadAssignment"; private final Map> xdsResources = new HashMap<>(); - private ImmutableMap, Set>> subscribers + private ImmutableMap, Set>> subscribers = ImmutableMap.of( - ADS_TYPE_URL_LDS, new HashMap, Set>(), - ADS_TYPE_URL_RDS, new HashMap, Set>(), - ADS_TYPE_URL_CDS, new HashMap, Set>(), - ADS_TYPE_URL_EDS, new HashMap, Set>() - ); + ADS_TYPE_URL_LDS, new ConcurrentHashMap, Set>(), + ADS_TYPE_URL_RDS, new ConcurrentHashMap, Set>(), + ADS_TYPE_URL_CDS, new ConcurrentHashMap, Set>(), + ADS_TYPE_URL_EDS, new ConcurrentHashMap, Set>()); private final ImmutableMap xdsVersions = ImmutableMap.of( ADS_TYPE_URL_LDS, new AtomicInteger(1), ADS_TYPE_URL_RDS, new AtomicInteger(1), ADS_TYPE_URL_CDS, new AtomicInteger(1), ADS_TYPE_URL_EDS, new AtomicInteger(1) ); - private final ImmutableMap, AtomicInteger>> + private final ImmutableMap, AtomicInteger>> xdsNonces = ImmutableMap.of( - ADS_TYPE_URL_LDS, new HashMap, AtomicInteger>(), - ADS_TYPE_URL_RDS, new HashMap, AtomicInteger>(), - ADS_TYPE_URL_CDS, new HashMap, AtomicInteger>(), - ADS_TYPE_URL_EDS, new HashMap, AtomicInteger>() + ADS_TYPE_URL_LDS, new ConcurrentHashMap, AtomicInteger>(), + ADS_TYPE_URL_RDS, new ConcurrentHashMap, AtomicInteger>(), + ADS_TYPE_URL_CDS, new ConcurrentHashMap, AtomicInteger>(), + ADS_TYPE_URL_EDS, new ConcurrentHashMap, AtomicInteger>() );