Invalid use of SingleClientConnManager: connection still allocated解决方案
来源:互联网 发布:网络灰色项目一天一万 编辑:程序博客网 时间:2024/05/17 22:01
在做项目的时候,看到后台打印的这样的错误
09-25 15:02:14.741: W/SingleClientConnManager(16430): Invalid use of SingleClientConnManager: connection still allocated.
09-25 15:02:14.741: W/SingleClientConnManager(16430): Make sure to release the connection before allocating another one.
此问题出现原因是使用同一个httpclient当 前一个post|get请求尚未结束,另条线程又再次使用该httpclient请求数据,则前一个会报出如上错误
出现原因
1: 每次重新New一个新的httpclien,进行请求
2:post/get没有关闭,没有写post.abort()或者 EntityUtils.consume(entity);
3:涉及到多线程调用同一个httpclient
解决方案考虑加同步块
synchronized(httpclient){
response=httpclient.execute(get);
entity=response.getEntity();
EntityUtils.consume(entity);
}
EntityUtils.toString(entity)
其实这个问题可以直接用httpclient的多线程解决,没必要这么麻烦
二:非法uri问题
一些asp网站中,常常出现url例如www.baidu.com?q=%34ut%3333 这个url不是合法的uri却是合法的url。
而httpclient4.1中无论httpget、httppost都是用uri而非url,曾尝试反编译,改源代码,一看工作量实在太大,只好放弃,此问题小弟没有其他方法,只好拿起httpclient3.1
真不知道httpclient4基于uri是什么原因......还望高手教教俺
- Invalid use of SingleClientConnManager: connection still allocated解决方案
- Invalid use of SingleClientConnManager: connection still allocated
- Invalid use of SingleClientConnManager: connection still allocated.
- W/SingleClientConnManager(1155):Invalid use of SingleClientConnManager: connection still allocated.
- HttpClient4.X Invalid use of SingleClientConnManager: connection still allocated问题
- HttpClient4.X Invalid use of SingleClientConnManager: connection still allocated
- httpclient4.1.2抓数据Invalid use of SingleClientConnManager: connection still allocated解决方案
- Invalid use of BasicClientConnManager: connection still allocated解决方案
- Invalid use of BasicClientConnManager: connection still allocated.
- Invalid use of BasicClientConnManager: connection still allocated.
- httpclient Invalid use of SingleClientConnManager: connection still alloc
- Invalid use of SingleClientConnManager: connection still allocatedMake sure to release the connectio
- 调用rest地址时异常:Invalid use of BasicClientConnManager: connection still allocated.
- HttpClient:connection still allocated.解决方法
- connection 'qt_sql_default_connection' is still in use
- some use of connection
- some use of connection
- QSqlDatabasePrivate::removeDatabase: connection 'qt_sql_default_connection' is still in use
- VB.net学习笔记之发送邮件:System.Net.Mail
- xcode cocos2d-x js lus 脚本更新代码
- 如何将整数int转换成字符串String?
- 利用MVC4将数据保存为CSV格式文件并指定目录
- POJ 3041 Asteroids
- Invalid use of SingleClientConnManager: connection still allocated解决方案
- BlazeDS中Java与ActionScript类型对应表
- hdu 1052
- Chrome 自带的 user agent stylesheet 与 html中<!DOCTYPE>标签
- MQ的安装和下载
- 51nod1262 扔球(欧拉函数)
- Android 自动完全组件(SocialTokenAutoComplete)—— 一种更友好的方式@某人在社交应用中
- struts2随笔(一)Action、struts.xml、Interceptor细节
- vc环境下的窗口程序