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: Context.send() in CompletionStage raises Exception #3486

Open
hidemikimura opened this issue Jul 26, 2024 · 1 comment
Open

Comments

@hidemikimura
Copy link

It seems that something is being sent after the response is sent with Context.send() in CompletionStage.
Can the process here in io.jooby.internal.handler.apply() be changed?

      } else if (result instanceof CompletionStage future) {
        future.whenComplete(
            (value, x) -> {
              // Add the following if statement
              if (ctx.isResponseStarted()) {
                return;
              }
              try {
                Route.After after = ctx.getRoute().getAfter();
                if (after != null) {
                  // run after:
                  after.apply(ctx, value, unwrap((Throwable) x));
                }
                if (x != null) {
                  Throwable exception = unwrap((Throwable) x);
                  ctx.sendError(exception);
                } else {
                  ctx.render(value);
                }
              } catch (Throwable cause) {
                ctx.sendError(cause);
              }
            });
        // Return context to mark as handled
        return ctx;
      }
@jknack
Copy link
Member

jknack commented Jul 27, 2024

Hi, don't follow. what would you like to change?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants