@@ -401,6 +401,7 @@ public void testPollingClient() throws ExecutionException, InterruptedException
401
401
EppoHttpClient mockHttpClient = mock (EppoHttpClient .class );
402
402
403
403
CountDownLatch pollLatch = new CountDownLatch (1 );
404
+ CountDownLatch configActivatedLatch = new CountDownLatch (1 );
404
405
405
406
// The poller fetches synchronously so let's return the boolean flag config
406
407
when (mockHttpClient .get (anyString ()))
@@ -433,6 +434,10 @@ public void testPollingClient() throws ExecutionException, InterruptedException
433
434
.isGracefulMode (false );
434
435
435
436
EppoClient eppoClient = clientBuilder .buildAndInitAsync ().get ();
437
+ eppoClient .onConfigurationChange (
438
+ (config ) -> {
439
+ configActivatedLatch .countDown ();
440
+ });
436
441
437
442
// Empty config on initialization
438
443
verify (mockHttpClient , times (1 )).getAsync (anyString ());
@@ -441,10 +446,10 @@ public void testPollingClient() throws ExecutionException, InterruptedException
441
446
// Wait for the client to send the "fetch"
442
447
assertTrue ("Polling did not occur within timeout" , pollLatch .await (5 , TimeUnit .SECONDS ));
443
448
444
- // Sleep a short period to allow the polling mechanism to complete writing the config.
445
- // The above latch releases immediately after the config is "fetched", not necessarily before
446
- // the config is applied.
447
- Thread . sleep ( 150 );
449
+ // Wait for the client to apply the fetch and notify of config change .
450
+ assertTrue (
451
+ "Configuration not activated within timeout" ,
452
+ configActivatedLatch . await ( 250 , TimeUnit . MILLISECONDS ) );
448
453
449
454
// Assignment is now true.
450
455
assertTrue (eppoClient .getBooleanAssignment ("bool_flag" , "subject1" , false ));
0 commit comments