Skip to content

Commit

Permalink
Remove further looping state for server responses.
Browse files Browse the repository at this point in the history
  • Loading branch information
noboomu committed Sep 15, 2020
1 parent 2621026 commit 487d57c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ Proteus Changelog.
## Unreleased
### No issue

**Expose socket timeouts.**


[2621026ce02933c](https://github.com/noboomu/proteus/commit/2621026ce02933c) Joshua Bauer *2020-09-14 20:13:41*

**Fix for looping requests when response wrapped in completable future.**


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,10 @@ public static ServerResponse<ByteBuffer> response(String body)

public static <T> ServerResponse<T> response(T entity)
{
if(entity == null)
{
return new ServerResponse<T>().notFound();
}
return new ServerResponse<T>().entity(entity);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ protected void addClassMethodHandlers(TypeSpec.Builder typeBuilder, Class<?> cla


if (m.getReturnType().equals(ServerResponse.class)) {
methodBuilder.addStatement("$L.send(this,$L)", "response", "exchange");
methodBuilder.addStatement("$L.send($L)", "response", "exchange");

} else if ((m.getGenericReturnType().toString().contains("java.util.concurrent.CompletionStage") && m.getGenericReturnType().toString().contains("ServerResponse"))
|| (m.getGenericReturnType().toString().contains("java.util.concurrent.CompletableFuture") && m.getGenericReturnType().toString().contains("ServerResponse")))
Expand Down Expand Up @@ -720,7 +720,7 @@ else if (m.getReturnType().getTypeName().contains("java.util.concurrent.Completi


methodBuilder.addCode(
"$L.thenAccept( r -> io.sinistral.proteus.server.ServerResponse.response(r)" + postProcess + "send(this,$L) )\n\t.exceptionally( ex -> ",
"$L.thenAccept( r -> io.sinistral.proteus.server.ServerResponse.response(r)" + postProcess + "send($L) )\n\t.exceptionally( ex -> ",
"response", "exchange");
methodBuilder.beginControlFlow("", "");
methodBuilder.addCode("\t\tthrow new java.util.concurrent.CompletionException(ex);\n\t");
Expand Down

0 comments on commit 487d57c

Please sign in to comment.