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

Close stream when client responds with an entity #45569

Merged
merged 1 commit into from
Jan 14, 2025

Conversation

geoand
Copy link
Contributor

@geoand geoand commented Jan 14, 2025

This shouldn't have an effect given the type of
buffers we currently use, but if we change things
in the future, this call will be necessary

This shouldn't have an effect given the type of
buffers we currently use, but if we change things
in the future, this call will be necessary
@geoand geoand requested a review from gsmet January 14, 2025 10:10
Copy link
Member

@gsmet gsmet left a comment

Choose a reason for hiding this comment

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

I'm not entirely sure if we should do it this way or close the one from the response (or both).

I wonder if it's too early to do that given we don't really know how things will pan out. It's definitely something we will have to think about but I'm not sure we have all the information to do so atm.

I will let you judge of that, though.

@geoand
Copy link
Contributor Author

geoand commented Jan 14, 2025

I want to take it step by step and this one is the safest and most straightforward to do. We probably will at some point need a more clear place to close everything.

@@ -358,7 +358,7 @@ public void handle(AsyncResult<Buffer> ar) {
try {
if (buffer.length() > 0) {
requestContext.setResponseEntityStream(
new ByteBufInputStream(buffer.getByteBuf()));
new ByteBufInputStream(buffer.getByteBuf(), true));
Copy link
Contributor

Choose a reason for hiding this comment

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

closing an unreleaseable buffer won't have any effect AFAIK, but is fine to do it.
In case the buffer is not releaseable, instead.
The problem arise if the src buffer is used by the caller elsewhere, since we slice it without increasing the ref cnt, when the stream is closed, we release the src as well - which can be dangerous.
I think the problem here is the Vertx API which doesn't help to understand what to do with this...

Copy link
Contributor Author

@geoand geoand Jan 14, 2025

Choose a reason for hiding this comment

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

This codepath should not result in the buffer being reused anywhere else other than were we use it

I think the problem here is the Vertx API which doesn't help to understand what to do with this...

Agreed

This comment has been minimized.

Copy link

quarkus-bot bot commented Jan 14, 2025

Status for workflow Quarkus CI

This is the status report for running Quarkus CI on commit 7841f90.

✅ The latest workflow run for the pull request has completed successfully.

It should be safe to merge provided you have a look at the other checks in the summary.

You can consult the Develocity build scans.

@geoand geoand merged commit 947988b into quarkusio:main Jan 14, 2025
32 checks passed
@quarkus-bot quarkus-bot bot added this to the 3.18 - main milestone Jan 14, 2025
@geoand geoand deleted the rest-client-close branch January 15, 2025 07:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants