From fc0a4dc141f6be694b4b1d6c37cc6d031b0f8c0c Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Wed, 4 Aug 2021 14:25:07 +1000 Subject: [PATCH] Fixed racy test (#6584) Signed-off-by: Greg Wilkins --- .../eclipse/jetty/server/HttpOutputTest.java | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/HttpOutputTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/HttpOutputTest.java index 36d8d34b7e0..725dfe9c91b 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/HttpOutputTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/HttpOutputTest.java @@ -767,7 +767,7 @@ public class HttpOutputTest @Test public void testEmptyArray() throws Exception { - AtomicBoolean committed = new AtomicBoolean(); + FuturePromise committed = new FuturePromise<>(); AbstractHandler handler = new AbstractHandler() { @Override @@ -775,8 +775,15 @@ public class HttpOutputTest { baseRequest.setHandled(true); response.setStatus(200); - response.getOutputStream().write(new byte[0]); - committed.set(response.isCommitted()); + try + { + response.getOutputStream().write(new byte[0]); + committed.succeeded(response.isCommitted()); + } + catch (Throwable t) + { + committed.failed(t); + } } }; @@ -790,7 +797,7 @@ public class HttpOutputTest @Test public void testEmptyArrayKnown() throws Exception { - AtomicBoolean committed = new AtomicBoolean(); + FuturePromise committed = new FuturePromise<>(); AbstractHandler handler = new AbstractHandler() { @Override @@ -799,8 +806,15 @@ public class HttpOutputTest baseRequest.setHandled(true); response.setStatus(200); response.setContentLength(0); - response.getOutputStream().write(new byte[0]); - committed.set(response.isCommitted()); + try + { + response.getOutputStream().write(new byte[0]); + committed.succeeded(response.isCommitted()); + } + catch (Throwable t) + { + committed.failed(t); + } } };