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

Properly use headers from RestMulti when the multi is empty #39587

Merged
merged 1 commit into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading