首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > Ruby Rails >

HttpClient_error_Too many open files_怎么正确关闭连接和流

2013-07-11 
HttpClient_error_Too many open files_如何正确关闭连接和流HttpClient_error_Too many open files_如何

HttpClient_error_Too many open files_如何正确关闭连接和流

HttpClient_error_Too many open files_如何正确关闭连接和流

?

Error:

java.io.FileNotFoundException: /usr/local/app/xxx.jpg (Too many open files)

?

症状分析:

经过检查,读写文件的流都已经正确关闭了,还是报告打开文件数过多

应该就是httpClient的问题了

?

解决:

官方文档HttpClient的API中:

     // When HttpClient instance is no longer needed,     // shut down the connection manager to ensure     // immediate deallocation of all system resources     httpclient.getConnectionManager().shutdown();

?

另外,如果多个线程使用一个httpClient,注意releaseConnection

public?void?releaseConnection()
A convenience method to simplify migration from HttpClient 3.1 API. This method is equivalent to?reset().

?

public?void?reset()
Resets internal state of the request making it reusable.?参考:?HttpClient容易忽视的细节——连接关闭?http://www.iteye.com/topic/234759http://www.2cto.com/kf/201109/103561.html?===+===

热点排行