### Question:
SpiLoader { public static <T> T loadFirstInstance(Class<T> clazz) { AssertUtil.notNull(clazz, "SPI class cannot be null"); try { String key = clazz.getName(); ServiceLoader<T> serviceLoader = SERVICE_LOADER_MAP.get(key); if (serviceLoader == null) { serviceLoader = ServiceLoaderUtil.getServiceLoader(clazz); SERVICE_LOADER_MAP.put(key, serviceLoader); } Iterator<T> iterator = serviceLoader.iterator(); if (iterator.hasNext()) { return iterator.next(); } else { return null; } } catch (Throwable t) { RecordLog.error("[SpiLoader] ERROR: loadFirstInstance failed", t); t.printStackTrace(); return null; } } private  SpiLoader(); static T loadFirstInstance(Class<T> clazz); static T loadFirstInstanceOrDefault(Class<T> clazz, Class<? extends T> defaultClass); static T loadHighestPriorityInstance(Class<T> clazz); static List<T> loadInstanceList(Class<T> clazz); static List<T> loadInstanceListSorted(Class<T> clazz); static List<T> loadPrototypeInstanceListSorted(Class<T> clazz);  }### Answer:
@Test public void testLoadFirstInstance() { ProcessorSlot processorSlot = SpiLoader.loadFirstInstance(ProcessorSlot.class); assertNotNull(processorSlot); ProcessorSlot processorSlot2 = SpiLoader.loadFirstInstance(ProcessorSlot.class); assertSame(processorSlot, processorSlot2); SlotChainBuilder slotChainBuilder = SpiLoader.loadFirstInstance(SlotChainBuilder.class); assertNotNull(slotChainBuilder); assertTrue(slotChainBuilder instanceof DefaultSlotChainBuilder); SlotChainBuilder slotChainBuilder2 = SpiLoader.loadFirstInstance(SlotChainBuilder.class); assertSame(slotChainBuilder, slotChainBuilder2); }