Source:
public void start() { enabled = configuration.persistence().usingStores(); if (!enabled) return; preloaded = false; segmentCount = configuration.clustering().hash().numSegments(); long stamp = lock.writeLock(); try { Completable storeStartup = Flowable.fromIterable(configuration.persistence().stores()) .concatMapSingle(storeConfiguration -> { NonBlockingStore<?, ?> actualStore = storeFromConfiguration(storeConfiguration); NonBlockingStore<?, ?> nonBlockingStore; if (storeConfiguration.async().enabled()) { nonBlockingStore = new AsyncNonBlockingStore<>(actualStore); } else { nonBlockingStore = actualStore; } StoreConfiguration processedConfiguration = cacheStoreFactoryRegistry.processStoreConfiguration(storeConfiguration); InitializationContextImpl ctx = new InitializationContextImpl(processedConfiguration, cache.wired(), keyPartitioner, persistenceMarshaller, timeService, byteBufferFactory, marshallableEntryFactory, nonBlockingExecutor, globalConfiguration, blockingManager); CompletionStage<Void> stage = nonBlockingStore.start(ctx); return Completable.fromCompletionStage(stage) .toSingle(() -> new StoreStatus(nonBlockingStore, processedConfiguration, updateCharacteristics(nonBlockingStore, nonBlockingStore.characteristics(), storeConfiguration))); }) .doOnNext(status -> stores.put(status.store, status)) .delay(status -> { if (status.config.purgeOnStartup()) { return Flowable.fromCompletable(Completable.fromCompletionStage(status.store.clear())); } return Flowable.empty(); }) .ignoreElements(); long interval = configuration.persistence().availabilityInterval(); if (interval > 0) { storeStartup = storeStartup.doOnComplete(() -> availabilityTask = nonBlockingManager.scheduleWithFixedDelay(this::pollStoreAvailability, interval, interval, MILLISECONDS)); } storeStartup.doOnComplete(() -> lock.unlockWrite(stamp)) .blockingAwait(); } catch (Throwable t) { lock.unlockWrite(stamp); throw t; } }

Target:
public void start() { enabled = configuration.persistence().usingStores(); if (!enabled) return; preloaded = false; segmentCount = configuration.clustering().hash().numSegments(); long stamp = lock.writeLock(); try { Completable storeStartup = Flowable.fromIterable(configuration.persistence().stores()) .concatMapSingle(storeConfiguration -> { NonBlockingStore<?, ?> actualStore = storeFromConfiguration(storeConfiguration); NonBlockingStore<?, ?> nonBlockingStore; if (storeConfiguration.async().enabled()) { nonBlockingStore = new AsyncNonBlockingStore<>(actualStore); } else { nonBlockingStore = actualStore; } StoreConfiguration processedConfiguration = cacheStoreFactoryRegistry.processStoreConfiguration(storeConfiguration); InitializationContextImpl ctx = new InitializationContextImpl(processedConfiguration, cache.wired(), keyPartitioner, persistenceMarshaller, timeService, byteBufferFactory, marshallableEntryFactory, nonBlockingExecutor, globalConfiguration, blockingManager); CompletionStage<Void> stage = nonBlockingStore.start(ctx).whenComplete((ignore, t) -> { if (t != null) { stores.add(new StoreStatus(nonBlockingStore, null, null)); } }); return Completable.fromCompletionStage(stage) .toSingle(() -> new StoreStatus(nonBlockingStore, processedConfiguration, updateCharacteristics(nonBlockingStore, nonBlockingStore.characteristics(), storeConfiguration))); }) .doOnNext(stores::add) .delay(status -> { if (status.config.purgeOnStartup()) { return Flowable.fromCompletable(Completable.fromCompletionStage(status.store.clear())); } return Flowable.empty(); }) .ignoreElements(); long interval = configuration.persistence().availabilityInterval(); if (interval > 0) { storeStartup = storeStartup.doOnComplete(() -> availabilityTask = nonBlockingManager.scheduleWithFixedDelay(this::pollStoreAvailability, interval, interval, MILLISECONDS)); } storeStartup.doOnComplete(() -> lock.unlockWrite(stamp)) .blockingAwait(); } catch (Throwable t) { lock.unlockWrite(stamp); log.debug("PersistenceManagerImpl encountered an exception during startup of stores", t); throw t; } }