@@ -87,22 +87,12 @@ private static boolean passesStaticAvailabilityCheck(ServiceLoader.Provider<?> p
8787
8888 @ VisibleForTesting
8989 static boolean passesStaticAvailabilityCheck (Class <?> type ) {
90- try {
91- return passesAvailabilityCheck (type , null );
92- } catch (ExceptionInInitializerError | NoClassDefFoundError | RuntimeException t ) {
93- LOG .warn ("Unable to load service provider {}." , type .getName (), t );
94- return false ;
95- }
90+ return silentlyPassesAvailabilityCheck (type , null );
9691 }
9792
9893 @ VisibleForTesting
9994 static boolean passesInstanceAvailabilityCheck (Object instance ) {
100- try {
101- return passesAvailabilityCheck (instance .getClass (), instance );
102- } catch (RuntimeException rte ) {
103- LOG .warn ("Unable to load service provider {}." , instance .getClass ().getName (), rte );
104- return false ;
105- }
95+ return silentlyPassesAvailabilityCheck (instance .getClass (), instance );
10696 }
10797
10898 private static void logServiceIsAvailable (Class <?> apiType , Class <?> implType ) {
@@ -111,6 +101,15 @@ private static void logServiceIsAvailable(Class<?> apiType, Class<?> implType) {
111101 }
112102 }
113103
104+ private static <T > boolean silentlyPassesAvailabilityCheck (Class <? extends T > type , @ Nullable T instance ) {
105+ try {
106+ return passesAvailabilityCheck (type , instance );
107+ } catch (ExceptionInInitializerError | NoClassDefFoundError | RuntimeException e ) {
108+ LOG .warn ("Unable to load service provider {}." , type .getName (), e );
109+ return false ;
110+ }
111+ }
112+
114113 private static <T > boolean passesAvailabilityCheck (Class <? extends T > type , @ Nullable T instance ) {
115114 if (!type .isAnnotationPresent (CheckAvailability .class )) {
116115 return true ; // if type is not annotated, skip tests
0 commit comments