Skip to content

Commit 5ec808d

Browse files
committed
Revert "proxy httpclient does not release connection pool when frontend close chunked response (#90)"
This reverts commit 477ca41.
1 parent 477ca41 commit 5ec808d

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

src/main/java/io/vertx/httpproxy/impl/ProxiedRequest.java

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,19 @@
1010
*/
1111
package io.vertx.httpproxy.impl;
1212

13-
import io.vertx.core.*;
13+
import io.vertx.core.AsyncResult;
14+
import io.vertx.core.Future;
15+
import io.vertx.core.Handler;
16+
import io.vertx.core.MultiMap;
17+
import io.vertx.core.Promise;
1418
import io.vertx.core.buffer.Buffer;
15-
import io.vertx.core.http.*;
19+
import io.vertx.core.http.HttpClientRequest;
20+
import io.vertx.core.http.HttpHeaders;
21+
import io.vertx.core.http.HttpMethod;
22+
import io.vertx.core.http.HttpServerRequest;
23+
import io.vertx.core.http.HttpVersion;
1624
import io.vertx.core.http.impl.HttpServerRequestInternal;
1725
import io.vertx.core.impl.ContextInternal;
18-
import io.vertx.core.impl.logging.Logger;
19-
import io.vertx.core.impl.logging.LoggerFactory;
2026
import io.vertx.core.net.HostAndPort;
2127
import io.vertx.core.streams.Pipe;
2228
import io.vertx.httpproxy.Body;
@@ -27,7 +33,6 @@
2733
import java.util.Objects;
2834

2935
public class ProxiedRequest implements ProxyRequest {
30-
private final static Logger log = LoggerFactory.getLogger(ProxiedRequest.class);
3136

3237
private static final CharSequence X_FORWARDED_HOST = HttpHeaders.createOptimized("x-forwarded-host");
3338

@@ -150,14 +155,6 @@ public ProxyResponse response() {
150155
}
151156

152157
void sendRequest(Handler<AsyncResult<ProxyResponse>> responseHandler) {
153-
proxiedRequest.connection().closeHandler(unused -> {
154-
if (log.isTraceEnabled()) {
155-
log.trace("Frontend connection closed,uri: " + proxiedRequest.uri());
156-
}
157-
158-
request.reset();
159-
proxiedRequest.response().reset();
160-
});
161158

162159
request.response().<ProxyResponse>map(r -> {
163160
r.pause(); // Pause it

src/test/java/io/vertx/httpproxy/ProxyClientKeepAliveTest.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import io.vertx.core.streams.WriteStream;
2121
import io.vertx.ext.unit.Async;
2222
import io.vertx.ext.unit.TestContext;
23+
import org.junit.Ignore;
2324
import org.junit.Test;
2425

2526
import java.io.Closeable;
@@ -258,7 +259,7 @@ public void testFrontendCloseResponse(TestContext ctx) {
258259

259260
@Test
260261
public void testFrontendCloseChunkedResponse(TestContext ctx) {
261-
testFrontendCloseResponse(ctx, true);
262+
testBackendCloseResponse(ctx, true);
262263
}
263264

264265
private void testFrontendCloseResponse(TestContext ctx, boolean chunked) {
@@ -271,12 +272,14 @@ private void testFrontendCloseResponse(TestContext ctx, boolean chunked) {
271272
resp.putHeader("content-length", "10000");
272273
}
273274
resp.write("part");
274-
resp.closeHandler(unused -> async.complete());
275+
resp.exceptionHandler(err -> {
276+
async.complete();
277+
});
275278
});
276279
startProxy(backend);
277280
HttpClient client = vertx.createHttpClient();
278-
client.request(GET, 8080, "localhost", "/").onComplete(ctx.asyncAssertSuccess(req -> {
279-
req.send().onComplete(ctx.asyncAssertSuccess(resp -> {
281+
client.request(GET, 8081, "localhost", "/", ctx.asyncAssertSuccess(req -> {
282+
req.send(ctx.asyncAssertSuccess(resp -> {
280283
resp.handler(buff -> {
281284
resp.request().connection().close();
282285
System.out.println("closing");

0 commit comments

Comments
 (0)