Use Advanced Search to search the entire archive.
[jsr363-experts] Notes on DefaultServiceProvider
- From: Martin Desruisseaux <
>
- To:
- Subject: [jsr363-experts] Notes on DefaultServiceProvider
- Date: Fri, 18 Mar 2016 01:21:49 +0100
- Organization: Geomatys
To refresh my memory about Bootstrap, I had a quick look to the content
of javax.measure.spi package. It provides a DefaultServiceProvider class
(not public, thanks)
https://github.com/unitsofmeasurement/unit-api/blob/master/src/main/java/javax/measure/spi/DefaultServiceProvider.java
Just a few notes:
* This class probably needs to be thread-safe, but current version is not.
* Line 101 has a check for null value, but the value can not be null
at that point because of the enclosing "if" statement (assuming no
multi-threading since the class is not thread-safe).
* The "catch (Exception e)" at line 104 is not effective. In case of
error, ServiceConfigurationLoader throws a ConfigurationError, which
is not an Exception subclass.
Actually in my understanding of ServiceLoader.iterator() javadoc, we
should not even try to catch anything there. The JDK documentation said
/"malformed provider-configuration file, like a malformed class file,
indicates a serious problem with the way the Java virtual machine is
configured or is being used. As such it is preferable to throw an error
rather than try to recover or, even worse, fail silently."/ The current
behaviour is to fail almost silently, with only a message logged at
Level.INFO and ignoring all other providers that may have existed after
the failed one.
Regards,
Martin