-
-
Notifications
You must be signed in to change notification settings - Fork 15.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
DelegatingDecompressorFrameListener doesn't support deferral of processed bytes #5375
Comments
Thanks for reporting @npordash! Are you in a situation where |
Do you have a unit test which you would be willing to contribute? I have a PR but it would be nice to verify against a unit test if you already have one. |
Thanks for the quick response! I'm not in a situation where My use-case is that I'm exposing inbound data frames as an Unfortunately, I do not have an existing unit test for this yet. I stumbled across this while I was prototyping which involved manual testing with |
As long as you are not double releasing the bytes you should be OK. I think I found the issue and I'll ask you to verify with the PR when its ready. |
Awesome, thanks again! |
Motivation: If a single DATA frame ends up being decompressed into multiple frames by DelegatingDecompressorFrameListener the flow control accounting is delayed until all frames have been decompressed. However it is possible the user may want to return bytes to the flow controller which were not included in the onDataRead return value. In this case the amount of processed bytes has not been incremented and will lead to negative value for processed bytes. Modifications: - Http2Decompressor.incrementProcessedBytes should be called each time onDataRead is called to ensure all bytes are accounted for at the correct time Result: Fixes netty#5375
Motivation: If a single DATA frame ends up being decompressed into multiple frames by DelegatingDecompressorFrameListener the flow control accounting is delayed until all frames have been decompressed. However it is possible the user may want to return bytes to the flow controller which were not included in the onDataRead return value. In this case the amount of processed bytes has not been incremented and will lead to negative value for processed bytes. Modifications: - Http2Decompressor.incrementProcessedBytes should be called each time onDataRead is called to ensure all bytes are accounted for at the correct time Result: Fixes netty#5375
Http2FrameListener.onDataRead
states that reporting of processed bytes to the local flow controller can be deferred by returning something less thandata + padding
and then later doing something equivalent toconnection().local().flowController().consumeBytes(Http2Stream, int)
.This works fine until you start using a
DelegatingDecompressorFrameListener
because once you callconsumeBytes
you end up with the following exception:As far as I can tell the reason for this is because
Http2Decompressor
is expectingincrementProcessedBytes
to be called prior toconsumeProcessedBytes
and you can't consume more than it has been incremented, which makes sense, butDelegatingDecompressorFrameListener.onDataRead
only callsincrementProcessedBytes
after all calls toonDataRead
returns and only increments the processed bytes based on what was accumulated from theonDataRead
calls which effectively means you need to fully consume the buffer inonDataRead
.I tested this with both 4.1.0.Final and 4.1.1.Final.
The text was updated successfully, but these errors were encountered: