Source:
<code>private Object handleWriteOnOriginPrimary(InvocationContext ctx, DataWriteCommand command, Object rv, RepeatableReadEntry cacheEntry, Object seenValue, EntryVersion seenVersion, CacheTopology cacheTopology, DistributionInfo info) { if (!command.isSuccessful()) { if (trace) log.tracef("Skipping the replication of the command as it did not succeed on primary owner (%s).", command); return rv; } EntryVersion nextVersion = svm.incrementVersion(info.segmentId()); Metadata metadata = addVersion(cacheEntry.getMetadata(), nextVersion); cacheEntry.setMetadata(metadata); if (command.loadType() != DONT_LOAD) { commitSingleEntryIfNoChange(cacheEntry, ctx, command); } else { commitSingleEntryIfNewer(cacheEntry, ctx, command); } WriteCommand backupCommand; long flags = command.getFlagsBitSet() | FlagBitSets.SKIP_OWNERSHIP_CHECK; if (cacheEntry.isRemoved()) { backupCommand = cf.buildRemoveCommand(command.getKey(), null, flags); ((RemoveCommand) backupCommand).setMetadata(cacheEntry.getMetadata()); } else { backupCommand = cf.buildPutKeyValueCommand(command.getKey(), cacheEntry.getValue(), cacheEntry.getMetadata(), flags); } Address backup = getNextMember(cacheTopology); if (backup != null) { List<Address> recipients = Collections.singletonList(backup); <START> assert recipients.size() == 1; <END> CompletableFuture<?> rpcFuture = rpcManager.invokeRemotelyAsync(recipients, backupCommand, defaultSyncOptions); rpcFuture.thenRun(() -> { if (cacheEntry.isCommitted() && !command.hasAnyFlag(FlagBitSets.PUT_FOR_STATE_TRANSFER)) { scheduleKeyInvalidation(command.getKey(), cacheEntry.getMetadata().version(), cacheEntry.isRemoved()); } }); rpcFuture = completeSingleWriteOnPrimaryOriginator(command, backup, rpcFuture); return asyncValue(rpcFuture.thenApply(ignore -> rv)); } else { return rv; } }</code><technical_language>I guess trust singletonList() size equals 1 time :)</technical_language>

Target:
private Object handleWriteOnOriginPrimary(InvocationContext ctx, DataWriteCommand command, Object rv, RepeatableReadEntry cacheEntry, Object seenValue, EntryVersion seenVersion, CacheTopology cacheTopology, DistributionInfo info) { if (!command.isSuccessful()) { if (trace) log.tracef("Skipping the replication of the command as it did not succeed on primary owner (%s).", command); return rv; } EntryVersion nextVersion = svm.incrementVersion(info.segmentId()); Metadata metadata = addVersion(cacheEntry.getMetadata(), nextVersion); cacheEntry.setMetadata(metadata); if (command.loadType() != DONT_LOAD) { commitSingleEntryIfNoChange(cacheEntry, ctx, command); } else { commitSingleEntryIfNewer(cacheEntry, ctx, command); } WriteCommand backupCommand; long flags = command.getFlagsBitSet() | FlagBitSets.SKIP_OWNERSHIP_CHECK; if (cacheEntry.isRemoved()) { backupCommand = cf.buildRemoveCommand(command.getKey(), null, flags); ((RemoveCommand) backupCommand).setMetadata(cacheEntry.getMetadata()); } else { backupCommand = cf.buildPutKeyValueCommand(command.getKey(), cacheEntry.getValue(), cacheEntry.getMetadata(), flags); } Address backup = getNextMember(cacheTopology); if (backup != null) { List<Address> recipients = Collections.singletonList(backup); CompletableFuture<?> rpcFuture = rpcManager.invokeRemotelyAsync(recipients, backupCommand, defaultSyncOptions); rpcFuture.thenRun(() -> { if (cacheEntry.isCommitted() && !command.hasAnyFlag(FlagBitSets.PUT_FOR_STATE_TRANSFER)) { scheduleKeyInvalidation(command.getKey(), cacheEntry.getMetadata().version(), cacheEntry.isRemoved()); } }); rpcFuture = completeSingleWriteOnPrimaryOriginator(command, backup, rpcFuture); return asyncValue(rpcFuture.thenApply(ignore -> rv)); } else { return rv; } }