@@ -167,9 +167,10 @@ void adjustResourceSubscription(XdsResourceType<?> resourceType) {
|
167 | 167 | resourceStore.startMissingResourceTimers(resources, resourceType); |
168 | 168 | |
169 | 169 | if (resources.isEmpty()) { |
170 | | -// The resource type no longer has subscribing resources; clean up references to it |
| 170 | +// The resource type no longer has subscribing resources; clean up references to it, except |
| 171 | +// for nonces. If the resource type becomes used again the control plane can ignore requests |
| 172 | +// for old/missing nonces. Old type's nonces are dropped when the ADS stream is restarted. |
171 | 173 | versions.remove(resourceType); |
172 | | -adsStream.respNonces.remove(resourceType); |
173 | 174 | } |
174 | 175 | } |
175 | 176 | |
@@ -313,7 +314,10 @@ private class AdsStream implements XdsTransportFactory.EventHandler<DiscoveryRes
|
313 | 314 | // Nonce in each response is echoed back in the following ACK/NACK request. It is |
314 | 315 | // used for management server to identify which response the client is ACKing/NACking. |
315 | 316 | // To avoid confusion, client-initiated requests will always use the nonce in |
316 | | -// most recently received responses of each resource type. |
| 317 | +// most recently received responses of each resource type. Nonces are never deleted from the |
| 318 | +// map; nonces are only discarded once the stream closes because xds_protocol says "the |
| 319 | +// management server should not send a DiscoveryResponse for any DiscoveryRequest that has a |
| 320 | +// stale nonce." |
317 | 321 | private final Map<XdsResourceType<?>, String> respNonces = new HashMap<>(); |
318 | 322 | private final StreamingCall<DiscoveryRequest, DiscoveryResponse> call; |
319 | 323 | private final MethodDescriptor<DiscoveryRequest, DiscoveryResponse> methodDescriptor = |
|