XMLConfigurator.createClassInstance() should catch Throwable ?

Brent Putman putmanb at georgetown.edu
Fri Jun 1 19:54:17 EDT 2018



On 5/31/18 5:04 PM, Tom Zeller wrote:
> TL;DR I think that
> org.opensaml.core.xml.config.XMLConfigurator.createClassInstance()
> should catch/handle Throwable in addition to Exception.
>
>

I think that's fine to do. Probably also need to widen the ctor args of
XMLConfigurationException to take a Throwable instead of Exception, so
as not to have nasty conditional logic in the catch.

I think it does lead though to the more philosophical question in Java
of when/where we should care about this case in general.  Any code
anywhere can theoretically throw an unchecked java.lang.Error.  But we
obviously aren't going to generally catch Throwable *everywhere*, as
opposed to specific types of checked exceptions.  And we don't
generally catch java.lang.Exception to cover unchecked
java.lang.RuntimeException, for the same reasons.  Both of those are
generally fatal (which is why they are unchecked), so it begs the
question when is it appropriate to handle explicitly.  If there's a
specific case we've actually encountered then I guess that's a good
argument - for better logging, etc.  But there's probably umpteen other
similar cases we don't (yet).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://shibboleth.net/pipermail/dev/attachments/20180601/4dc2f635/attachment.html>


More information about the dev mailing list