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

Gatherers.mapConcurrent could support async interrupts

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P4 P4
    • None
    • 24, 25
    • core-libs
    • None

      Currently Gatherers.mapConcurrent does not throw an InterruptedException if the thread evaluating the stream gets interrupted. This is due to Streams not supporting checked exceptions.

      It seems possible to examine how parallel Streams behave under similar circumstances and adopt a similar approach to dealing with the situation.

      It will be important to make sure that all spawned Virtual Threads executing tasks are also interrupted and that mapConcurrent still wait for all of them to join before the exception is propagated.

      This strategy should enable supporting async interruption of Streams using Gatherer.mapConcurrent either in sequential or parallel modes.

            vklang Viktor Klang
            vklang Viktor Klang
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: