File tree Expand file tree Collapse file tree 3 files changed +14
-5
lines changed
main/java/com/switcherapi/client
test/java/com/switcherapi/client Expand file tree Collapse file tree 3 files changed +14
-5
lines changed Original file line number Diff line number Diff line change 99 required : true
1010 default : ' 17'
1111 os :
12- description : ' Operating System (ubuntu-22.04, ubuntu- latest, windows-latest)'
12+ description : ' Operating System (ubuntu-latest, windows-latest)'
1313 required : true
1414 default : ' ubuntu-latest'
1515
Original file line number Diff line number Diff line change @@ -293,10 +293,14 @@ private static void scheduleSnapshotWatcher() {
293293 * @return ScheduledFuture instance
294294 */
295295 public static ScheduledFuture <?> scheduleSnapshotAutoUpdate (String intervalValue , SnapshotCallback callback ) {
296- if (StringUtils .isBlank (intervalValue ) || scheduledExecutorService != null ) {
296+ if (StringUtils .isBlank (intervalValue )) {
297297 return null ;
298298 }
299299
300+ if (Objects .nonNull (scheduledExecutorService )) {
301+ terminateSnapshotAutoUpdateWorker ();
302+ }
303+
300304 final long interval = SwitcherUtils .getMillis (intervalValue );
301305 final SnapshotCallback callbackFinal = Optional .ofNullable (callback ).orElse (new SnapshotCallback () {});
302306 final Runnable runnableSnapshotValidate = () -> {
Original file line number Diff line number Diff line change @@ -219,11 +219,15 @@ void shouldNotKillThread_whenAPI_wentLocal() {
219219
220220 @ Test
221221 @ Order (6 )
222- void shouldPreventSnapshotAutoUpdateToStart_whenAlreadySetup () {
223- //given
222+ void shouldRestartSnapshotAutoUpdate_whenAlreadySetup () {
223+ //given - initialize (snapshot autoload)
224224 givenResponse (generateMockAuth (10 )); //auth
225225 givenResponse (generateSnapshotResponse ("default.json" , SNAPSHOTS_LOCAL )); //graphql
226226
227+ //given - snapshot auto update
228+ givenResponse (generateCheckSnapshotVersionResponse (Boolean .toString (false ))); //criteria/snapshot_check
229+ givenResponse (generateSnapshotResponse ("default.json" , SNAPSHOTS_LOCAL )); //graphql
230+
227231 //that
228232 Switchers .configure (ContextBuilder .builder (true )
229233 .context (Switchers .class .getCanonicalName ())
@@ -235,8 +239,9 @@ void shouldPreventSnapshotAutoUpdateToStart_whenAlreadySetup() {
235239 .snapshotAutoUpdateInterval ("1s" ));
236240
237241 Switchers .initializeClient ();
242+
238243 ScheduledFuture <?> snapshotUpdater = Switchers .scheduleSnapshotAutoUpdate ("1m" );
239- assertNull (snapshotUpdater );
244+ assertNotNull (snapshotUpdater );
240245 }
241246
242247}
You can’t perform that action at this time.
0 commit comments