From 5084ed287cb1865c48c05ad6d08965bae8eb0bd0 Mon Sep 17 00:00:00 2001 From: tyiuhc <137842098+tyiuhc@users.noreply.github.com> Date: Tue, 10 Oct 2023 16:03:11 -0700 Subject: [PATCH] fix: Catch error in flag poller for local evaluation (#13) --- src/main/kotlin/flag/FlagConfigService.kt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/flag/FlagConfigService.kt b/src/main/kotlin/flag/FlagConfigService.kt index 8dbfce2..eb14b44 100644 --- a/src/main/kotlin/flag/FlagConfigService.kt +++ b/src/main/kotlin/flag/FlagConfigService.kt @@ -44,13 +44,19 @@ internal class FlagConfigServiceImpl( override fun start() { lock.once { - refresh() poller.scheduleAtFixedRate( - { refresh() }, + { + try { + refresh() + } catch (e: Exception) { + Logger.e("Failed to refresh flag configs.", e) + } + }, config.flagConfigPollerIntervalMillis, config.flagConfigPollerIntervalMillis, TimeUnit.MILLISECONDS ) + refresh() } }