Source:
<code>public <R> void streamOperationRehashAware(Object requestId, Address origin, boolean parallelStream, IntSet segments, Set<K> keysToInclude, Set<K> keysToExclude, boolean includeLoader, boolean entryStream, TerminalOperation<Original, R> operation) { if (trace) { log.tracef("Received rehash aware operation request for id %s from %s for segments %s", requestId, origin, segments); } CacheSet<Original> originalSet = toOriginalSet(includeLoader, entryStream); R value; operation.handleInjection(registry); SegmentListener listener; if (requiresListener) { listener = new SegmentListener(segments, operation); changeListener.put(requestId, listener); if (trace) { log.tracef("Registered change listener for %s", requestId); } } else { listener = null; } IntSet lostSegments; try { operation.setSupplier(() -> getRehashStream(originalSet, requestId, listener, parallelStream, entryStream, segments, keysToInclude, keysToExclude)); value = operation.performOperation(); if (listener != null) { lostSegments = listener.segmentsLost; } else { lostSegments = IntSets.immutableEmptySet(); } if (trace) { log.tracef("Request %s completed for segments %s with %s suspected segments", requestId, segments, lostSegments); } } finally { if (listener != null) { changeListener.remove(requestId); if (trace) { log.tracef("UnRegistered change listener for %s", requestId); } } } if (cache.getStatus() != ComponentStatus.RUNNING && cache.getStatus() != ComponentStatus.INITIALIZING) { if (trace) { log.tracef("Cache status is no longer running, all segments are now suspect for %s", requestId); } <START> lostSegments = segments; <END> value = null; } StreamResponseCommand<R> command = factory.buildStreamResponseCommand(requestId, true, lostSegments, value); CompletionStage<ValidResponse> completableFuture = this.rpc.invokeCommand(origin, command, SingleResponseCollector.validOnly(), rpc.getSyncRpcOptions()); handleResponseError(completableFuture, requestId, origin); }</code><technical_language>IMO send a StreamResponseCommand if cache is shutting down</technical_language>

Target:
public <R> void streamOperationRehashAware(Object requestId, Address origin, boolean parallelStream, IntSet segments, Set<K> keysToInclude, Set<K> keysToExclude, boolean includeLoader, boolean entryStream, TerminalOperation<Original, R> operation) { if (trace) { log.tracef("Received rehash aware operation request for id %s from %s for segments %s", requestId, origin, segments); } CacheSet<Original> originalSet = toOriginalSet(includeLoader, entryStream); R value; operation.handleInjection(registry); SegmentListener listener; if (isReplicated) { listener = null; } else { listener = new SegmentListener(segments, operation); changeListener.put(requestId, listener); if (trace) { log.tracef("Registered change listener for %s", requestId); } } IntSet lostSegments; try { operation.setSupplier(() -> getRehashStream(originalSet, requestId, listener, parallelStream, entryStream, segments, keysToInclude, keysToExclude)); value = operation.performOperation(); if (listener != null) { lostSegments = listener.segmentsLost; } else { lostSegments = IntSets.immutableEmptySet(); } if (trace) { log.tracef("Request %s completed for segments %s with %s suspected segments", requestId, segments, lostSegments); } } finally { if (listener != null) { changeListener.remove(requestId); if (trace) { log.tracef("UnRegistered change listener for %s", requestId); } } } sendRehashAwareResponse(requestId, origin, lostSegments, segments, value); }