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

Fixes Payload#hasMetadata to strictly match the flag in the frame #783

Merged
merged 8 commits into from
Apr 24, 2020

Conversation

OlegDokuka
Copy link
Member

This PR alights with the rsocket/rsocket#302 proposal.
Also, it ensures that ByteBufPayload throws an exception when one tries to use the released instance

Signed-off-by: Oleh Dokuka [email protected]

@OlegDokuka OlegDokuka added this to the 1.0 RC7 milestone Apr 17, 2020
@OlegDokuka OlegDokuka self-assigned this Apr 17, 2020
@OlegDokuka OlegDokuka linked an issue Apr 17, 2020 that may be closed by this pull request
Copy link
Contributor

@rstoyanchev rstoyanchev left a comment

Choose a reason for hiding this comment

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

This looks generally okay but I'd like to suggest some further improvements.

First, (the pre-existing) DataAndMetadataFlyweight#encodeOnlyMetadata I think is intended for use in frames with metadata only, and therefore it's confusing to have it in DataAndMetadataFlyweight and now conceptually overlaps with the (newly added) encode with metadata only. I propose to remove encodeOnlyMetadata. It is used only in LeaseFrameFlyweight and it's a one liner, so it can be copied there (like MetaDataPushFrameFlyweight does it).

For the remaining encode methods in DataAndMetadataFlyweight I think they should be consolidated into one method that takes both metadata and data, as well as the hasData and hasMetadata flag. This will allow encapsulating the if-else condition that is currently used to decide which encode to call form multiple places.

@OlegDokuka
Copy link
Member Author

Also, following the discussion at the specification thread mentioned earlier, EmptyMetadata should be supported with hasMetadata returning true. Thus will provide another workaround

@OlegDokuka OlegDokuka marked this pull request as draft April 19, 2020 08:35
@rstoyanchev
Copy link
Contributor

Yes I like having hasMetadata map to the setting of the metadata flag, and nothing more. The Javadoc would need to be adjusted to reflect that.

Initially that issue was hidden because both sides uses limitRate which does prefetch 256 elements in advance so it is almost impossible to track underflow in request

Signed-off-by: Oleh Dokuka <[email protected]>
ensures that ByteBufPayload is not accessible anymore when it has been released

Signed-off-by: Oleh Dokuka <[email protected]>
Signed-off-by: Oleh Dokuka <[email protected]>
…ed correctly

Right now there was observed a few issues related to that

Payload with no metadata was incorrectly incoded so it results to hasMetadata true on the received side
Also, optimized the API of Flyweights to ensure that we have common things in one place

Signed-off-by: Oleh Dokuka <[email protected]>
@OlegDokuka OlegDokuka marked this pull request as ready for review April 23, 2020 13:46
@OlegDokuka OlegDokuka changed the title Fixes behaviour of flight-weights when it gets unreadable buffers & fixes issue with ByteBufPayload access when it has been released Fixes behaviour of flyweights when it gets unreadable buffers & fixes issue with ByteBufPayload access when it has been released Apr 23, 2020
@OlegDokuka OlegDokuka requested a review from rstoyanchev April 23, 2020 15:14
Copy link
Contributor

@rstoyanchev rstoyanchev left a comment

Choose a reason for hiding this comment

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

LGTM!

@OlegDokuka OlegDokuka changed the title Fixes behaviour of flyweights when it gets unreadable buffers & fixes issue with ByteBufPayload access when it has been released Fixes Payload#hasMetadata to strictly flow the flag in frame Apr 24, 2020
@OlegDokuka OlegDokuka merged commit 3a5a4c2 into develop Apr 24, 2020
@OlegDokuka OlegDokuka deleted the bugfix/#764 branch April 24, 2020 07:47
@rstoyanchev rstoyanchev changed the title Fixes Payload#hasMetadata to strictly flow the flag in frame Fixes Payload#hasMetadata to strictly match the flag in the frame Apr 27, 2020
@rstoyanchev rstoyanchev removed the bug label Apr 28, 2020
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.

Improper Payload#hasMetadata behavior.
3 participants