Skip to content

Commit

Permalink
Fix flaky test from #6562/#6563 (#6628)
Browse files Browse the repository at this point in the history
Fix flaky test from #6562
Disable ipv6 test for #6624
  • Loading branch information
gregw committed Aug 17, 2021
1 parent 569455c commit a3f7747
Showing 1 changed file with 6 additions and 9 deletions.
Expand Up @@ -27,9 +27,7 @@
import java.nio.channels.ReadableByteChannel;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import javax.servlet.AsyncContext;
import javax.servlet.ServletException;
Expand Down Expand Up @@ -830,7 +828,7 @@ public void handle(String target, Request baseRequest, HttpServletRequest reques
@Test
public void testEmptyBuffer() throws Exception
{
AtomicBoolean committed = new AtomicBoolean();
FuturePromise<Boolean> committed = new FuturePromise<>();
AbstractHandler handler = new AbstractHandler()
{
@Override
Expand All @@ -839,21 +837,21 @@ public void handle(String target, Request baseRequest, HttpServletRequest reques
baseRequest.setHandled(true);
response.setStatus(200);
((HttpOutput)response.getOutputStream()).write(ByteBuffer.wrap(new byte[0]));
committed.set(response.isCommitted());
committed.succeeded(response.isCommitted());
}
};

_swap.setHandler(handler);
handler.start();
String response = _connector.getResponse("GET / HTTP/1.0\nHost: localhost:80\n\n");
assertThat(response, containsString("HTTP/1.1 200 OK"));
assertThat(committed.get(), is(false));
assertThat(committed.get(10, TimeUnit.SECONDS), is(false));
}

@Test
public void testEmptyBufferWithZeroContentLength() throws Exception
{
CountDownLatch latch = new CountDownLatch(1);
FuturePromise<Boolean> committed = new FuturePromise<>();
AbstractHandler handler = new AbstractHandler()
{
@Override
Expand All @@ -863,8 +861,7 @@ public void handle(String target, Request baseRequest, HttpServletRequest reques
response.setStatus(200);
response.setContentLength(0);
((HttpOutput)response.getOutputStream()).write(ByteBuffer.wrap(new byte[0]));
assertThat(response.isCommitted(), is(true));
latch.countDown();
committed.succeeded(response.isCommitted());
}
};

Expand All @@ -873,7 +870,7 @@ public void handle(String target, Request baseRequest, HttpServletRequest reques
String response = _connector.getResponse("GET / HTTP/1.0\nHost: localhost:80\n\n");
assertThat(response, containsString("HTTP/1.1 200 OK"));
assertThat(response, containsString("Content-Length: 0"));
assertThat(latch.await(3, TimeUnit.SECONDS), is(true));
assertThat(committed.get(10, TimeUnit.SECONDS), is(true));
}

@Test
Expand Down

0 comments on commit a3f7747

Please sign in to comment.