RFR: 8347274: Gatherers.mapConcurrent exhibits undesired behavior under variable delays, interruption, and finishing

Viktor Klang vklang at openjdk.org
Thu Jan 9 10:18:50 UTC 2025


The following patch updates Gatherers.mapConcurrent to limit work-in-progress (on-going and completed-unpushed) to the `maxConcurrency` so that head-of-line blocking does not cause completed-unpushed work to grow unbounded.

This also simplifies interruption handling to ignore-and-restore, which needs to be done on a per-element-basis as the calling thread can change between invocations of the integrator, as well as the finisher, so restoring it on finish is not possible (and won't happen if there's an exception thrown during integration anyway).

Furthermore, logic has been added to reduce the risk of any spawned virtual threads surviving the processing of the stream.

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

Commit messages:
 - 8347274 - Hardens the implementation of Gatherers.mapConcurrent

Changes: https://git.openjdk.org/jdk/pull/22999/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=22999&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8347274
  Stats: 144 lines in 2 files changed: 91 ins; 16 del; 37 mod
  Patch: https://git.openjdk.org/jdk/pull/22999.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/22999/head:pull/22999

PR: https://git.openjdk.org/jdk/pull/22999


More information about the core-libs-dev mailing list