Skip to content

Commit

Permalink
don't process resourceDoesNotExist for watchers that have been cancel…
Browse files Browse the repository at this point in the history
…led.
  • Loading branch information
larry-safran committed Feb 12, 2025
1 parent 764a4e3 commit d2bea30
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions xds/src/main/java/io/grpc/xds/XdsDependencyManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ private <T extends ResourceUpdate> void cancelWatcher(XdsWatcherBase<T> watcher)
throwIfParentContextsNotEmpty(watcher);
}

watcher.cancelled = true;
XdsResourceType<T> type = watcher.type;
String resourceName = watcher.resourceName;

Expand Down Expand Up @@ -597,6 +598,8 @@ private abstract static class XdsWatcherBase<T extends ResourceUpdate>
implements ResourceWatcher<T> {
private final XdsResourceType<T> type;
private final String resourceName;
boolean cancelled;

@Nullable
private StatusOr<T> data;

Expand Down Expand Up @@ -693,6 +696,10 @@ public void onError(Status error) {

@Override
public void onResourceDoesNotExist(String resourceName) {
if (cancelled) {
return;
}

handleDoesNotExist(resourceName);
xdsConfigWatcher.onResourceDoesNotExist(toContextString());
}
Expand Down Expand Up @@ -752,6 +759,9 @@ public void onError(Status error) {

@Override
public void onResourceDoesNotExist(String resourceName) {
if (cancelled) {
return;
}
handleDoesNotExist(checkNotNull(resourceName, "resourceName"));
xdsConfigWatcher.onResourceDoesNotExist(toContextString());
}
Expand Down Expand Up @@ -836,6 +846,9 @@ public void onChanged(XdsClusterResource.CdsUpdate update) {

@Override
public void onResourceDoesNotExist(String resourceName) {
if (cancelled) {
return;
}
handleDoesNotExist(checkNotNull(resourceName, "resourceName"));
maybePublishConfig();
}
Expand All @@ -857,6 +870,9 @@ public void onChanged(XdsEndpointResource.EdsUpdate update) {

@Override
public void onResourceDoesNotExist(String resourceName) {
if (cancelled) {
return;
}
handleDoesNotExist(checkNotNull(resourceName, "resourceName"));
maybePublishConfig();
}
Expand Down

0 comments on commit d2bea30

Please sign in to comment.