Skip to content

ReadyOnly*Buf must return false for isWritable(*) when sliced or duplicated - #14071

Merged
normanmaurer merged 5 commits into
netty:4.1from
lhotari:lh-fix-readonly-buffer-with-SslHandler
May 24, 2024
Merged

normanmaurer merged 5 commits into
netty:4.1from
lhotari:lh-fix-readonly-buffer-with-SslHandler

Conversation

@lhotari

@lhotari lhotari commented May 22, 2024 •

Copy link
Copy Markdown
Contributor

Motivation:

We need to ensure we return the correct type when duplicate() or slice(*) is called as otherwise we might return true when isWritable(...) is called

Modifications:

  • Return correct type
  • Add test-cases

Result:

Related to #14069

@normanmaurer normanmaurer left a comment

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.

LGTM

@lhotari

lhotari commented May 22, 2024

Copy link
Copy Markdown
Contributor Author

@normanmaurer I'm a bit lost on how to add a unit test for this one. Would you mind giving a hint which class or method I should look for examples of similar tests?

@lhotari
lhotari marked this pull request as ready for review May 22, 2024 19:55
@lhotari

lhotari commented May 22, 2024

Copy link
Copy Markdown
Contributor Author

The workaround I'm currently testing for Pulsar is to use Unpooled.unmodifiableBuffer(buf).retain() until this PR has been released. That seems to be compatible with SslHandler since isWritable(int) will always return false. When the buffer is created with buf.asReadOnly().retainedDuplicate(), isWritable(int) will return true (at least in some cases).

@lhotari

lhotari commented May 22, 2024 •

Copy link
Copy Markdown
Contributor Author

There are more obstacles on the way to support readonly buffers in SslHandler. When I tested the workaround of using Unpooled.unmodifiableBuffer(buf).retain() in Pulsar, it fails because of issue #14070 .

@lhotari

lhotari commented May 22, 2024

Copy link
Copy Markdown
Contributor Author

In the Pulsar PR, I'm currently using this type of workaround: https://github.com/apache/pulsar/pull/22760/files . Currently running CI to see if tests pass with it. I ran some manual tests were I have been able to reproduce the race conditions and those pass.

…icated

Motivation:

We need to ensure we return the correct type when duplicate() or slice(*) is called as otherwise we might return true when isWritable(...) is called

Modifications:

- Return correct type
- Add test-cases

Result:

Related to netty#14069
@normanmaurer

Copy link
Copy Markdown
Member

@lhotari actually the problem was not in the queue implementation but the buffers itself. I just pushed an extra commit to your branch which fixes it

@normanmaurer normanmaurer added this to the 4.1.111.Final milestone May 23, 2024
private static boolean attemptCopyToCumulation(ByteBuf cumulation, ByteBuf next, int wrapDataSize) {
final int inReadableBytes = next.readableBytes();
// Nothing to copy so just release the buffer.
if (inReadableBytes == 0) {

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.

I still kept this one, even tho its not needed to fix the problem

@lhotari

lhotari commented May 23, 2024

Copy link
Copy Markdown
Contributor Author

@lhotari actually the problem was not in the queue implementation but the buffers itself. I just pushed an extra commit to your branch which fixes it

Awesome! Thank you @normanmaurer

@normanmaurer normanmaurer changed the title Add support for readonly buffers in SslHandler ReadyOnly*Buf must return false for isWritable(*) when sliced or duplicated May 23, 2024
@normanmaurer
normanmaurer merged commit 5085cef into netty:4.1 May 24, 2024
normanmaurer added a commit that referenced this pull request May 24, 2024
…icated (#14071)

Motivation:

We need to ensure we return the correct type when duplicate() or
slice(*) is called as otherwise we might return true when
isWritable(...) is called

Modifications:

- Return correct type
- Add test-cases

Result:

Related to #14069

---------

Co-authored-by: Norman Maurer <[email protected]>
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.

3 participants