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

CompletionStage exceptions leak into Mutiny API #179

Closed
FroMage opened this issue Jun 23, 2020 · 4 comments · Fixed by #181
Closed

CompletionStage exceptions leak into Mutiny API #179

FroMage opened this issue Jun 23, 2020 · 4 comments · Fixed by #181
Labels
bug Something isn't working
Milestone

Comments

@FroMage
Copy link
Contributor

FroMage commented Jun 23, 2020

I just got a CompletionException via the Mutiny API, which wraps any exception thrown inside a CompletionStage pipeline. I believe this is very annoying because it means I must wrap all my Uni into an exception mapper that unwraps these silly exception wrappers into their original causes.

Can we make sure the Mutiny API unwrap those when we create a Uni from a CompletionStage?

@cescoffier
Copy link
Contributor

So basically:

Uni.createFrom().completionStage(() -> {

    // ...
	CompletionStage<X> stage = ...

}) 
// automatically added
.onFailure(CompletionException.class).apply(ce -> ce.getCause());

@cescoffier
Copy link
Contributor

Actually, another approach (much better):
In: io.smallrye.mutiny.operators.UniCreateFromCompletionStage#forwardFromCompletionStage

private static <O> void forwardFromCompletionStage(CompletionStage<? extends O> stage,
            UniSerializedSubscriber<? super O> subscriber) {
        subscriber.onSubscribe(() -> stage.toCompletableFuture().cancel(false));
        stage.whenComplete((res, fail) -> {
            if (fail != null) {
                if (fail instanceof CompletionException) {
                    subscriber.onFailure(fail.getCause());
                } else {
                    subscriber.onFailure(fail);
                }
            } else {
                subscriber.onItem(res);
            }
        });
    }

@FroMage
Copy link
Contributor Author

FroMage commented Jun 23, 2020

Yes that's what I had in mind.

@cescoffier cescoffier added this to the 0.6.0 milestone Jun 24, 2020
@cescoffier cescoffier added the bug Something isn't working label Jun 24, 2020
@FroMage
Copy link
Contributor Author

FroMage commented Jun 24, 2020

Thanks

@cescoffier cescoffier modified the milestones: 0.6.0, 0.5.4 Jun 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants