From d3e16cff474fe050e8093487201d57d5c9f5c7fb Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Mon, 8 Jun 2026 22:06:28 +0000 Subject: [PATCH] test: increase poll timeouts in canIterateEvents to fix flake PipedInputStream.read() has a built-in wait(1000) when the pipe buffer is empty. If the pipe writer thread hasn't written data before EventSource starts reading, this causes up to a 1-second delay. Combined with the 1-second queue poll timeout, the poll can expire just as data arrives. Increase poll timeouts from 1s to 5s. The tests remain fast because poll returns immediately when data arrives. Co-Authored-By: rlamb@launchdarkly.com <4955475+kinyoklion@users.noreply.github.com> --- .../eventsource/EventSourceReadingTest.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/test/java/com/launchdarkly/eventsource/EventSourceReadingTest.java b/src/test/java/com/launchdarkly/eventsource/EventSourceReadingTest.java index 8110507..cf87245 100644 --- a/src/test/java/com/launchdarkly/eventsource/EventSourceReadingTest.java +++ b/src/test/java/com/launchdarkly/eventsource/EventSourceReadingTest.java @@ -303,16 +303,16 @@ public void canIterateEvents() throws Exception { } }).start(); - StreamEvent e1 = queue.poll(1, TimeUnit.SECONDS); + StreamEvent e1 = queue.poll(5, TimeUnit.SECONDS); assertThat(e1, equalTo(new StartedEvent())); - StreamEvent e2 = queue.poll(1, TimeUnit.SECONDS); + StreamEvent e2 = queue.poll(5, TimeUnit.SECONDS); assertThat(e2, equalTo(new MessageEvent("a", "data1", null, ORIGIN))); - StreamEvent e3 = queue.poll(1, TimeUnit.SECONDS); + StreamEvent e3 = queue.poll(5, TimeUnit.SECONDS); assertThat(e3, equalTo(new CommentEvent("nice"))); - StreamEvent e4 = queue.poll(1, TimeUnit.SECONDS); + StreamEvent e4 = queue.poll(5, TimeUnit.SECONDS); assertThat(e4, equalTo(new MessageEvent("b", "data2", null, ORIGIN))); assertThat("iterator should not have finished yet because we didn't close the stream", @@ -321,7 +321,7 @@ public void canIterateEvents() throws Exception { stream.close(); assertThat("timed out waiting for iterator on reader thread to finish", - iteratorFinished.tryAcquire(1, TimeUnit.SECONDS), is(true)); + iteratorFinished.tryAcquire(5, TimeUnit.SECONDS), is(true)); } @Test