Unexpected side effect with java streams reduce operation : <p>I'm observing a side effect on an underlying collection when calling 'reduce' on a Stream. This is so basic. I can't believe what I am seeing, but I can't find the error. Below is the code and the resulting output. Can anyone explain to me why one of the underlying collections of the Stream is mutating?</p>

<pre><code>package top;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.stream.Stream;

public class Main {
    public static void main(String[] args) throws Exception {
        ArrayList&lt;Integer&gt; list1 = new ArrayList&lt;&gt;();
        ArrayList&lt;Integer&gt; list2 = new ArrayList&lt;&gt;();
        ArrayList&lt;Integer&gt; list3 = new ArrayList&lt;&gt;();

        list1.addAll(Arrays.asList(1, 2, 3));
        list2.addAll(Arrays.asList(4, 5, 6));
        list3.addAll(Arrays.asList(7, 8, 9));

        System.out.println("Before");
        System.out.println(list1);
        System.out.println(list2);
        System.out.println(list3);

        ArrayList&lt;Integer&gt; r1 = Stream.of(list1, list2, list3).reduce((l, r) -&gt; {
            l.addAll(r);
            return l;
        }).orElse(new ArrayList&lt;&gt;());

        System.out.println("After");
        System.out.println(list1);
        System.out.println(list2);
        System.out.println(list3);

        System.out.println("Result");
        System.out.println(r1);

    }
}

// Output
Before
[1, 2, 3]
[4, 5, 6]
[7, 8, 9]
After
[1, 2, 3, 4, 5, 6, 7, 8, 9] // Why is this not [1,2,3]?
[4, 5, 6]
[7, 8, 9]
Result
[1, 2, 3, 4, 5, 6, 7, 8, 9]

</code></pre>
