/** * Copies the consumers of the given {@code channel} into this instance. */ private void copyConsumersFrom(Channel channel) { assert channel.getOriginal() == this; for (ExecutionTask consumer : new ArrayList<>(channel.getConsumers())) { // We must take care not to copy back channels, that we already have in the original. assert this.consumers.stream() .noneMatch(existingConsumer -> existingConsumer.getOperator().equals(consumer.getOperator())) : String.format("Conflict when copying consumers from %s (%s) to %s (%s).", this, this.consumers, channel, channel.getConsumers() ); consumer.exchangeInputChannel(channel, this); } }