我正在使用 Jersey v10 并编写了以下代码。这是关闭 Jersey 客户端连接以避免内存泄漏的正确方法吗?在此之前我最终没有对他进行任何调用。
ClientConfig config = setupHttps();
final Client c = Client.create(config);
final WebResource r = c.resource(baseUri);
ClientResponse response = null;
try {
response = r.path("/....")
.header("contentId", id)
.header("sid", sid).get(ClientResponse.class);
...
} catch (Exception e) {
log.error("Error returning contentServiceName.");
} finally {
if (response != null) {
response.close();
}
if (c!= null) {
c.destroy();
}
}
TIA,维杰