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

DoubleStream.count is incorrect for a stream containing > Integer.MAX_VALUE elements

    XMLWordPrintable

Details

    Backports

      Description

        The code for the DoubleStream.count method is incorrect:

            public final long count() {
                return mapToObj(e -> null).mapToInt(e -> 1).sum();
            }

        If a a double stream contains more than Integer.MAX_VALUE then the sum will overflow resulting in an incorrect value. The code should be:

            public final long count() {
                return mapToLong(e -> 1).sum();
            }

        Attachments

          Issue Links

            Activity

              People

                psandoz Paul Sandoz
                psandoz Paul Sandoz
                Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: