Source:
<code>public synchronized void addExchangeLocations(PlanFragmentId fragmentId, Set<RemoteTask> sourceTasks, boolean noMoreExchangeLocations) { requireNonNull(fragmentId, "fragmentId is null"); requireNonNull(sourceTasks, "sourceTasks is null"); RemoteSourceNode remoteSource = exchangeSources.get(fragmentId); checkArgument(remoteSource != null, "Unknown remote source %s. Known sources are %s", fragmentId, exchangeSources.keySet()); this.sourceTasks.putAll(remoteSource.getId(), sourceTasks); ImmutableSet.Builder<URI> locationsToDestroy = ImmutableSet.builder(); for (RemoteTask task : getAllTasks()) { if (task.getTaskStatus().getState().isDone()) { sourceTasks.stream() <START> .map(sourceTask -> exchangeSourceLocation(task.getTaskId(), sourceTask.getTaskStatus().getSelf())).forEach(locationsToDestroy::add); <END> } else { ImmutableMultimap.Builder<PlanNodeId, Split> newSplits = ImmutableMultimap.builder(); for (RemoteTask sourceTask : sourceTasks) { URI exchangeLocation = sourceTask.getTaskStatus().getSelf(); newSplits.put(remoteSource.getId(), createRemoteSplitFor(task.getTaskId(), exchangeLocation)); } task.addSplits(newSplits.build()); } } if (noMoreExchangeLocations) { completeSourceFragments.add(fragmentId); if (completeSourceFragments.containsAll(remoteSource.getSourceFragmentIds())) { completeSources.add(remoteSource.getId()); for (RemoteTask task : getAllTasks()) { task.noMoreSplits(remoteSource.getId()); } } } remoteTaskFactory.destroyExchangeSources(locationsToDestroy.build()); }</code><technical_language>Formatting (add new line) sourceTasks.stream() .map(sourceTask -> exchangeSourceLocation(task.getTaskId(), sourceTask.getTaskStatus().getSelf())) .forEach(locationsToDestroy::add); I personally prefer this written a for-loop. I feel strongly</technical_language>

Target:
public synchronized void addExchangeLocations(PlanFragmentId fragmentId, Set<RemoteTask> sourceTasks, boolean noMoreExchangeLocations) { requireNonNull(fragmentId, "fragmentId is null"); requireNonNull(sourceTasks, "sourceTasks is null"); RemoteSourceNode remoteSource = exchangeSources.get(fragmentId); checkArgument(remoteSource != null, "Unknown remote source %s. Known sources are %s", fragmentId, exchangeSources.keySet()); this.sourceTasks.putAll(remoteSource.getId(), sourceTasks); ImmutableList.Builder<ExchangeBufferLocation> buffersToDestroy = ImmutableList.builder(); for (RemoteTask task : getAllTasks()) { if (task.getTaskStatus().getState().isDone()) { for (RemoteTask sourceTask : sourceTasks) { URI location = exchangeSourceLocation(task.getTaskId(), sourceTask.getTaskStatus().getSelf()); buffersToDestroy.add(new ExchangeBufferLocation(sourceTask.getTaskId(), location)); } } else { ImmutableMultimap.Builder<PlanNodeId, Split> newSplits = ImmutableMultimap.builder(); for (RemoteTask sourceTask : sourceTasks) { URI exchangeLocation = sourceTask.getTaskStatus().getSelf(); newSplits.put(remoteSource.getId(), createRemoteSplitFor(task.getTaskId(), exchangeLocation)); } task.addSplits(newSplits.build()); } } if (noMoreExchangeLocations) { completeSourceFragments.add(fragmentId); if (completeSourceFragments.containsAll(remoteSource.getSourceFragmentIds())) { completeSources.add(remoteSource.getId()); for (RemoteTask task : getAllTasks()) { task.noMoreSplits(remoteSource.getId()); } } } remoteTaskFactory.destroyExchangeSources(buffersToDestroy.build(), stateMachine::transitionToFailed); }