RFR: 8349462: Gatherers.mapConcurrent could support async interrupts

Viktor Klang vklang at openjdk.org
Thu Feb 6 10:43:19 UTC 2025


On Thu, 6 Feb 2025 06:14:10 GMT, David Holmes <dholmes at openjdk.org> wrote:

>> This change is likely going to need some extra verbiage in the spec for mapConcurrent, and thus a CSR.
>> This behavior aligns mapConcurrent with how parallel streams work in conjunction with interruptions of the caller thread.
>
> src/java.base/share/classes/java/util/stream/Gatherers.java line 432:
> 
>> 430:                                 } catch (InterruptedException ie) {
>> 431:                                     // We ignore interrupts here because we cannot proceed
>> 432:                                     // until all spawned threads have exited
> 
> Why discard instead of keeping existing deferral? Swallowing interrupt requests generally breaks cancellation.

@dholmes-ora Good question. It is to avoid the situation where re-interruption and/or timing of interrupt leads to difference in behavior. But your question led me to re-examing an assumption so I might have to reconsider the best path forward. In the meantime I'll close the PR.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/23467#discussion_r1944497629


More information about the core-libs-dev mailing list