我有一个Java进程,其中我使用HttpClient
和PoolingClientConnectionManager
并使用多个执行线程在CouchDB
数据库之间复制文件。
代码是这样的:
private boolean copyDocuments(JsonArray docs) {
PoolingClientConnectionManager clientConnectionManager = new PoolingClientConnectionManager();
clientConnectionManager.setMaxTotal(50);
clientConnectionManager.setDefaultMaxPerRoute(50);
HttpClient httpClient = new DefaultHttpClient(clientConnectionManager);
//Fixed thread pool initialized using ExecutorService
try{
//iterate documents and create runnable threads for each document using the executor service. Each thread will use the same httpClient instance with a local HttpContext
}
...
} finally {
httpClient.getConnectionManager().shutdown();
}
我担心的是,当我在finally块中关闭连接管理器时,是否可能有Runtime exceptions
,如果是,我是否应该处理它。