Skip to content

Auto-port 5.0: Add missing bounds check to AdaptiveByteBuf.getBytes(...) channel variants - #17630

Merged
normanmaurer merged 1 commit into
5.0from
auto-port-pr-17620-to-5.0
Sep 26, 2026
Merged

normanmaurer merged 1 commit into
5.0from
auto-port-pr-17620-to-5.0

Conversation

@netty-project-bot

Copy link
Copy Markdown
Contributor

Auto-port of #17620 to 5.0
Cherry-picked commit: a0c8ddc


Motivation:

AdaptiveByteBuf.getBytes(int, GatheringByteChannel, int) and AdaptiveByteBuf.getBytes(int, FileChannel, long, int) do not call checkIndex(index, length), unlike other ByteBuf implementations.

These methods write from the cached tmpNioBuf, whose limit is maxFastCapacity (the size of the underlying segment) rather than capacity(). An out-of-bounds request that still fits within the segment is therefore not rejected: instead of throwing IndexOutOfBoundsException, the buffer silently writes bytes located beyond its own capacity to the channel.

Modification:

Add the missing checkIndex(index, length) to both methods, and add tests covering both channel variants.

Result:

AdaptiveByteBuf no longer reads past its capacity, and throws IndexOutOfBoundsException like the other ByteBuf implementations.

…ariants (#17620)

Motivation:

`AdaptiveByteBuf.getBytes(int, GatheringByteChannel, int)` and
`AdaptiveByteBuf.getBytes(int, FileChannel, long, int)` do not call
`checkIndex(index, length)`, unlike other `ByteBuf` implementations.

These methods write from the cached `tmpNioBuf`, whose limit is
`maxFastCapacity` (the size of the underlying segment) rather than
`capacity()`. An out-of-bounds request that still fits within the
segment is therefore not rejected: instead of throwing
`IndexOutOfBoundsException`, the buffer silently writes bytes located
beyond its own capacity to the channel.

Modification:

Add the missing `checkIndex(index, length)` to both methods, and add
tests covering both channel variants.

Result:

`AdaptiveByteBuf` no longer reads past its capacity, and throws
`IndexOutOfBoundsException` like the other `ByteBuf` implementations.

(cherry picked from commit a0c8ddc)
@testlens-app

testlens-app Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

🚨 TestLens detected 3 failed tests 🚨

Here is what you can do:

  1. Inspect the test failures carefully.
  2. If you are convinced that some of the tests are flaky, you can mute them below.
  3. Finally, trigger a rerun by checking the rerun checkbox.

Test Summary

Build PR / linux-x86_64-java25-awslc build > Netty/Common

Test Runs Flakiness
SingleThreadEventExecutorTest > testSuspendDoesNotRaceWithCancelledScheduledTask() ❌ 9% 🟠

Build PR / macos-aarch64-java25-boringssl build > Netty/Transport/Native/KQueue

Test Runs Flakiness
KQueueDatagramUnicastIPv6MappedTest > testSimpleSendWithoutBind(TestInfo) ❌ 3% 🟡

Build PR / windows-x86_64-java25-boringssl > Netty/Buffer

Test Runs Flakiness
LittleEndianDirectByteBufTest > testToStringMultipleThreads() ❌ 0% 🟢

🏷️ Commit: 24d4e2d
▶️ Tests: 165584 executed
⚪️ Checks: 12/12 completed

Test Failures

SingleThreadEventExecutorTest > testSuspendDoesNotRaceWithCancelledScheduledTask() (Netty/Common in Build PR / linux-x86_64-java25-awslc build)
org.opentest4j.AssertionFailedError: worker thread did not terminate at iteration 658 ==> expected: <false> but was: <true>
	at org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:151)
	at org.junit.jupiter.api.AssertionFailureBuilder.buildAndThrow(AssertionFailureBuilder.java:132)
	at org.junit.jupiter.api.AssertFalse.failNotFalse(AssertFalse.java:63)
	at org.junit.jupiter.api.AssertFalse.assertFalse(AssertFalse.java:36)
	at org.junit.jupiter.api.Assertions.assertFalse(Assertions.java:239)
	at io.netty.util.concurrent.SingleThreadEventExecutorTest.testSuspendDoesNotRaceWithCancelledScheduledTask(SingleThreadEventExecutorTest.java:243)
	at java.base/java.lang.reflect.Method.invoke(Method.java:565)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1604)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1604)
expected actual
false true
KQueueDatagramUnicastIPv6MappedTest > testSimpleSendWithoutBind(TestInfo) (Netty/Transport/Native/KQueue in Build PR / macos-aarch64-java25-boringssl build)
org.opentest4j.AssertionFailedError
	at io.netty.testsuite.transport.socket.DatagramUnicastTest.testSimpleSend0(DatagramUnicastTest.java:367)
	at io.netty.testsuite.transport.socket.DatagramUnicastTest.testSimpleSend(DatagramUnicastTest.java:194)
	at io.netty.testsuite.transport.socket.DatagramUnicastTest.testSimpleSendWithoutBind(DatagramUnicastTest.java:186)
	at io.netty.testsuite.transport.socket.DatagramUnicastTest$6.run(DatagramUnicastTest.java:180)
	at io.netty.testsuite.transport.socket.DatagramUnicastTest$6.run(DatagramUnicastTest.java:177)
	at io.netty.testsuite.transport.AbstractComboTestsuiteTest.run(AbstractComboTestsuiteTest.java:52)
	at io.netty.testsuite.transport.socket.DatagramUnicastTest.testSimpleSendWithoutBind(DatagramUnicastTest.java:177)
	at java.base/java.lang.reflect.Method.invoke(Method.java:565)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1604)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1604)
LittleEndianDirectByteBufTest > testToStringMultipleThreads() (Netty/Buffer in Build PR / windows-x86_64-java25-boringssl)
java.util.concurrent.TimeoutException
	at java.base/java.util.concurrent.CyclicBarrier.dowait(CyclicBarrier.java:259)
	at java.base/java.util.concurrent.CyclicBarrier.await(CyclicBarrier.java:437)
	at io.netty.buffer.AbstractByteBufTest$30.run(AbstractByteBufTest.java:2316)
	at java.base/java.lang.Thread.run(Thread.java:1474)
	Suppressed: java.util.concurrent.BrokenBarrierException
		at java.base/java.util.concurrent.CyclicBarrier.dowait(CyclicBarrier.java:252)
		... 3 more
	Suppressed: java.util.concurrent.BrokenBarrierException
		at java.base/java.util.concurrent.CyclicBarrier.dowait(CyclicBarrier.java:252)
		... 3 more
	Suppressed: java.util.concurrent.BrokenBarrierException
		at java.base/java.util.concurrent.CyclicBarrier.dowait(CyclicBarrier.java:252)
		... 3 more
	Suppressed: java.util.concurrent.BrokenBarrierException
		at java.base/java.util.concurrent.CyclicBarrier.dowait(CyclicBarrier.java:252)
		... 3 more
	Suppressed: java.util.concurrent.BrokenBarrierException
		at java.base/java.util.concurrent.CyclicBarrier.dowait(CyclicBarrier.java:252)
		... 3 more
	Suppressed: java.util.concurrent.BrokenBarrierException
		at java.base/java.util.concurrent.CyclicBarrier.dowait(CyclicBarrier.java:252)
		... 3 more
	Suppressed: java.util.concurrent.BrokenBarrierException
		at java.base/java.util.concurrent.CyclicBarrier.dowait(CyclicBarrier.java:252)
		... 3 more
	Suppressed: java.util.concurrent.BrokenBarrierException
		at java.base/java.util.concurrent.CyclicBarrier.dowait(CyclicBarrier.java:252)
		... 3 more
	Suppressed: java.util.concurrent.BrokenBarrierException
		at java.base/java.util.concurrent.CyclicBarrier.dowait(CyclicBarrier.java:210)
		... 3 more

Rerun Controls

Select tests to mute in this pull request:

  • KQueueDatagramUnicastIPv6MappedTest > testSimpleSendWithoutBind(TestInfo)
  • LittleEndianDirectByteBufTest > testToStringMultipleThreads()
  • SingleThreadEventExecutorTest > testSuspendDoesNotRaceWithCancelledScheduledTask()

Reuse successful test results:

  • ♻️ Only rerun the tests that failed or were muted before

Click the checkbox to trigger a rerun:

  • Rerun jobs

Learn more about TestLens at testlens.app/docs.

@normanmaurer normanmaurer added this to the 5.0.0.Final milestone Sep 26, 2026
@normanmaurer
normanmaurer merged commit 497d8b2 into 5.0 Sep 26, 2026
10 of 13 checks passed
@normanmaurer
normanmaurer deleted the auto-port-pr-17620-to-5.0 branch September 26, 2026 12:34
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