我这样定义httpclient,当serval requset调用execute方法时,我发现有一个方法retuslt是一样的,如何修复这个bug?现在我想锁定execute方法,对吗?
//defind global variable:client
Registry<ConnectionSocketFactory> reg = RegistryBuilder.<ConnectionSocketFactory>create()
.register("http", new PlainConnectionSocketFactory())) .build();
PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager(reg);
client = HttpClients.custom()
.setConnectionManager(cm).build();
//call method
synchronized (this) {
HttpResponse response = client.execute(get);
if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
System.out.println(EntityUtils.toString(response.getEntity()));
}
}
暂无答案!
目前还没有任何答案,快来回答吧!