[jdk24] RFR: 8347542: Gatherers.mapConcurrent exhibits undesired behavior under variable delays, interruption, and finishing
Viktor Klang
vklang at openjdk.org
Tue Jan 14 11:02:46 UTC 2025
On Mon, 13 Jan 2025 19:20:41 GMT, He-Pin(kerr) <duke at openjdk.org> wrote:
>> Backport to jdk24 of https://bugs.openjdk.org/browse/JDK-8347274
>
> Does this fix the OOM problem?
>
>
> import java.util.stream.Gatherers;
> import java.util.stream.IntStream;
>
> /**
> * TODO: description of this file
> *
> * @author 虎鸣
> */
> public class Main {
> public static void main(String[] args) {
> final var stream = IntStream.range(0, Integer.MAX_VALUE);
> stream.boxed()
> .gather(Gatherers.mapConcurrent(
> 2,
> i -> {
> if (i == 0) {
> try {
> Thread.sleep(Integer.MAX_VALUE);
> } catch (InterruptedException e) {
> throw new RuntimeException(e);
> }
> }
> return i;
> }))
> .forEach(System.out::println);
> try {
> Thread.sleep(Integer.MAX_VALUE);
> } catch (InterruptedException e) {
> throw new RuntimeException(e);
> }
> }
> }
@He-Pin I believe it will, yes.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/23068#issuecomment-2589614630
More information about the core-libs-dev
mailing list