@Test public void exceptionSurfacedToCaller_failAtAvailable() { ClassLoader cl = new ReplacingClassLoader(getClass().getClassLoader(), serviceFile, "io/grpc/ServiceProvidersTestAbstractProvider-failAtAvailableProvider.txt"); try { ServiceProvidersTestAbstractProvider ignored = ServiceProviders.load( ServiceProvidersTestAbstractProvider.class, NO_HARDCODED, cl, ACCESSOR); fail("Expected exception"); } catch (FailAtAvailableProvider.AvailableException expected) { } }
public static <T> T load( Class<T> klass, Iterable<Class<?>> hardcoded, ClassLoader cl, PriorityAccessor<T> priorityAccessor) { List<T> candidates = loadAll(klass, hardcoded, cl, priorityAccessor); if (candidates.isEmpty()) { return null; } return candidates.get(0); }
ServiceProviders { public static <T> T load( Class<T> klass, Iterable<Class<?>> hardcoded, ClassLoader cl, PriorityAccessor<T> priorityAccessor) { List<T> candidates = loadAll(klass, hardcoded, cl, priorityAccessor); if (candidates.isEmpty()) { return null; } return candidates.get(0); } }
ServiceProviders { public static <T> T load( Class<T> klass, Iterable<Class<?>> hardcoded, ClassLoader cl, PriorityAccessor<T> priorityAccessor) { List<T> candidates = loadAll(klass, hardcoded, cl, priorityAccessor); if (candidates.isEmpty()) { return null; } return candidates.get(0); } private  ServiceProviders(); }
ServiceProviders { public static <T> T load( Class<T> klass, Iterable<Class<?>> hardcoded, ClassLoader cl, PriorityAccessor<T> priorityAccessor) { List<T> candidates = loadAll(klass, hardcoded, cl, priorityAccessor); if (candidates.isEmpty()) { return null; } return candidates.get(0); } private  ServiceProviders(); static T load(
      Class<T> klass,
      Iterable<Class<?>> hardcoded,
      ClassLoader cl,
      PriorityAccessor<T> priorityAccessor); static List<T> loadAll(
      Class<T> klass,
      Iterable<Class<?>> hardcoded,
      ClassLoader cl,
      final PriorityAccessor<T> priorityAccessor); @VisibleForTesting static Iterable<T> getCandidatesViaServiceLoader(Class<T> klass, ClassLoader cl); }
ServiceProviders { public static <T> T load( Class<T> klass, Iterable<Class<?>> hardcoded, ClassLoader cl, PriorityAccessor<T> priorityAccessor) { List<T> candidates = loadAll(klass, hardcoded, cl, priorityAccessor); if (candidates.isEmpty()) { return null; } return candidates.get(0); } private  ServiceProviders(); static T load(
      Class<T> klass,
      Iterable<Class<?>> hardcoded,
      ClassLoader cl,
      PriorityAccessor<T> priorityAccessor); static List<T> loadAll(
      Class<T> klass,
      Iterable<Class<?>> hardcoded,
      ClassLoader cl,
      final PriorityAccessor<T> priorityAccessor); @VisibleForTesting static Iterable<T> getCandidatesViaServiceLoader(Class<T> klass, ClassLoader cl);  }