Skip to content

Commit

Permalink
Merge pull request #1521 from smallrye/fix/1520
Browse files Browse the repository at this point in the history
Fix cancellation issues in Uni to Multi bridge
  • Loading branch information
jponge authored Feb 21, 2024
2 parents bc3ba4f + 607320e commit aeb71fa
Show file tree
Hide file tree
Showing 17 changed files with 38 additions and 22 deletions.
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

0 comments on commit aeb71fa

Please sign in to comment.