4
我正在使用泽西岛v10并编写了下面的代码。这是关闭泽西岛客户端连接以避免内存泄漏的正确方法。在此之前,我终于没有做任何调用。泽西岛客户端连接关闭内存泄漏问题
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, 维杰