Closed
Description
Expected behavior
ByteBuf haystack = Unpooled.copiedBuffer("+PONG\r\n", CharsetUtil.UTF_8);
ByteBuf needle = Unpooled.copiedBuffer("\r\n", CharsetUtil.UTF_8);
haystack.readByte();
int index = ByteBufUtil.indexOf(needle ,haystack);
System.out.println(index);
expected result is 5.
Actual behavior
actual result is 4.
Steps to reproduce
Minimal yet complete reproducer code (or URL to code)
Netty version
4.1.73.Final-SNAPSHOT
JVM version (e.g. java -version
)
openjdk version "11.0.13" 2021-10-19
OpenJDK Runtime Environment (build 11.0.13+8-Ubuntu-0ubuntu1.21.10)
OpenJDK 64-Bit Server VM (build 11.0.13+8-Ubuntu-0ubuntu1.21.10, mixed mode, sharing)
OS version (e.g. uname -a
)
Linux XPS-13-9310 5.13.0-22-generic #22-Ubuntu SMP Fri Nov 5 13:21:36 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
Metadata
Metadata
Assignees
Labels
No labels
Activity
chrisvest commentedon Jan 5, 2022
Thanks for the report, preparing a fix.
Fix ByteBufUtil.indexOf(buf, buf)
shichaoyuan commentedon Jan 5, 2022
good
wanglunhui2012 commentedon Jan 5, 2022
this is
ByteBuf
feature,readByte()
make readIndex + 1,so the first index isP
rather than+
.Fix ByteBufUtil.indexOf(buf, buf) (#11970)
Fix ByteBufUtil.indexOf(buf, buf) (#11970)
Fix ByteBufUtil.indexOf(buf, buf) (netty#11970)
Fix ByteBufUtil.indexOf(buf, buf) (netty#11970)