From b6930ac37344fa38741c2919fb48608ec36711ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=CC=88rg=20Prante?= Date: Thu, 6 May 2021 14:07:34 +0200 Subject: [PATCH] auto close after async response --- gradle.properties | 2 +- .../main/java/org/xbib/netty/http/client/rest/RestClient.java | 3 ++- .../org/xbib/netty/http/client/transport/BaseTransport.java | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/gradle.properties b/gradle.properties index 2211a83..892f571 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ group = org.xbib name = netty-http -version = 4.1.63.2 +version = 4.1.63.3 gradle.wrapper.version = 6.6.1 netty.version = 4.1.63.Final diff --git a/netty-http-client-rest/src/main/java/org/xbib/netty/http/client/rest/RestClient.java b/netty-http-client-rest/src/main/java/org/xbib/netty/http/client/rest/RestClient.java index abd0c7f..f1f0612 100644 --- a/netty-http-client-rest/src/main/java/org/xbib/netty/http/client/rest/RestClient.java +++ b/netty-http-client-rest/src/main/java/org/xbib/netty/http/client/rest/RestClient.java @@ -73,7 +73,8 @@ public class RestClient { requestBuilder.content(byteBuf); } client.newTransport(HttpAddress.http1(url)) - .execute(requestBuilder.setResponseListener(restClient::setResponse).build()).close(); + .execute(requestBuilder.setResponseListener(restClient::setResponse).build()) + .close(); } catch (Exception e) { throw new IOException(e); } diff --git a/netty-http-client/src/main/java/org/xbib/netty/http/client/transport/BaseTransport.java b/netty-http-client/src/main/java/org/xbib/netty/http/client/transport/BaseTransport.java index c98fa37..ff2a948 100644 --- a/netty-http-client/src/main/java/org/xbib/netty/http/client/transport/BaseTransport.java +++ b/netty-http-client/src/main/java/org/xbib/netty/http/client/transport/BaseTransport.java @@ -94,6 +94,7 @@ public abstract class BaseTransport implements ClientTransport { } else { completableFuture.cancel(true); } + close(); }); execute(request); return completableFuture; @@ -101,7 +102,6 @@ public abstract class BaseTransport implements ClientTransport { @Override public void close() { - // channels are present, maybe forgot a get() to receive responses? get(); cancel(); }