Improve Http1xTest#testCloseTheConnectionAfterResetBeforeResponseReceived reliability

This commit is contained in:
Julien Viet
2019-05-03 10:49:09 +02:00
parent b26ab636f9
commit c3df210150

View File

@@ -3403,6 +3403,7 @@ public class Http1xTest extends HttpTest {
server.close();
NetServer server = vertx.createNetServer();
CompletableFuture<Void> requestReceived = new CompletableFuture<>();
CompletableFuture<Void> sendResponse = new CompletableFuture<>();
try {
AtomicInteger count = new AtomicInteger();
AtomicBoolean closed = new AtomicBoolean();
@@ -3416,12 +3417,14 @@ public class Http1xTest extends HttpTest {
"host: localhost:8080\r\n" +
"\r\n")) {
requestReceived.complete(null);
so.write(Buffer.buffer(
sendResponse.whenComplete((v, err) -> {
so.write(Buffer.buffer(
"HTTP/1.1 200 OK\r\n" +
"Content-Length: 11\r\n" +
"\r\n" +
"Some-Buffer"
));
"Content-Length: 11\r\n" +
"\r\n" +
"Some-Buffer"
));
});
so.closeHandler(v -> {
closed.set(true);
});
@@ -3458,6 +3461,7 @@ public class Http1xTest extends HttpTest {
client.close();
client = vertx.createHttpClient(createBaseClientOptions().setMaxPoolSize(1).setPipelining(pipelined).setKeepAlive(true));
HttpClientRequest req1 = client.request(HttpMethod.GET, testAddress, DEFAULT_HTTP_PORT, DEFAULT_HTTP_HOST, "/1");
req1.exceptionHandler(err -> sendResponse.complete(null));
if (pipelined) {
requestReceived.thenAccept(v -> {
req1.reset();