[ 
https://issues.apache.org/jira/browse/DISCOVERY-11?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13017498#comment-13017498
 ] 

Simone Tripodi commented on DISCOVERY-11:
-----------------------------------------

thanks for your feedbacks! so what about catching not just Exception but even 
Throwable? I mean, instead of

{code}
            private S getNextClassInstance() {
                while (services.hasNext()) {
                    ResourceClass<S> info = services.nextResourceClass();
                    try {
                        return spi.newInstance(info.loadClass());
                    } catch (Exception e) {
                        // ignore
                    }
                }
                return null;
            }
{code}

we will have

{code}
            private S getNextClassInstance() {
                while (services.hasNext()) {
                    ResourceClass<S> info = services.nextResourceClass();
                    try {
                        return spi.newInstance(info.loadClass());
                    } catch (Throwable t) {
                        // TODO logging the exception
                    }
                }
                return null;
            }
{code}

sounds more reasonable according to your suggestions?

@Michael: make the behavior configurable sounds the better "nice to have", but 
I wouldn't add a new API in this maintenance release, does it sound good to you?

> Service.providers Enumeration does not catch and discard 
> UnsatisfiedLinkErrors and ExceptionInInitializerErrors
> ---------------------------------------------------------------------------------------------------------------
>
>                 Key: DISCOVERY-11
>                 URL: https://issues.apache.org/jira/browse/DISCOVERY-11
>             Project: Commons Discovery
>          Issue Type: Bug
>    Affects Versions: 0.4
>         Environment: Windows, Sun JDK 1.5.0.10
>            Reporter: Michael Rudolf
>
> The enumeration created by Service.providers does not catch 
> UnsatisfiedLinkErrors and ExceptionInInitializerErrors. The former can arise, 
> if a class contains a call to System.loadLibrary(String) in its static 
> initializer, while the latter will be thrown, when a runtime exception is 
> thrown from the static initializer. Service.providers should catch and ignore 
> these and it should simply discard the class provoking the error as not 
> available. As of version 0.4, Commons Discovery just forwards these errors.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to