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

AbstractByteBuf.ensureWritable(...) should check if buffer was released #6978

Closed
wants to merge 1 commit into
base: 4.1
from

Conversation

Projects
None yet
4 participants
@normanmaurer
Member

normanmaurer commented Jul 17, 2017

Motivation:

AbstractByteBuf.ensureWritable(...) should check if buffer was released and if so throw an IllegalReferenceCountException

Modifications:

Ensure we throw in all cases.

Result:

More consistent and correct behaviour

@@ -1095,7 +1084,6 @@ public int writeBytes(InputStream in, int length)
@Override
public int writeBytes(ScatteringByteChannel in, int length) throws IOException {
ensureAccessible();
ensureWritable(length);
int writtenBytes = setBytes(writerIndex, in, length);

This comment has been minimized.

@Scottmitch

Scottmitch Jul 18, 2017

Member

the implementation of this method may call checkIndex but can now call checkIndex0. For example PooledDirectByteBuf#setBytes(..) and PooledHeapByteBuf#setBytes(..) call checkIndex. We should inspect all usages of checkIndex in buffer implementations which inherit from AbstractByteBuf as suggested in #6953 (comment).

@Scottmitch

Scottmitch Jul 18, 2017

Member

the implementation of this method may call checkIndex but can now call checkIndex0. For example PooledDirectByteBuf#setBytes(..) and PooledHeapByteBuf#setBytes(..) call checkIndex. We should inspect all usages of checkIndex in buffer implementations which inherit from AbstractByteBuf as suggested in #6953 (comment).

This comment has been minimized.

@Scottmitch

Scottmitch Jul 18, 2017

Member

Discussed with @normanmaurer offline ... both methods are public so we would have to create additional methods that bypass the additional call to ensureWritable (e.g writeBytes calls setBytes0 which calls checkIndex0) ... lets not worry about this for now.

@Scottmitch

Scottmitch Jul 18, 2017

Member

Discussed with @normanmaurer offline ... both methods are public so we would have to create additional methods that bypass the additional call to ensureWritable (e.g writeBytes calls setBytes0 which calls checkIndex0) ... lets not worry about this for now.

This comment has been minimized.

@normanmaurer

normanmaurer Jul 18, 2017

Member

+1...

@normanmaurer
AbstractByteBuf.ensureWritable(...) should check if buffer was released
Motivation:

AbstractByteBuf.ensureWritable(...) should check if buffer was released and if so throw an IllegalReferenceCountException

Modifications:

Ensure we throw in all cases.

Result:

More consistent and correct behaviour
@normanmaurer

This comment has been minimized.

Show comment
Hide comment
@normanmaurer

normanmaurer Jul 19, 2017

Member

Cherry-picked into 4.1 (d125ade) and 4.0 (44a7475)

Member

normanmaurer commented Jul 19, 2017

Cherry-picked into 4.1 (d125ade) and 4.0 (44a7475)

@normanmaurer normanmaurer deleted the ensure_writable branch Jul 19, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment