2323import org .junit .Ignore ;
2424import org .junit .Test ;
2525
26+ import java .util .concurrent .CompletableFuture ;
2627import java .util .concurrent .CountDownLatch ;
2728import java .util .concurrent .TimeUnit ;
2829import java .util .concurrent .atomic .AtomicBoolean ;
@@ -195,6 +196,20 @@ public void testUpdateConfigNotificationGetsTriggered() throws InterruptedExcept
195196 assertTrue (countDownLatch .await (500 , TimeUnit .MILLISECONDS ));
196197 }
197198
199+ @ Test
200+ public void testUpdateConfigNotificationDoesNotResultInDeadlock () throws Exception {
201+ NotificationCenter notificationCenter = new NotificationCenter ();
202+
203+ TestProjectConfigManager testProjectConfigManager = new TestProjectConfigManager (projectConfig , TimeUnit .SECONDS .toMillis (10 ), notificationCenter );
204+ notificationCenter .getNotificationManager (UpdateConfigNotification .class )
205+ .addHandler (message -> {
206+ assertNotNull (testProjectConfigManager .getConfig ());
207+ });
208+
209+ testProjectConfigManager .start ();
210+ CompletableFuture .runAsync (testProjectConfigManager ::getConfig ).get (5 , TimeUnit .SECONDS );
211+ }
212+
198213 private static class TestProjectConfigManager extends PollingProjectConfigManager {
199214 private final AtomicInteger counter = new AtomicInteger ();
200215
@@ -206,7 +221,11 @@ private TestProjectConfigManager() {
206221 }
207222
208223 private TestProjectConfigManager (ProjectConfig projectConfig ) {
209- super (POLLING_PERIOD , POLLING_UNIT , POLLING_PERIOD / 2 , POLLING_UNIT , new NotificationCenter ());
224+ this (projectConfig , POLLING_PERIOD / 2 , new NotificationCenter ());
225+ }
226+
227+ private TestProjectConfigManager (ProjectConfig projectConfig , long blockPeriod , NotificationCenter notificationCenter ) {
228+ super (POLLING_PERIOD , POLLING_UNIT , blockPeriod , POLLING_UNIT , notificationCenter );
210229 this .projectConfig = projectConfig ;
211230 }
212231
0 commit comments