Resource should be released in HttpClient example

This commit is contained in:
Trustin Lee 2008-11-27 01:11:53 +00:00
parent 7a87543020
commit 00fbf2a2f3

View File

@ -87,7 +87,12 @@ public class HttpClient {
// Send the HTTP request. // Send the HTTP request.
HttpRequest request = new DefaultHttpRequest(HttpVersion.HTTP_1_0, HttpMethod.GET, uri); HttpRequest request = new DefaultHttpRequest(HttpVersion.HTTP_1_0, HttpMethod.GET, uri);
request.addHeader(HttpHeaders.HOST, host); request.addHeader(HttpHeaders.HOST, host);
ChannelFuture lastWriteFuture = channel.write(request); channel.write(request);
lastWriteFuture.awaitUninterruptibly();
// Wait for the server to close the connection.
channel.getCloseFuture().awaitUninterruptibly();
// Shut down executor threads to exit.
factory.getExternalResource().release();
} }
} }