title: When is a Java 8 Stream considered to be consumed?
body: <p>My understanding was that a Java 8 <code>Stream</code> is considered to be consumed once a terminal operation, such as <code>forEach()</code> or <code>count()</code>, is performed. </p>
  
  <p>However, the test case <code>multipleFilters_separate</code> below throws an <code>IllegalStateException</code> even though <code>filter</code> is a lazy intermediate operation, just called as two statements. And yet, I can chain the two filter operations into a single statement and it works.</p>
  
  <pre><code>@Test(expected=IllegalStateException.class)
  public void multipleFilters_separate() {
      Stream&lt;Double&gt; ints = Stream.of(1.1, 2.2, 3.3);
      ints.filter(d -&gt; d &gt; 1.3);
      ints.filter(d -&gt; d &gt; 2.3).forEach(System.out::println);
  }
  
  @Test
  public void multipleFilters_piped() {
      Stream&lt;Double&gt; ints = Stream.of(1.1, 2.2, 3.3);
      ints.filter(d -&gt; d &gt; 1.3)
          .filter(d -&gt; d &gt; 2.3)
          .forEach(System.out::println);
  }
  </code></pre>
  
  <p>From this, I'm assuming a <code>Stream</code> is considered to be consumed after the first statement that uses it whether that statement calls a terminal operation or not. Does that sound right?</p>