Skip to content

Commit f2092b9

Browse files
committed
fix(flagd): Ignore unimplemented getMetadata
Signed-off-by: Guido Breitenhuber <[email protected]>
1 parent 36b8df7 commit f2092b9

File tree

1 file changed

+18
-5
lines changed
  • providers/flagd/src/main/java/dev/openfeature/contrib/providers/flagd/resolver/process/storage/connector/sync

1 file changed

+18
-5
lines changed

providers/flagd/src/main/java/dev/openfeature/contrib/providers/flagd/resolver/process/storage/connector/sync/SyncStreamQueueSource.java

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
import dev.openfeature.flagd.grpc.sync.Sync.SyncFlagsResponse;
1717
import dev.openfeature.sdk.Awaitable;
1818
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
19+
import io.grpc.Status;
20+
import io.grpc.StatusException;
21+
import io.grpc.StatusRuntimeException;
1922
import io.grpc.stub.StreamObserver;
2023
import java.util.concurrent.BlockingQueue;
2124
import java.util.concurrent.LinkedBlockingQueue;
@@ -144,13 +147,23 @@ private Struct getMetadata() {
144147
localStub = localStub.withDeadlineAfter(deadline, TimeUnit.MILLISECONDS);
145148
}
146149

147-
GetMetadataResponse metadataResponse = localStub.getMetadata(GetMetadataRequest.getDefaultInstance());
150+
try {
151+
GetMetadataResponse metadataResponse = localStub.getMetadata(GetMetadataRequest.getDefaultInstance());
148152

149-
if (metadataResponse != null) {
150-
return metadataResponse.getMetadata();
151-
}
153+
if (metadataResponse != null) {
154+
return metadataResponse.getMetadata();
155+
}
156+
157+
return null;
158+
} catch (StatusRuntimeException e) {
159+
// In newer versions of flagd, metadata is part of the sync stream. If the method is unimplemented, we
160+
// can ignore the error
161+
if (Status.UNIMPLEMENTED.equals(e.getStatus())) {
162+
return null;
163+
}
152164

153-
return null;
165+
throw e;
166+
}
154167
}
155168

156169
private void syncFlags(SyncStreamObserver streamObserver) {

0 commit comments

Comments
 (0)