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

NullPointerException on object of parallelStream().forEach

    Details

      Description

      FULL PRODUCT VERSION :
      java version "1.8.0_131"
      Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
      Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      MacOS Sierra 10.12.4 (16E195)

      A DESCRIPTION OF THE PROBLEM :
      I have a code like:
      srcObjs.parallelStream().forEach((src) -> {...}
      where srcObjs is a list of custom objects.
      We encounter null for 'src' consumer, random occurrences.
      On debugging found that it is in ArrayList.ArrayListSpliterator.forEachRemaining(Consumer<? super E> action) method.
      Line 1373 has: E e = (E) a[i];
      where a is the Object[] pointing to elementData. The size of this array is greater than that of the array, and hence for some indices the values are null.

      REGRESSION. Last worked in version 7u76


      REPRODUCIBILITY :
      This bug can be reproduced occasionally.

      CUSTOMER SUBMITTED WORKAROUND :
      Using java 7 for loop.

        Attachments

          Activity

            People

            • Assignee:
              psonal Pallavi Sonal
              Reporter:
              webbuggrp Webbug Group
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: