Counterintuitive behavior of method io.netty.buffer.AbstractByteBuf#readBytes(int)
See original GitHub issueExpected behavior
The following code should print both true
or both false
:
public static void main(String[] args) {
ByteBuf heapBuffer = new PooledByteBufAllocator(false).heapBuffer(1, 1).writeByte(1);
ByteBuf buffer_a = heapBuffer.readBytes(0);
ByteBuf buffer_b = heapBuffer.readBytes(1);
System.out.println(buffer_a.isDirect());
System.out.println(buffer_b.isDirect());
}
Actual behavior
buffer_a.isDirect()
printed true
,
buffer_b.isDirect()
printed false
.
Steps to reproduce
See above
Minimal yet complete reproducer code (or URL to code)
See above
Netty version
4.1
JVM version (e.g. java -version
)
1.8
OS version (e.g. uname -a
)
MacOS
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (8 by maintainers)
Top Results From Across the Web
Spark 2.3 java.lang.NoSuchMethodError: io.netty.buffer ...
This is because Hadoop binaries compiled with an older version and need us to just replace them. I haven't faced any issues with...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@trustin, Thanks a lot for the explanation, it really makes sense someway. Maybe I can add this explanation to the doc of method
io.netty.buffer.EmptyByteBuf#isDirect
, so that more people can better understand it.Great. Looking forward to your pull request 🙇