Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

autoConnect(0) seems to be broken - late subscribers receive data #3805

Open
kitkars opened this issue May 2, 2024 · 0 comments
Open

autoConnect(0) seems to be broken - late subscribers receive data #3805

kitkars opened this issue May 2, 2024 · 0 comments
Labels
❓need-triage This issue needs triage, hasn't been looked at by a team member yet

Comments

@kitkars
Copy link

kitkars commented May 2, 2024

autoConnect(0) seems to be broken completely.

Steps to replicate:

        CountDownLatch latch = new CountDownLatch(1);
        AtomicInteger atomicInteger = new AtomicInteger(0);
        Flux<Integer> flux = Flux.generate(sink -> sink.next(atomicInteger.incrementAndGet()))
                                 .delayElements(Duration.ofSeconds(1))
                                 .take(7)
                                 .cast(Integer.class)
                                 .doOnComplete(() -> System.out.println("completed"))
                                 .publish()
                                 .autoConnect(0);

        // no subscribers for 3 seconds
        Thread.sleep(3000);

        // first subscriber: this should print 3,4,5 
        flux.take(3).subscribe(System.out::println);

        // no subscribers for 6 seconds. by this time source would have completed
        Thread.sleep(6000);

        // second subscriber: this should NOT print any data! but it prints 6 and 7
        flux.take(3).subscribe(System.out::println);

        latch.await();

Expected Behavior:

First subscribers get fresh messages emitted by the source. This behavior should be same for late subscribers as well. That is - if the source is already completed, late subscribers should not receive any data.

Actual Behavior.
the late subscribers get all the messages dropped by the first subscriber. This behavior does not make any sense.

Tested with latest version as well - https://mvnrepository.com/artifact/io.projectreactor/reactor-bom/2023.0.5

@chemicL chemicL added the ❓need-triage This issue needs triage, hasn't been looked at by a team member yet label Aug 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
❓need-triage This issue needs triage, hasn't been looked at by a team member yet
Projects
None yet
Development

No branches or pull requests

2 participants