auto close after async response

This commit is contained in:
Jörg Prante 2021-05-06 14:07:34 +02:00
parent b97c7407d2
commit b6930ac373
3 changed files with 4 additions and 3 deletions

View file

@ -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

View file

@ -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);
}

View file

@ -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();
}