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

Iterator never end when dealing with LinkedBlockingQueue/LinkedBlockingDeque

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • P2
    • Resolution: Fixed
    • 8, 8-repo-lambda
    • 8
    • core-libs

    Description

      Below snippet will hang in recent code

                  Collection<Integer> c1 = new LinkedBlockingQueue<>(); //Not hang with ArrayList
                  Random rand = new Random();
                  for(int i = -64; i < 64; i++)
                      c1.add(-64 + rand.nextInt(128));
                  
                  int limit = rand.nextInt(256) - 128;
                  boolean isUP = rand.nextBoolean();
                  Stream<Integer> stream1 = c1.stream();
                  AtomicInteger ai = new AtomicInteger(0);
                  Iterator<Integer> iter = stream1.peek(t -> ai.updateAndGet(t1 -> t1 + t)).iterator();
                  while(iter.hasNext()) //infinite loop here, but stream1.peek(t -> ai.updateAndGet(t1 -> t1 + t)).toArray() works fine
                      System.out.println(iter.next());

      This caused below lambda tests failed
      java/util/stream/Stream/IntegerStreamTest.java
      java/util/stream/Stream/StringBuilderStreamTest.java
      java/util/stream/Stream/EmployeeStreamTest.java

      Test log shows
      java.lang.NullPointerException
      at com.sun.javatest.regtest.TestNGReporter.getMatcher(TestNGReporter.java:97)
      at com.sun.javatest.regtest.TestNGReporter.add(TestNGReporter.java:80)
      at com.sun.javatest.regtest.TestNGAction.endAction(TestNGAction.java:127)
      at com.sun.javatest.regtest.MainAction.run(MainAction.java:252)
      at com.sun.javatest.regtest.RegressionScript.run(RegressionScript.java:146)
      at com.sun.javatest.Script.run(Script.java:228)
      at com.sun.javatest.DefaultTestRunner.runTest(DefaultTestRunner.java:174)
      at com.sun.javatest.DefaultTestRunner.access$100(DefaultTestRunner.java:43)
      at com.sun.javatest.DefaultTestRunner$1.run(DefaultTestRunner.java:66)
      Which is because hanging cause timeout, and no testng report is available

      Attachments

        Activity

          People

            psandoz Paul Sandoz
            tyan Tristan Yan (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: