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

Fix cancellation issues in Uni to Multi bridge #1521

Merged
merged 3 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>io.smallrye.reactive</groupId>
<artifactId>mutiny-bom</artifactId>
<version>2.5.6</version>
<version>2.5.7-SNAPSHOT</version>

<packaging>pom</packaging>

Expand Down
2 changes: 1 addition & 1 deletion context-propagation/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>io.smallrye.reactive</groupId>
<artifactId>mutiny-project</artifactId>
<version>2.5.6</version>
<version>2.5.7-SNAPSHOT</version>
</parent>

<artifactId>mutiny-smallrye-context-propagation</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion documentation/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>io.smallrye.reactive</groupId>
<artifactId>mutiny-project</artifactId>
<version>2.5.6</version>
<version>2.5.7-SNAPSHOT</version>
</parent>

<artifactId>mutiny-documentation</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion implementation/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.smallrye.reactive</groupId>
<artifactId>mutiny-project</artifactId>
<version>2.5.6</version>
<version>2.5.7-SNAPSHOT</version>
</parent>

<artifactId>mutiny</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,21 @@ public Context context() {

@Override
public void cancel() {
if (upstream != null) {
upstream.cancel();
if (STATE_UPDATER.getAndSet(this, State.DONE) != State.DONE) {
if (upstream != null) {
upstream.cancel();
}
}
}

@Override
public void request(long n) {
if (n <= 0L) {
downstream.onError(new IllegalArgumentException("Invalid request"));
return;
}
if (STATE_UPDATER.compareAndSet(this, State.INIT, State.UNI_REQUESTED)) {
AbstractUni.subscribe(uni, this);
if (n <= 0L) {
onFailure(new IllegalArgumentException("Invalid request"));
} else {
AbstractUni.subscribe(uni, this);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import static org.awaitility.Awaitility.await;
import static org.hamcrest.Matchers.greaterThanOrEqualTo;

import java.time.Duration;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutorService;
Expand Down Expand Up @@ -94,4 +95,17 @@ void reproducer_quarkus_21528() {

Uni.join().first(asList).withItem();
}

@Test
void reproducer_1520() {
// From https://github.com/smallrye/smallrye-mutiny/issues/1520 and
// to address https://github.com/quarkusio/quarkus/issues/34613
AtomicInteger counter = new AtomicInteger();
Multi.createFrom().iterable(List.of("aa", "bb", "cc"))
.collect().asList()
.onTermination().invoke(counter::incrementAndGet)
.onFailure().retry().withBackOff(Duration.ofSeconds(1)).atMost(2)
.await().atMost(Duration.ofSeconds(5));
assertThat(counter).hasValue(1);
}
}
2 changes: 1 addition & 1 deletion kotlin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.smallrye.reactive</groupId>
<artifactId>mutiny-project</artifactId>
<version>2.5.6</version>
<version>2.5.7-SNAPSHOT</version>
</parent>

<artifactId>mutiny-kotlin</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion math/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>io.smallrye.reactive</groupId>
<artifactId>mutiny-project</artifactId>
<version>2.5.6</version>
<version>2.5.7-SNAPSHOT</version>
</parent>

<name>SmallRye Mutiny - Math operators</name>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<groupId>io.smallrye.reactive</groupId>
<artifactId>mutiny-project</artifactId>
<version>2.5.6</version>
<version>2.5.7-SNAPSHOT</version>
<packaging>pom</packaging>

<name>SmallRye Mutiny - Parent</name>
Expand Down
2 changes: 1 addition & 1 deletion reactive-streams-operators-jakarta/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.smallrye.reactive</groupId>
<artifactId>mutiny-project</artifactId>
<version>2.5.6</version>
<version>2.5.7-SNAPSHOT</version>
</parent>

<artifactId>mutiny-reactive-streams-operators-jakarta</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion reactive-streams-operators/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.smallrye.reactive</groupId>
<artifactId>mutiny-project</artifactId>
<version>2.5.6</version>
<version>2.5.7-SNAPSHOT</version>
</parent>

<artifactId>mutiny-reactive-streams-operators</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion reactive-streams-tck-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>io.smallrye.reactive</groupId>
<artifactId>mutiny-project</artifactId>
<version>2.5.6</version>
<version>2.5.7-SNAPSHOT</version>
</parent>

<artifactId>reactive-streams-tck-tests</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion reactor/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>io.smallrye.reactive</groupId>
<artifactId>mutiny-project</artifactId>
<version>2.5.6</version>
<version>2.5.7-SNAPSHOT</version>
</parent>

<artifactId>mutiny-reactor</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion release/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>io.smallrye.reactive</groupId>
<artifactId>mutiny-project</artifactId>
<version>2.5.6</version>
<version>2.5.7-SNAPSHOT</version>
</parent>

<artifactId>smallrye-mutiny-release</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion rxjava3/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>io.smallrye.reactive</groupId>
<artifactId>mutiny-project</artifactId>
<version>2.5.6</version>
<version>2.5.7-SNAPSHOT</version>
</parent>

<artifactId>mutiny-rxjava3</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion test-utils/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>io.smallrye.reactive</groupId>
<artifactId>mutiny-project</artifactId>
<version>2.5.6</version>
<version>2.5.7-SNAPSHOT</version>
</parent>

<artifactId>mutiny-test-utils</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion workshop-examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>io.smallrye.reactive</groupId>
<artifactId>mutiny-project</artifactId>
<version>2.5.6</version>
<version>2.5.7-SNAPSHOT</version>
</parent>

<name>SmallRye Mutiny - Workshop examples</name>
Expand Down
Loading