Source:
<code>public static <K, V> CompletionStage<Void> handleEviction(InternalCacheEntry<K, V> entry, DataOperationOrderer orderer, PassivationManager passivator, EvictionManager<K, V> evictionManager, DataContainer<K, V> dataContainer, CompletionStage<Void> selfDelay) { K key = entry.getKey(); CompletableFuture<Operation> future = new CompletableFuture<>(); CompletionStage<Operation> ordererStage = orderer != null ? orderer.orderOn(key, future) : null; if (ordererStage != null) { return ordererStage.thenCompose(operation -> { switch (operation) { case REMOVE: return skipPassivation(orderer, key, future, operation); case WRITE: if (dataContainer.containsKey(key)) { if (selfDelay != null) { if (trace) { log.tracef("Delaying check for %s verify if passivation should occur as there was a" + " concurrent write", key); } return selfDelay.thenCompose(ignore -> { if (dataContainer.containsKey(key)) { return skipPassivation(orderer, key, future, operation); } else { return handleNotificationAndOrderer(key, entry, passivator.passivateAsync(entry), orderer, evictionManager, future); } }); } return skipPassivation(orderer, key, future, operation); } default: CompletionStage<Void> passivatedStage = passivator.passivateAsync(entry); <START> return handleNotificationAndOrderer(key, entry, passivatedStage, orderer, evictionManager, future); <END> } }); } return handleNotificationAndOrderer(key, entry, passivator.passivateAsync(entry), orderer, evictionManager, future); }</code><technical_language>I cheaper do container check if selfDelay == null || selfDelay.isDone(), complicate code more</technical_language>

Target:
public static <K, V> CompletionStage<Void> handleEviction(InternalCacheEntry<K, V> entry, DataOperationOrderer orderer, PassivationManager passivator, EvictionManager<K, V> evictionManager, DataContainer<K, V> dataContainer, CompletionStage<Void> selfDelay) { K key = entry.getKey(); CompletableFuture<Operation> future = new CompletableFuture<>(); CompletionStage<Operation> ordererStage = orderer != null ? orderer.orderOn(key, future) : null; if (ordererStage != null) { if (trace) { log.tracef("Encountered concurrent operation during eviction of %s", key); } return ordererStage.thenCompose(operation -> { if (trace) { log.tracef("Concurrent operation during eviction of %s was %s", key, operation); } switch (operation) { case REMOVE: return skipPassivation(orderer, key, future, operation); case WRITE: if (dataContainer.containsKey(key)) { if (selfDelay != null) { if (trace) { log.tracef("Delaying check for %s verify if passivation should occur as there was a" + " concurrent write", key); } return selfDelay.thenCompose(ignore -> { if (dataContainer.containsKey(key)) { return skipPassivation(orderer, key, future, operation); } else { return handleNotificationAndOrderer(key, entry, passivator.passivateAsync(entry), orderer, evictionManager, future); } }); } return skipPassivation(orderer, key, future, operation); } default: CompletionStage<Void> passivatedStage = passivator.passivateAsync(entry); return handleNotificationAndOrderer(key, entry, passivatedStage, orderer, evictionManager, future); } }); } return handleNotificationAndOrderer(key, entry, passivator.passivateAsync(entry), orderer, evictionManager, future); }