@@ -43,17 +43,19 @@ public class FlagdProvider extends EventProvider {
4343 private volatile ProviderEvent previousEvent = null ;
4444
4545 /**
46- * An executor service responsible for scheduling reconnection attempts.
46+ * An executor service responsible for emitting {@link ProviderEvent#PROVIDER_ERROR} after the provider went
47+ * {@link ProviderEvent#PROVIDER_STALE} for {@link #gracePeriod} seconds.
4748 */
48- private final ScheduledExecutorService reconnectExecutor ;
49+ private final ScheduledExecutorService errorExecutor ;
4950
5051 /**
51- * A scheduled task for managing reconnection attempts .
52+ * A scheduled task for emitting {@link ProviderEvent#PROVIDER_ERROR} .
5253 */
5354 private ScheduledFuture <?> reconnectTask ;
5455
5556 /**
56- * The grace period in milliseconds to wait for reconnection before emitting an error event.
57+ * The grace period in milliseconds to wait after {@link ProviderEvent#PROVIDER_STALE} before emitting a
58+ * {@link ProviderEvent#PROVIDER_ERROR}.
5759 */
5860 private final long gracePeriod ;
5961 /**
@@ -92,7 +94,7 @@ public FlagdProvider(final FlagdOptions options) {
9294 }
9395 hooks .add (new SyncMetadataHook (this ::getEnrichedContext ));
9496 contextEnricher = options .getContextEnricher ();
95- this .reconnectExecutor = Executors .newSingleThreadScheduledExecutor ();
97+ this .errorExecutor = Executors .newSingleThreadScheduledExecutor ();
9698 this .gracePeriod = options .getRetryGracePeriod ();
9799 this .deadline = options .getDeadline ();
98100 }
@@ -122,9 +124,9 @@ public synchronized void shutdown() {
122124 }
123125 try {
124126 this .flagResolver .shutdown ();
125- if (reconnectExecutor != null ) {
126- reconnectExecutor .shutdownNow ();
127- reconnectExecutor .awaitTermination (deadline , TimeUnit .MILLISECONDS );
127+ if (errorExecutor != null ) {
128+ errorExecutor .shutdownNow ();
129+ errorExecutor .awaitTermination (deadline , TimeUnit .MILLISECONDS );
128130 }
129131 } catch (Exception e ) {
130132 log .error ("Error during shutdown {}" , FLAGD_PROVIDER , e );
@@ -242,8 +244,8 @@ private void onError() {
242244 reconnectTask .cancel (false );
243245 }
244246
245- if (!reconnectExecutor .isShutdown ()) {
246- reconnectTask = reconnectExecutor .schedule (
247+ if (!errorExecutor .isShutdown ()) {
248+ reconnectTask = errorExecutor .schedule (
247249 () -> {
248250 log .debug (
249251 "Provider did not reconnect successfully within {}s. Emit ERROR event..." , gracePeriod );
0 commit comments