Skip to content

Add Jakarta REST Request and Response return support#828

Open
arturobernalg wants to merge 2 commits into
apache:masterfrom
arturobernalg:jakarta-rest-client
Open

Add Jakarta REST Request and Response return support#828
arturobernalg wants to merge 2 commits into
apache:masterfrom
arturobernalg:jakarta-rest-client

Conversation

@arturobernalg
Copy link
Copy Markdown
Member

@arturobernalg arturobernalg commented May 3, 2026

Support jakarta.ws.rs.core.Response as a resource method return type,
including access to response metadata and entity decoding. Responses
declared as Response are returned to the caller even for non-successful
status codes.

@arturobernalg arturobernalg requested a review from ok2c May 3, 2026 12:15
@ok2c
Copy link
Copy Markdown
Member

ok2c commented May 11, 2026

@arturobernalg Looks good overall. ClientRequest does not look very useful. I would drop it for now. I also would like to change the intermediate representation of the ClientResponse JSON content from byte array to JsonNode for better efficiency but this can be done as a separate change-set at a later point.

Represent buffered JSON response content as JsonNode internally and reuse it
for entity decoding. This avoids repeatedly decoding the same JSON byte array
while preserving the public Response readEntity behavior.
@arturobernalg
Copy link
Copy Markdown
Member Author

I also would like to change the intermediate representation of the ClientResponse JSON content from byte array to JsonNode

Done. I dropped ClientRequest / Request support and kept the change focused on Response.

I also changed JSON Response entity decoding to parse into JsonNode once and reuse that tree for subsequent readEntity(...) calls.

private JsonNode jsonNode;
private boolean jsonParsed;

RestClientResponse(final HttpResponse response, final byte[] body, final ObjectMapper objectMapper) {
Copy link
Copy Markdown
Member

@ok2c ok2c May 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@arturobernalg It would be better to digest the body into JsonNode directly if the content is known to be JSON bypassing byte[] altogether.

});
}
if (rawType == Response.class) {
return submit(requestProducer, new BasicResponseConsumer<>(new BasicAsyncEntityConsumer()))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@arturobernalg See if one could useJsonNodeEntityFallbackConsumer here or a similar custom response consumer.

Copy link
Copy Markdown
Member

@ok2c ok2c left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@arturobernalg Please squash your changes

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

Successfully merging this pull request may close these issues.

2 participants