From f91ff64db7a64eaddce1974fc840219c3b5dc539 Mon Sep 17 00:00:00 2001 From: Joshua Bauer Date: Mon, 14 Sep 2020 12:41:59 -0700 Subject: [PATCH] Fix for looping requests when response wrapped in completable future. --- CHANGELOG.md | 5 +++++ .../java/io/sinistral/proteus/server/ServerResponse.java | 5 +++-- .../sinistral/proteus/server/handlers/HandlerGenerator.java | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ed9911d..07a7ea7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ Proteus Changelog. ## Unreleased ### No issue +**Cleanup shutdown and expose worker in request.** + + +[54979422dab4bff](https://github.com/noboomu/proteus/commit/54979422dab4bff) Joshua Bauer *2020-09-02 18:34:03* + **Set config log level to trace.** diff --git a/proteus-core/src/main/java/io/sinistral/proteus/server/ServerResponse.java b/proteus-core/src/main/java/io/sinistral/proteus/server/ServerResponse.java index ef4c6cf..5076290 100644 --- a/proteus-core/src/main/java/io/sinistral/proteus/server/ServerResponse.java +++ b/proteus-core/src/main/java/io/sinistral/proteus/server/ServerResponse.java @@ -573,8 +573,6 @@ public void send(final HttpHandler handler, final HttpServerExchange exchange) t return; } - - exchange.setStatusCode(this.status); @@ -641,6 +639,9 @@ public void send(final HttpHandler handler, final HttpServerExchange exchange) t exchange.getResponseSender().send(this.body, this.ioCallback); } } else if (hasEntity) { + + + try { if (this.processXml) { exchange.getResponseSender().send(ByteBuffer.wrap(XML_MAPPER.writeValueAsBytes(this.entity))); diff --git a/proteus-core/src/main/java/io/sinistral/proteus/server/handlers/HandlerGenerator.java b/proteus-core/src/main/java/io/sinistral/proteus/server/handlers/HandlerGenerator.java index a228ebd..b4f80f3 100644 --- a/proteus-core/src/main/java/io/sinistral/proteus/server/handlers/HandlerGenerator.java +++ b/proteus-core/src/main/java/io/sinistral/proteus/server/handlers/HandlerGenerator.java @@ -687,7 +687,7 @@ protected void addClassMethodHandlers(TypeSpec.Builder typeBuilder, Class cla methodBuilder.beginControlFlow("", ""); methodBuilder.addCode( - "$L.thenAccept( r -> r.send(this,$L) )\n\t.exceptionally( ex -> ", + "$L.thenAccept( r -> r.send(null,$L) )\n\t.exceptionally( ex -> ", "response", "exchange"); methodBuilder.beginControlFlow("", ""); methodBuilder.addCode("\t\tthrow new java.util.concurrent.CompletionException(ex);\n\t");