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

EmitterProcessor queue not cleared on immediate cancellation #3359

Open
chringwer opened this issue Feb 20, 2023 · 0 comments
Open

EmitterProcessor queue not cleared on immediate cancellation #3359

chringwer opened this issue Feb 20, 2023 · 0 comments
Assignees
Labels
area/doOnDiscard This belongs to the doOnDiscard theme type/bug A general bug
Milestone

Comments

@chringwer
Copy link

EmitterProcessor#remove has support to discard the buffer once the last subscriber is gone. However, it returns early if the subscribers array is already EMPTY. For cases where the subscription is immediately cancelled (e.g. .take(0)) this may leak the buffered elements.

Here is a repro case:

@Test
void shouldClearBufferOnCancellation() {
  BlockingQueue<Integer> queue = new LinkedBlockingQueue<>();

  Many<Integer> sink = Sinks.many().unicast().onBackpressureBuffer(queue);

  sink.tryEmitNext(1);
  sink.tryEmitNext(2);
  sink.tryEmitNext(3);

  assertThat(queue).hasSize(3);

  sink.asFlux().take(0).blockLast();

  assertThat(queue).isEmpty();
}

As a workaround .takeWhile(x -> false) does make the test pass for example.

@reactorbot reactorbot added the ❓need-triage This issue needs triage, hasn't been looked at by a team member yet label Feb 20, 2023
@OlegDokuka OlegDokuka added type/bug A general bug area/doOnDiscard This belongs to the doOnDiscard theme and removed ❓need-triage This issue needs triage, hasn't been looked at by a team member yet labels Feb 20, 2023
@OlegDokuka OlegDokuka added this to the 3.4.28 milestone Feb 20, 2023
@violetagg violetagg modified the milestones: 3.4.28, 3.4.29 Mar 14, 2023
@OlegDokuka OlegDokuka modified the milestones: 3.4.29, 3.5.7, 3.5.8 Jun 7, 2023
@violetagg violetagg removed this from the 3.5.8 milestone Dec 12, 2023
@chemicL chemicL added this to the 3.6.x Backlog milestone Aug 2, 2024
@chemicL chemicL self-assigned this Aug 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/doOnDiscard This belongs to the doOnDiscard theme type/bug A general bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants