Source:
public CompletionStage<Void> disableStore(String storeType) { if (!enabled) { return CompletableFutures.completedNull(); } boolean stillHasAStore = false; AggregateCompletionStage<Void> aggregateCompletionStage = CompletionStages.aggregateCompletionStage(); long stamp = lock.writeLock(); try { boolean allAvailable = true; Iterator<StoreStatus> statusIterator = stores.values().iterator(); while (statusIterator.hasNext()) { StoreStatus status = statusIterator.next(); NonBlockingStore<?, ?> nonBlockingStore = unwrapStore(status.store()); if (nonBlockingStore.getClass().getName().equals(storeType) || containedInAdapter(nonBlockingStore, storeType)) { statusIterator.remove(); aggregateCompletionStage.dependsOn(nonBlockingStore.stop() .whenComplete((v, t) -> { if (t != null) { log.warn("There was an error stopping the store", t); } })); } else { stillHasAStore = true; allAvailable = allAvailable && status.availability; } } if (!stillHasAStore) { unavailableExceptionMessage = null; enabled = false; stopAvailabilityTask(); } else if (allAvailable) { unavailableExceptionMessage = null; } } finally { lock.unlockWrite(stamp); } if (!stillHasAStore) { AsyncInterceptorChain chain = cache.wired().getAsyncInterceptorChain(); AsyncInterceptor loaderInterceptor = chain.findInterceptorExtending(CacheLoaderInterceptor.class); if (loaderInterceptor == null) { PERSISTENCE.persistenceWithoutCacheLoaderInterceptor(); } else { chain.removeInterceptor(loaderInterceptor.getClass()); } AsyncInterceptor writerInterceptor = chain.findInterceptorExtending(CacheWriterInterceptor.class); if (writerInterceptor == null) { writerInterceptor = chain.findInterceptorWithClass(TransactionalStoreInterceptor.class); if (writerInterceptor == null) { PERSISTENCE.persistenceWithoutCacheWriteInterceptor(); } else { chain.removeInterceptor(writerInterceptor.getClass()); } } else { chain.removeInterceptor(writerInterceptor.getClass()); } } return aggregateCompletionStage.freeze(); }

Target:
public CompletionStage<Void> disableStore(String storeType) { if (!enabled) { return CompletableFutures.completedNull(); } boolean stillHasAStore = false; AggregateCompletionStage<Void> aggregateCompletionStage = CompletionStages.aggregateCompletionStage(); long stamp = lock.writeLock(); try { boolean allAvailable = true; Iterator<StoreStatus> statusIterator = stores.iterator(); while (statusIterator.hasNext()) { StoreStatus status = statusIterator.next(); NonBlockingStore<?, ?> nonBlockingStore = unwrapStore(status.store()); if (nonBlockingStore.getClass().getName().equals(storeType) || containedInAdapter(nonBlockingStore, storeType)) { statusIterator.remove(); aggregateCompletionStage.dependsOn(nonBlockingStore.stop() .whenComplete((v, t) -> { if (t != null) { log.warn("There was an error stopping the store", t); } })); } else { stillHasAStore = true; allAvailable = allAvailable && status.availability; } } if (!stillHasAStore) { unavailableExceptionMessage = null; enabled = false; stopAvailabilityTask(); } else if (allAvailable) { unavailableExceptionMessage = null; } } finally { lock.unlockWrite(stamp); } if (!stillHasAStore) { AsyncInterceptorChain chain = cache.wired().getAsyncInterceptorChain(); AsyncInterceptor loaderInterceptor = chain.findInterceptorExtending(CacheLoaderInterceptor.class); if (loaderInterceptor == null) { PERSISTENCE.persistenceWithoutCacheLoaderInterceptor(); } else { chain.removeInterceptor(loaderInterceptor.getClass()); } AsyncInterceptor writerInterceptor = chain.findInterceptorExtending(CacheWriterInterceptor.class); if (writerInterceptor == null) { writerInterceptor = chain.findInterceptorWithClass(TransactionalStoreInterceptor.class); if (writerInterceptor == null) { PERSISTENCE.persistenceWithoutCacheWriteInterceptor(); } else { chain.removeInterceptor(writerInterceptor.getClass()); } } else { chain.removeInterceptor(writerInterceptor.getClass()); } } return aggregateCompletionStage.freeze(); }