HttpClient连接管理器关闭期间是否可能出现运行时异常?

时间:2018-09-20 05:50:55

标签: java apache http httpclient

我有一个Java进程,其中我使用HttpClientPoolingClientConnectionManager并使用多个执行线程在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,如果是,我是否应该处理它。

0 个答案:

没有答案