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

Stream method peek() doesn't execute on JDK9

XMLWordPrintable

    • b56
    • 9
    • generic
    • generic

      FULL PRODUCT VERSION :
      java version "9.0.4"
      Java(TM) SE Runtime Environment (build 9.0.4+11)
      Java HotSpot(TM) 64-Bit Server VM (build 9.0.4+11, mixed mode)


      ADDITIONAL OS VERSION INFORMATION :
      Linux juan-notebook 4.13.0-32-generic #35-Ubuntu SMP Thu Jan 25 09:13:46 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux


      A DESCRIPTION OF THE PROBLEM :
      When I execute the following sentence:
      jshell> Stream.of("A","B","C").peek(System.out::println).count()
      I get the result:
      $9 ==> 3
      But should be:
      A
      B
      C
      3


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Open jshell and execute:
      Stream.of("A","B","C").peek(System.out::println).count()

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      A
      B
      C
      3

      REPRODUCIBILITY :
      This bug can be reproduced always.

      CUSTOMER SUBMITTED WORKAROUND :
      Don't use it with jshell.

      When I execute the following class works ok:
      class Snippet {
          public static void main(String[] args) {
              System.out.println(java.util.stream.Stream.of("lower", "case", "text")
                  .peek(System.out::println)
                  .count());
          }
      }

        1. A.java
          0.2 kB
          Fairoz Matte

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

              Created:
              Updated:
              Resolved: