commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Remko Popma <remko.po...@gmail.com>
Subject Re: [DBCP] org.apache.commons.dbcp2.datasources.InstanceKeyDataSourceFactory.closeAll() does not close all
Date Sun, 10 Jun 2018 23:25:30 GMT
Good question. 
I’ve never liked `close()` methods that throw exceptions. What is the client code supposed
to do?

It certainly makes sense to me to first fulfill the promise of “closeAll”, which is to
call `close` on all values (and not stop half-way through).

The remaining question is what to do with any exceptions (there could be multiple) that occurred
during this process. 

One idea is to rethrow the first one. Another is to throw a MultipleExceptions from which
the client code can obtain all exceptions that occurred. But then again, given that there
is little that the client code can do with these exceptions, why not _return_ a list of the
exceptions that occurred?

Remko

(Shameless plug) Every java main() method deserves http://picocli.info

> On Jun 11, 2018, at 1:14, Gary Gregory <garydgregory@gmail.com> wrote:
> 
> org.apache.commons.dbcp2.datasources.InstanceKeyDataSourceFactory.closeAll()
> does not close all if one of delegated close() calls throws an exception.
> 
> I would think we would want to close all no matter what and then save the
> first exception caught and rethrow it after all closes have been attempted.
> 
> Thoughts?
> 
> Gary

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Mime
View raw message