Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Properly use headers from RestMulti when the datasource is empty.

Signed-off-by: Pierre Adam <[email protected]>
  • Loading branch information
PierreAdam committed Mar 20, 2024
1 parent 7eb8479 commit 7230239
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,19 @@ public Multi<Message> multiNdJson2() {
Wrapper::getStatus);
}

@Path("restmulti/empty")
@GET
@Produces(RestMediaType.APPLICATION_JSON)
public Multi<Message> restMultiEmptyJson() {
return RestMulti.fromUniResponse(
Uni.createFrom().item(
() -> new Wrapper(Multi.createFrom().empty(),
new AbstractMap.SimpleEntry<>("foo", "bar"), 222)),
Wrapper::getData,
Wrapper::getHeaders,
Wrapper::getStatus);
}

@Path("stream-json/multi")
@GET
@Produces(RestMediaType.APPLICATION_STREAM_JSON)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,14 @@ public void testNdJsonMultiFromMulti2() {
.header("foo", "bar");
}

@Test
public void testRestMultiEmptyJson() {
when().get(uri.toString() + "streams/restmulti/empty")
.then().statusCode(222)
.body(is("[]"))
.header("foo", "bar");
}

@Test
public void testStreamJsonMultiFromMulti() {
when().get(uri.toString() + "streams/stream-json/multi")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ private List<StreamingResponseCustomizer> determineCustomizers(boolean isFirst)
@Override
public void onComplete() {
if (!hadItem) {
StreamingUtil.setHeaders(requestContext, requestContext.serverResponse(), staticCustomizers);
StreamingUtil.setHeaders(requestContext, requestContext.serverResponse(), this.determineCustomizers(true));
}
if (json) {
String postfix = onCompleteText();
Expand Down

0 comments on commit 7230239

Please sign in to comment.