Fixed racy test (#6584)

Signed-off-by: Greg Wilkins <gregw@webtide.com>
This commit is contained in:
Greg Wilkins 2021-08-04 14:25:07 +10:00 committed by GitHub
parent 342396c7ee
commit fc0a4dc141
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 20 additions and 6 deletions

View File

@ -767,7 +767,7 @@ public class HttpOutputTest
@Test @Test
public void testEmptyArray() throws Exception public void testEmptyArray() throws Exception
{ {
AtomicBoolean committed = new AtomicBoolean(); FuturePromise<Boolean> committed = new FuturePromise<>();
AbstractHandler handler = new AbstractHandler() AbstractHandler handler = new AbstractHandler()
{ {
@Override @Override
@ -775,8 +775,15 @@ public class HttpOutputTest
{ {
baseRequest.setHandled(true); baseRequest.setHandled(true);
response.setStatus(200); response.setStatus(200);
try
{
response.getOutputStream().write(new byte[0]); response.getOutputStream().write(new byte[0]);
committed.set(response.isCommitted()); committed.succeeded(response.isCommitted());
}
catch (Throwable t)
{
committed.failed(t);
}
} }
}; };
@ -790,7 +797,7 @@ public class HttpOutputTest
@Test @Test
public void testEmptyArrayKnown() throws Exception public void testEmptyArrayKnown() throws Exception
{ {
AtomicBoolean committed = new AtomicBoolean(); FuturePromise<Boolean> committed = new FuturePromise<>();
AbstractHandler handler = new AbstractHandler() AbstractHandler handler = new AbstractHandler()
{ {
@Override @Override
@ -799,8 +806,15 @@ public class HttpOutputTest
baseRequest.setHandled(true); baseRequest.setHandled(true);
response.setStatus(200); response.setStatus(200);
response.setContentLength(0); response.setContentLength(0);
try
{
response.getOutputStream().write(new byte[0]); response.getOutputStream().write(new byte[0]);
committed.set(response.isCommitted()); committed.succeeded(response.isCommitted());
}
catch (Throwable t)
{
committed.failed(t);
}
} }
}; };