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

toInt(Long)SummaryStatistics toString() throws IllegalFormatConversionException

    XMLWordPrintable

Details

    Description

      IllegalFormatConversionException with following message:

       "d != java.lang.Double"

       is thrown when you try to call toString() applied to empty(or not) result container for following collectors:

      Please see example below:

      import java.util.function.ToIntFunction;
      import java.util.stream.Collectors;

      public class Main {
          private static final ToIntFunction<Object> toIntFunction = (Object obj) -> 1;

          public static void main(String[] args) {
              Collectors.toIntSummaryStatistics(toIntFunction).resultSupplier().get().toString();
          }
      }

      The same happens in the case of Collectors.toLongSummaryStatistics

      The following testcases will fail due to this issue:
      api/java_util/stream/Collectors/ToIntSummaryStatistics.html\#ToIntSummaryStatistics[accumulator_Test, combinerTest1_Args]
      api/java_util/stream/Collectors/ToLongSummaryStatistics.html\#ToLongSummaryStatistics[accumulator_Test, combinerTest1_Args]

      Attachments

        Issue Links

          Activity

            People

              mduigou Mike Duigou
              ostrizhe Olga Strizhenko (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: