Skip to content

Commit

Permalink
Just catch, do not inspect ServiceConfigurationError
Browse files Browse the repository at this point in the history
  • Loading branch information
infeo committed Feb 23, 2024
1 parent 0e61467 commit 1fa0066
Showing 1 changed file with 4 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,10 @@ private static <T> Stream<T> instantiateServiceProvider(ServiceLoader.Provider<T
return Stream.of(provider.get());
} catch (ServiceConfigurationError err) {
//ServiceLoader.Provider::get throws this error if (from javadoc)
if (err.getCause() == null || //the public static "provider()" method of a provider factory returns null
err.getCause() instanceof ExceptionInInitializerError || // * the service provider cannot be instantiated,
err.getCause() instanceof NoClassDefFoundError ||
err.getCause() instanceof RuntimeException) {
LOG.warn("Unable to load service provider {}.", provider.type().getName(), err);
return Stream.empty();
} else {
throw err;
}
// * the public static "provider()" method of a provider factory returns null
// * the service provider cannot be instantiated due to an error/throw
LOG.warn("Unable to load service provider {}.", provider.type().getName(), err);
return Stream.empty();
}
}

Expand Down

0 comments on commit 1fa0066

Please sign in to comment.