-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Avoid leaking memory in SseParser #27594
Conversation
Relates to: quarkusio#23997
Tests pass. @FroMage do you agree with this one? |
Well, it really depends on the semantics of the event, if the buffer is reused for every event or not. If it's reused, then we shouldn't release it. If the consumers have to release it, then sure. |
Where would it be reused? |
By the code sending us notifications of new data to read. |
Docs say:
So, it doesn't tell us what to do with the |
My question is whether in this case the buffer will ever be reused. |
To give you an example of why this sort of thing should be specified by the javadoc, here's where this handler gets called in the vertx http client: void handleChunk(Buffer chunk) {
Handler<Buffer> handler = chunkHandler;
if (handler != null) {
context.dispatch(chunk, handler);
}
if (body != null) {
body.appendBuffer(chunk);
}
} You can see our handler is called first, then we append the chunk (buffer) to the |
But currently it seems like no one is, and therefore we get a leak |
Well, it looks like it, I agree, but as you can see from a quick glance at the docs it's not specified, and at the impl, it appears to not always allow us to release it. So it's not clear that this fix is right. If it is right, then the docs should be updated and that's a vert.x bug, and I suspect the My point is that this may appear to work, and may work, but we should raise this question to the vert.x team. @tsegismont or @vietj can you tell us what we should do with the |
Now, I still don't know who's creating those This does raise the bigger question of what we should do for other |
@geoand @FroMage it doesn't look good to me. Where are the underlying I don't know where the corresponding |
It can not - it's an implementatio detail of the REST Client |
@geoand what happens if the developer uses the REST Client for something else than SSE? Is the direct buffer released somewhere? |
The handler in question only comes into play for SSE - none of the other codepaths handle buffers directly |
@geoand ok then |
@FroMage ^ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, @tsegismont cleared it up, looks safe then.
But really, the Vert.x docs could say what handlers should do with buffers they receive. |
See comment above, the docs don't say anything because Vert.x does not provide users with pooled buffers. So this case never happens. |
Relates to: #23997 (comment)