Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8079264

Non-terminating Stream.flatMap() with short-circuiting downstream operation

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Duplicate
    • Affects Version/s: 8u45
    • Fix Version/s: None
    • Component/s: core-libs
    • Labels:

      Description

      FULL PRODUCT VERSION :
      java version "1.8.0_25"
      Java(TM) SE Runtime Environment (build 1.8.0_25-b18)
      Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)


      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 6.1.7601]

      A DESCRIPTION OF THE PROBLEM :
      While the following works as expected, printing out the infinite sequence of integers

      Stream.of("").flatMap(x -> Stream.iterate(1, i -> i + 1)).forEach(System.out::println);

      the following code prints out only the "1", but still does not terminate:

      Stream.of("").flatMap(x -> Stream.iterate(1, i -> i + 1)).limit(1).forEach(System.out::println);

      This may have the same cause as Bug JDK-8075939 (flatMap does not do a cancellation check on the stream), but to my eyes the effect is even stranger.


      REPRODUCIBILITY :
      This bug can be reproduced always.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              psandoz Paul Sandoz
              Reporter:
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: