Skip to content

Commit dd87d38

Browse files
committed
chore: add error log on stream fail, retry cancels
Signed-off-by: Todd Baert <[email protected]>
1 parent ac8a4db commit dd87d38

File tree

4 files changed

+9
-7
lines changed

4 files changed

+9
-7
lines changed

providers/flagd/src/main/java/dev/openfeature/contrib/providers/flagd/FlagdProviderSyncResources.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ public void waitForInitialization(long deadline) {
6161
// if wait(0) is called, the thread would wait forever, so we abort when this would happen
6262
if (now >= end) {
6363
throw new GeneralError(String.format(
64-
"Deadline exceeded. Condition did not complete within the %d ms deadline", deadline));
64+
"Startup timeout exceeded. Initialization did not complete within the %d ms deadline",
65+
deadline));
6566
}
6667
long remaining = end - now;
6768
synchronized (this) {

providers/flagd/src/main/java/dev/openfeature/contrib/providers/flagd/resolver/common/ChannelBuilder.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,12 @@ public class ChannelBuilder {
5858
"retryableStatusCodes",
5959
Arrays.asList(
6060
/*
61-
* All codes are retryable except OK, CANCELLED and DEADLINE_EXCEEDED since
61+
* All codes are retryable except OK and DEADLINE_EXCEEDED since
6262
* any others not listed here cause a very tight loop of retries.
63-
* CANCELLED is not retryable because it is a client-side termination.
6463
* DEADLINE_EXCEEDED is typically a result of a client specified deadline,
6564
* and definitionally should not result in a tight loop (it's a timeout).
6665
*/
66+
Code.CANCELLED.toString(),
6767
Code.UNKNOWN.toString(),
6868
Code.INVALID_ARGUMENT.toString(),
6969
Code.NOT_FOUND.toString(),

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ private void observeSyncStream() throws InterruptedException {
147147
}
148148

149149
// inner loop for handling messages
150-
while (!shutdown.get() && !Context.current().isCancelled()) {
150+
while (!shutdown.get() && !context.isCancelled()) {
151151
final StreamResponseModel<SyncFlagsResponse> taken = incomingQueue.take();
152152
if (taken.isComplete()) {
153153
log.debug("Sync stream completed, will reconnect");
@@ -157,9 +157,9 @@ private void observeSyncStream() throws InterruptedException {
157157

158158
Throwable streamException = taken.getError();
159159
if (streamException != null) {
160-
log.debug("Exception in GRPC connection, streamException {}, will reconnect", streamException);
161-
if (!outgoingQueue.offer(new QueuePayload(
162-
QueuePayloadType.ERROR, "Error from stream or metadata", metadataResponse))) {
160+
log.error("Exception in GRPC connection, streamException {}, will reconnect", streamException);
161+
if (!outgoingQueue.offer(
162+
new QueuePayload(QueuePayloadType.ERROR, "Error from stream: ", metadataResponse))) {
163163
log.error("Failed to convey ERROR status, queue is full");
164164
}
165165
break;

providers/flagd/src/test/java/dev/openfeature/contrib/providers/flagd/resolver/process/storage/connector/sync/SyncStreamQueueSourceTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class SyncStreamQueueSourceTest {
4040
@BeforeEach
4141
public void init() throws Exception {
4242
blockingStub = mock(FlagSyncServiceBlockingStub.class);
43+
when(blockingStub.withDeadlineAfter(anyLong(), any())).thenReturn(blockingStub);
4344
when(blockingStub.getMetadata(any())).thenReturn(GetMetadataResponse.getDefaultInstance());
4445

4546
mockConnector = mock(ChannelConnector.class);

0 commit comments

Comments
 (0)