GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||
GeezerVison is showing github.com — Avoid UnsupportedOperationException in CompositeeByteBuf when noUnsafe is true by dreamlike-ocean · Pull Request #16097 · netty/netty Conversation
|
| ByteBuf buf2 = Unpooled.compositeBuffer().addComponent( | |
| buffer(bufferType, 8)).addComponent(buffer(bufferType, 24)); | |
| // write some byte so we start writing with an offset. | |
| buf2.writeByte(1); | |
| ByteBufUtil.writeUtf8(buf2, utf8); |
Modification:
Result:
Resolves UnsupportedOperationException when writing UTF-8 to direct CompositeByteBuf with noUnsafe.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…eByteBuf with noUnsafe
There was an error while loading. Please reload this page.
|
Thanks! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…e is true (netty#16097) Motivation: On Java 25, Netty defaults to io.netty.noUnsafe=true. The following code throws UnsupportedOperationException: ``` java CompositeByteBuf compositeByteBuf = ByteBufAllocator.DEFAULT.compositeDirectBuffer(); compositeByteBuf.addComponent(ByteBufAllocator.DEFAULT.directBuffer(2)); compositeByteBuf.addComponent(ByteBufAllocator.DEFAULT.directBuffer(2)); ByteBufUtil.writeUtf8(compositeByteBuf, ""); ``` This happens because ByteBufUtil#writeUtf8(AbstractByteBuf, ...) uses ByteBuf#internalNioBuffer, which throws UnsupportedOperationException when a CompositeByteBuf is composed of multiple DirectByteBuf components. With io.netty.noUnsafe=false, Netty uses the safe UTF-8 write path, so the issue is not triggered. The existing unit test did not catch this because it uses a direct=false compositeByteBuf; after calling `writeByte`, a heapBytebuf component is added, so the failing path is avoided. https://github.com/netty/netty/blob/11938b53522a578b7e113e4fe85baa560e7aa841/buffer/src/test/java/io/netty/buffer/ByteBufUtilTest.java#L459-L463 Modification: 1. Avoid UnsupportedOperationException in ByteBufUtil#writeUtf8 for direct CompositeByteBuf when io.netty.noUnsafe=true. 2. Fix the unit test to cover the failing scenario. Result: Resolves UnsupportedOperationException when writing UTF-8 to direct CompositeByteBuf with noUnsafe. (cherry picked from commit db33c48)
…e is true (#16097) (#16100) Motivation: On Java 25, Netty defaults to io.netty.noUnsafe=true. The following code throws UnsupportedOperationException: ``` java CompositeByteBuf compositeByteBuf = ByteBufAllocator.DEFAULT.compositeDirectBuffer(); compositeByteBuf.addComponent(ByteBufAllocator.DEFAULT.directBuffer(2)); compositeByteBuf.addComponent(ByteBufAllocator.DEFAULT.directBuffer(2)); ByteBufUtil.writeUtf8(compositeByteBuf, ""); ``` This happens because ByteBufUtil#writeUtf8(AbstractByteBuf, ...) uses ByteBuf#internalNioBuffer, which throws UnsupportedOperationException when a CompositeByteBuf is composed of multiple DirectByteBuf components. With io.netty.noUnsafe=false, Netty uses the safe UTF-8 write path, so the issue is not triggered. The existing unit test did not catch this because it uses a direct=false compositeByteBuf; after calling `writeByte`, a heapBytebuf component is added, so the failing path is avoided. https://github.com/netty/netty/blob/11938b53522a578b7e113e4fe85baa560e7aa841/buffer/src/test/java/io/netty/buffer/ByteBufUtilTest.java#L459-L463 Modification: 1. Avoid UnsupportedOperationException in ByteBufUtil#writeUtf8 for direct CompositeByteBuf when io.netty.noUnsafe=true. 2. Fix the unit test to cover the failing scenario. Result: Resolves UnsupportedOperationException when writing UTF-8 to direct CompositeByteBuf with noUnsafe. (cherry picked from commit db33c48) Co-authored-by: Mengyang Li <[email protected]>
### What changes were proposed in this pull request? This PR aims to upgrade Netty to `4.2.10.Final`. ### Why are the changes needed? To bring the latest bug fixed version. - https://netty.io/news/2026/02/05/4-2-10.html - netty/netty#16097 - netty/netty#16144 ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? Pass the CIs. ### Was this patch authored or co-authored using generative AI tooling? `Gemini 3 Pro (High)` on `Antigravity`. Closes #54203 from dongjoon-hyun/SPARK-55420. Authored-by: Dongjoon Hyun <[email protected]> Signed-off-by: Dongjoon Hyun <[email protected]>
### What changes were proposed in this pull request? This PR aims to upgrade Netty to `4.2.10.Final`. ### Why are the changes needed? To bring the latest bug fixed version. - https://netty.io/news/2026/02/05/4-2-10.html - netty/netty#16097 - netty/netty#16144 ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? Pass the CIs. ### Was this patch authored or co-authored using generative AI tooling? `Gemini 3 Pro (High)` on `Antigravity`. Closes apache#54203 from dongjoon-hyun/SPARK-55420. Authored-by: Dongjoon Hyun <[email protected]> Signed-off-by: Dongjoon Hyun <[email protected]>
### What changes were proposed in this pull request? This PR aims to upgrade Netty to `4.2.10.Final`. ### Why are the changes needed? To bring the latest bug fixed version. - https://netty.io/news/2026/02/05/4-2-10.html - netty/netty#16097 - netty/netty#16144 ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? Pass the CIs. ### Was this patch authored or co-authored using generative AI tooling? `Gemini 3 Pro (High)` on `Antigravity`. Closes apache#54203 from dongjoon-hyun/SPARK-55420. Authored-by: Dongjoon Hyun <[email protected]> Signed-off-by: Dongjoon Hyun <[email protected]>
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.