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

Java DSL: completeWithFuture is missing unwrapCompletionException #2054

Closed
jypma opened this Issue Jun 6, 2018 · 3 comments

Comments

Projects
None yet
5 participants
@jypma
Copy link
Member

jypma commented Jun 6, 2018

In modern Java, a CompletionStage's failure will always be a CompletionException. That doesn't go very well with writing route ExceptionHandlers, since one would always be matching CompletionException.

In order to work around this, FutureDirectives has a unwrapCompletionException that auto-unwraps failed futures, so exception handlers can deal with the actual exception. However, this unwrapping is missing from completeWithFuture (multiple variants, in javadsl/RouteDirectives.scala ).

Now, any exception thrown by a CompletionStage passed to completeWithFuture will always be CompletionException, and not be handled correctly by any applied exception handler.

A quick fix would be to add unwrapCompletionException to RouteDirectives where appropriate.

@raboof

This comment has been minimized.

Copy link
Member

raboof commented Jun 26, 2018

Sounds good, I remember this being quite cumbersome.

@raboof raboof added the 1 - triaged label Jun 26, 2018

@jlprat

This comment has been minimized.

Copy link
Member

jlprat commented Sep 5, 2018

I will attempt to tackle this one :)

@jlprat jlprat self-assigned this Sep 5, 2018

jlprat added a commit to jlprat/akka-http that referenced this issue Sep 6, 2018

Fail with unwrapped exception when using CompletionStage akka#2054
Refs: akka#2054
Unwraps the original exception that caused the `CompletionStage` to fail.
This original exception can then be used on the custom `ExceptionHandler`.

johanandren added a commit that referenced this issue Sep 7, 2018

@johanandren johanandren added this to the 10.1.6 milestone Sep 7, 2018

@jlprat

This comment has been minimized.

Copy link
Member

jlprat commented Sep 7, 2018

Closed by 8bd0bec

@jlprat jlprat closed this Sep 7, 2018

Synesso added a commit to Synesso/akka-http that referenced this issue Sep 17, 2018

Fail with unwrapped exception when using CompletionStage akka#2054
Refs: akka#2054
Unwraps the original exception that caused the `CompletionStage` to fail.
This original exception can then be used on the custom `ExceptionHandler`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment