diff --git a/src/test/java/com/launchdarkly/sdk/server/StreamProcessorTest.java b/src/test/java/com/launchdarkly/sdk/server/StreamProcessorTest.java index 50d2ad165..41a058e7f 100644 --- a/src/test/java/com/launchdarkly/sdk/server/StreamProcessorTest.java +++ b/src/test/java/com/launchdarkly/sdk/server/StreamProcessorTest.java @@ -554,6 +554,36 @@ public void restartsStreamIfStoreNeedsRefresh() throws Exception { } } + @Test + public void doesNotRestartStreamIfStoreHadOutageButDoesNotNeedRefresh() throws Exception { + TestComponents.DataStoreWithStatusUpdates storeWithStatus = new TestComponents.DataStoreWithStatusUpdates(dataStore); + + SettableFuture restarted = SettableFuture.create(); + mockEventSource.start(); + expectLastCall(); + mockEventSource.restart(); + expectLastCall().andAnswer(() -> { + restarted.set(null); + return null; + }); + mockEventSource.close(); + expectLastCall(); + mockRequestor.close(); + expectLastCall(); + + replayAll(); + + try (StreamProcessor sp = createStreamProcessorWithStore(storeWithStatus)) { + sp.start(); + + storeWithStatus.broadcastStatusChange(new DataStoreStatusProvider.Status(false, false)); + storeWithStatus.broadcastStatusChange(new DataStoreStatusProvider.Status(true, false)); + + Thread.sleep(500); + assertFalse(restarted.isDone()); + } + } + @Test public void storeFailureOnPutCausesStreamRestart() throws Exception { DataStore badStore = dataStoreThatThrowsException(new RuntimeException("sorry"));