Hello!
if I run the following test, it is green but Mutiny logs [-- Mutiny had to drop the following exception --] which is thrown by Uni<String> a
Is there a way to properly cancel other Unis if the first one was already received, so that no dropped exceptions are reported? It seems that it happens only if the unis run on an executor.
Thanks!
The test:
import io.smallrye.mutiny.Uni;
import io.smallrye.mutiny.infrastructure.Infrastructure;
import org.junit.jupiter.api.Test;
import java.util.concurrent.TimeUnit;
import static org.assertj.core.api.Assertions.assertThat;
class UniFirstTest {
@Test
void uni() throws Exception {
var bean = new Bean();
Uni<String> a = Uni.createFrom().item(() -> bean.getValue("f")).runSubscriptionOn(Infrastructure.getDefaultWorkerPool());
Uni<String> b = Uni.createFrom().item(() -> bean.getValue("test")).runSubscriptionOn(Infrastructure.getDefaultWorkerPool());
var subscribe = Uni.join().first(a, b).withItem().subscribe();
assertThat(subscribe.asCompletionStage().get(10, TimeUnit.SECONDS)).isEqualTo("testtest");
}
private static class Bean {
public String getValue(String test) {
if (test == null || test.length() < 3) {
try {
Thread.sleep(10);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
throw new IllegalArgumentException("too short");
}
return test + test;
}
}
}
Hello!
if I run the following test, it is green but Mutiny logs
[-- Mutiny had to drop the following exception --]which is thrown byUni<String> aIs there a way to properly cancel other Unis if the first one was already received, so that no dropped exceptions are reported? It seems that it happens only if the unis run on an executor.
Thanks!
The test: